[Snort-devel] XFF/ExtraData not always logged for drop rules

Carter Waxman (cwaxman) cwaxman at ...3461...
Mon Jul 6 16:40:26 EDT 2015

Hi Mike,

Sorry for the lack of communication. The first scenario is to be expected per the involvement of stream, as wire packet processing excludes several functions. We are currently addressing the second point, as that was not the intended behavior.


From: Mike Cox <mike.cox52 at ...2499...<mailto:mike.cox52 at ...2499...>>
Date: Monday, July 6, 2015 at 4:31 PM
To: Carter Waxman <cwaxman at ...3461...<mailto:cwaxman at ...3461...>>
Cc: "snort-devel at lists.sourceforge.net<mailto:snort-devel at ...362....net>" <snort-devel at lists.sourceforge.net<mailto:snort-devel at ...2763...rge.net>>
Subject: Re: [Snort-devel] XFF/ExtraData not always logged for drop rules

Any update/confirmation on this?

I hate to think that the Snort community has become a one way street now that Cisco is calling the shots....  :(

-Mike Cox

On Fri, Jun 26, 2015 at 2:25 PM, Mike Cox <mike.cox52 at ...2499...<mailto:mike.cox52 at ...2499...>> wrote:
Put simply, the network traffic that generates an event has to be flushed and ACKd for the ExtraData (e.g. XFF data) to be logged.  This means that for 'drop' rules, if the packet is inspected individually (no flushing or ACK) or if a stream is flushed before being fully ACKd (i.e. when 'normalize_tcp: ips' is enabled so the sensor is in pre-ACK mode), the ExtraData is not logged.

I'm convinced that the above is true and I'm suprised no one has brought it up before now.

-Mike Cox

On Thu, Jun 25, 2015 at 4:25 PM, Mike Cox <mike.cox52 at ...2499...<mailto:mike.cox52 at ...2499...>> wrote:
Thanks Carter.  Is my analysis correct on how XFF logging works and the lack of logging in the described scenarios?


-Mike Cox

On Thu, Jun 25, 2015 at 2:08 PM, Carter Waxman (cwaxman) <cwaxman at ...3482....<mailto:cwaxman at ...3461...>> wrote:
Hi Mike,

Thanks for the detailed analysis. We will be tracking this internally.


From: Mike Cox <mike.cox52 at ...2499...<mailto:mike.cox52 at ...2499...>>
Date: Thursday, June 25, 2015 at 2:00 PM
To: "snort-devel at lists.sourceforge.net<mailto:snort-devel at ...362....net>" <snort-devel at lists.sourceforge.net<mailto:snort-devel at ...2763...rge.net>>
Subject: Re: [Snort-devel] XFF/ExtraData not always logged for drop rules

I did some quick tests with Snort<> and saw the same behavior described above.

Any insights, agreements, or disagreements?

Testing scenario 1 is easy enough.  For scenario 2, I've attached a pcap with a simple HTTP request (with XFF header) and response that both require reasembly.

These rules can be used to test (only enable one at a time):

drop tcp any any -> any $HTTP_PORTS (msg:"Client request with XFF - reassembly required"; flow:established,to_server; content:"GET"; http_method; content:"requestmatch"; sid:36332;)

drop tcp any $HTTP_PORTS -> any any (msg:"Server response XFF test - reassembly required"; flow:established,to_client; content:"Server"; http_header; file_data; content:"ninja"; sid:26221;)

If 'normalize: tcp' is enabled (flush policy is *-IPS/pre-ACK), the the rules will trigger but the ExtraData with the XFF info is not logged.  If you change the rules to 'alert' or if you disable normalize so the sensor is in post-ACK mode, the ExtraData/XFF info is logged.  You'll want to run in inline mode (the dump DAQ is great for testing!) and of course you need to be configured to output unified2.


-Mike Cox

On Wed, Jun 24, 2015 at 9:49 AM, Mike Cox <mike.cox52 at ...2499...<mailto:mike.cox52 at ...2499...>> wrote:

VRT and Snort Devs,

The X-Forwared-For ("XFF") and/or True-Client-IP data is stored in what is called "ExtraData" and written to the unified2 file.  ExtraData is often not written to the unified2 file at the same time as other alert data and can depend on stream flushing as well as alert flushing.

Looking at Stream5, there are a number of cases where the XFF ExtraData is not logged on 'drop' rules even though it is available in the data stream.  From what I can tell, the ExtraData gets written by purge_alerts() which gets called by purge_to_seq() which gets called by purge_flushed_ackd() (sometimes these functions get called when dealing with TIME_WAIT timer stuff but let's ignore those cases for now).  However, purge_flushed_ackd() only purges flushed and acked bytes (as I understand it, bytes that are flushed and ackd).

So in these situations, when 'drop' rules trigger, the ExtraData is not written:

1) A single packet triggers the drop rule and it is inspected as a packet and not part of a (reassembled) stream.
  - The Stream5 preprocessor doesn't get involved enough to do the appropriate flushing/purging required to write the ExtraData.

2) A reassembled stream "packet" triggers the drop rule and the normalize_tcp preprocessor is enabled (i.e. 'normalize_tcp: ips' which is going to be the Protocol-IPS or Footprint-IPS flush policy depending on PAF).
  - Snort is in pre-ACK mode and so it doesn't wait on the ACK to flush the data to detection.  Since the flushing happens before the ACK is received (and the ACK isn't processed anyway since the stream is blocked by the block rule), the ExtraData never gets written.

I can understand and somewhat accept why the ExtraData isn't written for scenario 1 although this happens when the HTTP Inspect preprocessor is already engaged so it seems feasible to log the ExtraData/XFF.  Can this be done?

For scenario 2, can I make a feature request that the ExtraData gets logged appropriately in this case?  I'm guessing that people who run Snort inline also have normalize and PAF enabled and it makes sense to me that 'drop' rules would still write ExtraData, especially since Stream5 is fully involved.

Once drop rules fire, the stream gets blocked (assuming the DAQ supports this) so it makes sense to go ahead and compile/write out the ExtraData since nothing else on that stream is going to get fully processed.

I haven't looked much at Stream6 although it looks like most of the code from Stream5 so I'm not sure why the version number change.


-Mike Cox

P.S. setting 'flush_on_alert' for Stream5 doesn't seem to have any affect on these scenarios.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.snort.org/pipermail/snort-devel/attachments/20150706/7001372c/attachment.html>

More information about the Snort-devel mailing list