<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Tcp on Inliniac</title>
    <link>https://inliniac.net/blog/category/tcp/</link>
    <description>Recent content in Tcp on Inliniac</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Fri, 19 Apr 2013 07:53:00 +0000</lastBuildDate>
    <atom:link href="https://inliniac.net/blog/category/tcp/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Suricata: Handling of multiple different SYN/ACKs</title>
      <link>https://inliniac.net/blog/2013/04/19/suricata-handling-of-multiple-different-synacks/</link>
      <pubDate>Fri, 19 Apr 2013 07:53:00 +0000</pubDate>
      <guid>https://inliniac.net/blog/2013/04/19/suricata-handling-of-multiple-different-synacks/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://inliniac.net/blog/blog/wp-content/uploads/2013/04/synack.png&#34; alt=&#34;synack&#34;&gt;When processing the TCP 3 way handshake (3whs), Suricata&amp;rsquo;s TCP stream engine will closely follow the setup of a TCP connection to make sure the rest of the session can be tracked and reassembled properly. Retransmissions of SYN/ACKs are silently accepted, unless they are different somehow. If the SEQ or ACK values are different they are considered wrong and events are set. The stream events rules will match on this.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Suricata IPS improvements</title>
      <link>https://inliniac.net/blog/2011/01/31/suricata-ips-improvements/</link>
      <pubDate>Mon, 31 Jan 2011 20:51:25 +0000</pubDate>
      <guid>https://inliniac.net/blog/2011/01/31/suricata-ips-improvements/</guid>
      <description>&lt;p&gt;January has been a productive month for Suricata, especially for the IPS part of it. I&amp;rsquo;ve quite some time on adding support to the stream engine to operate differently when running inline. This was needed as dropping attacks found in the reassembled stream or the application layer was not reliable. Up until now the stream engine would offer the reassembled stream to the detection engine as soon as it was ACK&amp;rsquo;d. This meant that by definition the packets containing the data had already passed the IPS device. Simply switching to sending un-ACK&amp;rsquo;d data to the detection engine would have it&amp;rsquo;s own set of issues.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Suricata 1.0.2 released</title>
      <link>https://inliniac.net/blog/2010/09/02/suricata-1-0-2-released/</link>
      <pubDate>Thu, 02 Sep 2010 17:36:38 +0000</pubDate>
      <guid>https://inliniac.net/blog/2010/09/02/suricata-1-0-2-released/</guid>
      <description>&lt;p&gt;After some well deserved vacation I&amp;rsquo;m getting back up to speed in Suricata development. Luckily most of our dev team continued to work in my absence, making today&amp;rsquo;s 1.0.2 release possible.&lt;/p&gt;&#xA;&lt;p&gt;The main focus of this release was fixing the TCP stream engine. &lt;a href=&#34;http://twitter.com/judy_novak&#34;&gt;Judy Novak&lt;/a&gt; found a number of ways to evade detection. See her &lt;a href=&#34;http://www.packetstan.com/2010/09/suricata-tcp-evasions.html&#34;&gt;blog post&lt;/a&gt; describing the issues.&lt;/p&gt;&#xA;&lt;p&gt;The biggest other change is the addition of a new application layer module. The SSH parser parses SSH sessions and stops detection/inspection of the stream after the encrypted part of the session has started. So this is mainly a module focused on reducing the number of packets that need inspection, just like the SSL and TLS modules.&lt;/p&gt;</description>
    </item>
    <item>
      <title>OISF engine prototype: streams handling</title>
      <link>https://inliniac.net/blog/2009/03/31/oisf-engine-prototype-streams-handling/</link>
      <pubDate>Tue, 31 Mar 2009 15:36:27 +0000</pubDate>
      <guid>https://inliniac.net/blog/2009/03/31/oisf-engine-prototype-streams-handling/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve been thinking about how to deal with streams in the OISF engine. We need to do stream reassembly to be able to handle spliced sessions, otherwise it would be very easy to evade detection. Snort traditionally used an approach of inspecting the packets individually and reassembling (part of) the stream in a pseudo packet, that was inspected mostly like a normal packet. Recent Snort versions, especially when Stream5 was introduced, have a so called stream api. This enables detection modules to control the reassembly better.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Improving Snort_inline&#39;s NFQ performance</title>
      <link>https://inliniac.net/blog/2008/01/23/improving-snort_inlines-nfq-performance/</link>
      <pubDate>Wed, 23 Jan 2008 15:27:29 +0000</pubDate>
      <guid>https://inliniac.net/blog/2008/01/23/improving-snort_inlines-nfq-performance/</guid>
      <description>&lt;p&gt;When using Snort_inline with NFQ support, it&amp;rsquo;s likely that at some point you&amp;rsquo;ve seen messages like these on the console: &lt;em&gt;packet recv contents failure: No buffer space available&lt;/em&gt;. When the messages are appearing Snort_inline slows down significantly. I&amp;rsquo;ve been trying to find out why.&lt;/p&gt;&#xA;&lt;p&gt;There are a number of setting that influence NFQ performance. One of them is the NFQ queue maximum length. This is a value in packets. Snort_inline takes an argument to modify the buffer length: &amp;ndash;queue-maxlen 5000 (note: there are two dashes before queue-maxlen).&lt;/p&gt;</description>
    </item>
    <item>
      <title>New Snort_inline TCP window normalization code in SVN</title>
      <link>https://inliniac.net/blog/2007/11/17/new-snort_inline-tcp-window-normalization-code-in-svn/</link>
      <pubDate>Sat, 17 Nov 2007 13:55:38 +0000</pubDate>
      <guid>https://inliniac.net/blog/2007/11/17/new-snort_inline-tcp-window-normalization-code-in-svn/</guid>
      <description>&lt;p&gt;A while ago I &lt;a href=&#34;http://www.inliniac.net/blog/2007/09/04/window-scaling-normalization-in-snort_inline-broken-by-design.html&#34;&gt;wrote&lt;/a&gt; about why the TCP window scaling normalization in Snort_inline was broken by design. I also wrote about a new solution I was working on and testing that would be uploaded to SVN soon. I just committed the patch to SVN. What it does is add two new options to stream4:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;norm_window&lt;/strong&gt;: normalize the TCP window (disabled by default). This is to protect Snort_inline from being forced to queue too many packets.&#xA;&lt;strong&gt;max_win_size&lt;/strong&gt;: maximum size of the scaled TCP window. Packets increasing the window beyond the limit are modified.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Window scaling normalization in Snort_inline broken by design</title>
      <link>https://inliniac.net/blog/2007/09/04/window-scaling-normalization-in-snort_inline-broken-by-design/</link>
      <pubDate>Tue, 04 Sep 2007 15:51:25 +0000</pubDate>
      <guid>https://inliniac.net/blog/2007/09/04/window-scaling-normalization-in-snort_inline-broken-by-design/</guid>
      <description>&lt;p&gt;After debugging some connection problems I found that the wscale normalization concept is flawed. I&amp;rsquo;ll describe here what is wrong with it and then move on to suggest a different solution I&amp;rsquo;m currently testing. The problem I was seeing is that some connections to some webservers stalled without an apparent reason.&lt;/p&gt;&#xA;&lt;p&gt;First a quick reminder of why I originally came up with the wscale normalization. Stream4 originally doesn&amp;rsquo;t look at the window scaling value when determining the TCP window. This causes it to be wrong about the TCP window in about every connection, which is one of the reasons out of window packets are not dropped (this is actually a gaping evasion hole since these packets are not used in stream reassembly). This is why I decided to add window scaling support to the stream4inline extension. This works great and allows the admin to drop out of window packets. There is a problem associated with it though. The maximal window that is possible with wscaling is 1GB. This would mean that Snort_inline would in the worst case have to queue almost 1GB of data in it&amp;rsquo;s buffers for a single stream. To prevent this being used by an attacker to attack Snort_inline, I wanted give the admin the option to set a maximal wscale size.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Snort_inline and out of order packets</title>
      <link>https://inliniac.net/blog/2007/07/30/snort_inline-and-out-of-order-packets/</link>
      <pubDate>Mon, 30 Jul 2007 21:22:56 +0000</pubDate>
      <guid>https://inliniac.net/blog/2007/07/30/snort_inline-and-out-of-order-packets/</guid>
      <description>&lt;p&gt;In Snort_inline&amp;rsquo;s stream4 modifications, one of the changes is that out of order TCP packets are treated differently from unmodified stream4. This can cause some new alerts to appear and some unexpected behaviour. So I&amp;rsquo;ll try to explain what happens here.&lt;/p&gt;&#xA;&lt;p&gt;First of all let me explain quickly what out of order packets are. To put it simple, TCP packets are send out by the source host in a specific order but can arrive in a different order at the destination. Packetloss, link saturation, routing issues are among many things that can cause this. A Snort_inline specific issue is that when Snort_inline can&amp;rsquo;t keep up with the packets it needs to process, it will drop packets which causes packetloss. These packets will then have to be resent by the sending host.&lt;/p&gt;</description>
    </item>
    <item>
      <title>TCP Window scaling in Snort_inline</title>
      <link>https://inliniac.net/blog/2007/06/16/tcp-window-scaling-in-snort_inline/</link>
      <pubDate>Fri, 15 Jun 2007 22:04:57 +0000</pubDate>
      <guid>https://inliniac.net/blog/2007/06/16/tcp-window-scaling-in-snort_inline/</guid>
      <description>&lt;p&gt;The TCP window field in the TCP header is only 16 bits, so the maximum window size it can handle is only 64kb. A long time ago this was enough, but nowadays it isn&amp;rsquo;t, by far. Luckily, this is something the window scaling option fixes. Window scaling is very common these days. Your pc or laptop probably uses it by default. Snort&amp;rsquo;s stream4 however, does not support it. This means that when tracking and reassembling streams, Snort for most connections has no idea about what data is in window and which is out of window. To make matters worse, the packets that are in window when using wscaling, but appear out of window when the wscaling is not accounted for, are never used in the reassembly process. This makes Snort evadable.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Memory leak fixed in stream4inline</title>
      <link>https://inliniac.net/blog/2007/05/22/memory-leak-fixed-in-stream4inline/</link>
      <pubDate>Tue, 22 May 2007 21:54:17 +0000</pubDate>
      <guid>https://inliniac.net/blog/2007/05/22/memory-leak-fixed-in-stream4inline/</guid>
      <description>&lt;p&gt;A few days ago William told me that if he enabled stream4inline on a busy gateway, Snort_inline would consume all memory within hours. The problem went away when disabling stream4inline, so it made sense that the problem would be in there somewhere.&lt;/p&gt;&#xA;&lt;p&gt;The first suspect was the reassembly cache. The reassembly cache is used to keep a per stream copy of the reassembled packet in memory. While being memory expensive, it greatly speeds up the &lt;em&gt;sliding window&lt;/em&gt; stream reassembly process, especially with small packets. The reason for this being the first and primary suspect is that this is the only place where stream4inline code allocates memory. Reviewing the code however, showed no leaks and adding a debug counter to monitor the memory usage also showed that the leak was not in that code.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Snort_inline and TCP Segmentation Offloading</title>
      <link>https://inliniac.net/blog/2007/04/20/snort_inline-and-tcp-segmentation-offloading/</link>
      <pubDate>Fri, 20 Apr 2007 16:36:55 +0000</pubDate>
      <guid>https://inliniac.net/blog/2007/04/20/snort_inline-and-tcp-segmentation-offloading/</guid>
      <description>&lt;p&gt;Since a short while I have a gigabit setup at home. My laptop has a e1000 Intel NIC, my desktop a Broadcom NIC.While playing with Snort_inline and netpipe-tcp, I noticed something odd. I got tcp packets that had the &amp;lsquo;Don&amp;rsquo;t Fragment&amp;rsquo; option set, but were still bigger than the mtu size of the link. Snort_inline read packets of up to 26kb from the queue, and wireshark and tcpdump were seeing the packets as well. This was only for outgoing packets on the e1000 NIC. The receiving pc saw the packets split up in multiple packets that were honoring the mtu size. This got me thinking that some form of offloading must be taking place and indeed this was the case:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Snort_inline patch updated to 2.6.1.2</title>
      <link>https://inliniac.net/blog/2007/01/17/snort_inline-patch-updated-to-2612/</link>
      <pubDate>Wed, 17 Jan 2007 11:55:34 +0000</pubDate>
      <guid>https://inliniac.net/blog/2007/01/17/snort_inline-patch-updated-to-2612/</guid>
      <description>&lt;p&gt;With the recent Snort vulnerabilities we had to make a choice if we would backport the fixes to our Snort_inline 2.6.0.2 patch or that we would upgrade to 2.6.1.2. Upgrading makes most sense since &lt;a href=&#34;http://www.sourcefire.com/&#34;&gt;SourceFire&lt;/a&gt; improves Snort with every release, but since the upgrade process has been very painful the last couple of releases, we weren&amp;rsquo;t really looking forward to it.&lt;/p&gt;&#xA;&lt;p&gt;Earlier I wrote about my testing with &lt;a href=&#34;http://www.inliniac.net/blog/?p=60&#34;&gt;Subversion for Snort_inline&lt;/a&gt;, and I found out that using Subversion made the upgrade procedure much easier and much less time consuming. So upgrading it was. Generally there were little changes to the Snort_inline patch required.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Snort_inline 2.6 development update</title>
      <link>https://inliniac.net/blog/2006/12/23/snort_inline-26-development-update/</link>
      <pubDate>Sat, 23 Dec 2006 00:35:58 +0000</pubDate>
      <guid>https://inliniac.net/blog/2006/12/23/snort_inline-26-development-update/</guid>
      <description>&lt;p&gt;Development of Snort_inline 2.6 experienced a bit of a setback when William and I discovered that the new Stream4inline had some issues with detecting certain attacks. Since we are scanning the reassembled stream certain detection plugins didn&amp;rsquo;t work as expected. Basically every detection plugin that uses absolute offsets from the packet start is messed up when we scan the reassembled stream only.&lt;/p&gt;&#xA;&lt;p&gt;This is because the start of the reassembled stream doesn&amp;rsquo;t match with the start of the last packet added to this stream. Most TCP sigs are using offsets match against the start of the stream, or relative matches. For example a rule like:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Update on Snort_inline 2.6.0.2 development</title>
      <link>https://inliniac.net/blog/2006/11/10/update-on-snort_inline-2602-development/</link>
      <pubDate>Fri, 10 Nov 2006 11:54:11 +0000</pubDate>
      <guid>https://inliniac.net/blog/2006/11/10/update-on-snort_inline-2602-development/</guid>
      <description>&lt;p&gt;I have spend the last week trying to find a very annoying bug that caused Snort_inline to go into 100% CPU on certain traffic. It kept working, only my P3 500Mhz home gateway slowed down to between 2kb/s and 25kb/s, while normally it handles the full 325kb/s for my DSL line at around 25% CPU.&lt;/p&gt;&#xA;&lt;p&gt;Snort comes with a number of performance measurement options. In 2.6 &amp;ndash;enable-perfprofiling was introduced. Also, &amp;ndash;enable-profile builds Snort for use with gprof. Next to those you can use strace and ltrace with the -c option to see the ammount of time spend in the several functions.&lt;/p&gt;&#xA;&lt;p&gt;I already knew the problem was related to my new Stream4 code, since running Snort_inline without the &amp;lsquo;stream4inline&amp;rsquo; option made the problem go away. So my performance debugging and code reviews were focussed on that code. However, the performance statistics showed no functions that took large ammounts of time in Stream4.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Snort_inline: running Snort_inline 2.6.0.2</title>
      <link>https://inliniac.net/blog/2006/10/05/snort_inline-running-snort_inline-2602/</link>
      <pubDate>Thu, 05 Oct 2006 08:13:29 +0000</pubDate>
      <guid>https://inliniac.net/blog/2006/10/05/snort_inline-running-snort_inline-2602/</guid>
      <description>&lt;p&gt;No, it&amp;rsquo;s not released. But it wil be soon&amp;hellip; really!&lt;/p&gt;&#xA;&lt;p&gt;William has done most of the hard work of porting our Snort_inline patch from 2.4.5 to 2.6. I have mostly been working on improving the stream4inline modification. I have written about this &lt;a href=&#34;http://www.inliniac.net/blog/?p=3&#34;&gt;before&lt;/a&gt;. Like the stream4inline modification in Snort_inline 2.4.5 it scans the stream in a sliding window, making it possible to drop an attack detected in the reassembled stream. The new code does the same but is much faster, at the cost of higher memory usage.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Snort_inline: idea for an improved bait-and-switch</title>
      <link>https://inliniac.net/blog/2006/07/11/snort_inline-idea-for-an-improved-bait-and-switch/</link>
      <pubDate>Mon, 10 Jul 2006 22:13:09 +0000</pubDate>
      <guid>https://inliniac.net/blog/2006/07/11/snort_inline-idea-for-an-improved-bait-and-switch/</guid>
      <description>&lt;p&gt;William Metcalf recently wrote a bait-and-switch plugin for Snort_inline. The idea is that when a rule matches on certain traffic this plugin loads an iptables rule into the system that redirects the offending host to another server. This can present the user an error message such as &amp;ldquo;Access Denied&amp;rdquo; for example, but this server can also have al kinds of sniffing tools, or even be a honeypot.&lt;/p&gt;&#xA;&lt;p&gt;As the plugin currently creates an iptables rule it only works with linux. Also, it has some difficulty with existing iptables rulesets that might be maintained by other programs, such as my own Vuurmuur. My idea is to investigate whether or not it is possible to simply do the redirection in Snort_inline itself. By rewriting the ipaddress in the IP header, it might work as well. Naturally, this would need to be done for every packet, but with a connection to either the flow engine or the stream engine, this should be able to work&amp;hellip; just a thought&amp;hellip;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Snort_inline: Adapting the TCP stream reassembler</title>
      <link>https://inliniac.net/blog/2006/07/10/snort_inline-adapting-the-tcp-stream-reassembler/</link>
      <pubDate>Mon, 10 Jul 2006 16:34:25 +0000</pubDate>
      <guid>https://inliniac.net/blog/2006/07/10/snort_inline-adapting-the-tcp-stream-reassembler/</guid>
      <description>&lt;p&gt;Currently I am rewriting a modification of the TCP reassembler in Snort_inline. Snort&amp;rsquo;s TCP reassembler is called Stream4 and it works fairly well in IDS mode, however it has some serious issues in &lt;em&gt;inline&lt;/em&gt; mode. The biggest and most important issue is that Snort_inline cannot block an attack if it is detected in the reassembled stream. In Snort_inline 2.4 we made our first attempt to fix this with the &lt;em&gt;stream4inline&lt;/em&gt; modification.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
