[Snort-devel] Flowbits Set and Not Checked Against SRC/DST Networks

Martin Holste mcholste at ...2499...
Tue Jun 28 01:16:47 EDT 2011


I've attached a sample pcap which should not generate any alerts (but
does) with these rules:
alert tcp any any <> [4.2.2.1] any (msg:"set flowbit on 4.2.2.1";
flags:S; threshold: type limit, track by_src, seconds 60, count 1;
flowbits:set,TEST; classtype:not-suspicious; sid:1; rev:1)
alert tcp any any <> any any (msg:"alert on set flowbit";
flow:established; flowbits:isset,TEST; classtype:not-suspicious;
sid:2; rev:1)

I'm using snort 2.9.1b1 with this config:
ipvar HOME_NET [192.168.0.0/16]
ipvar EXTERNAL_NET any
ipvar DNS_SERVERS $HOME_NET
ipvar SMTP_SERVERS $HOME_NET
ipvar HTTP_SERVERS $HOME_NET
ipvar SQL_SERVERS $HOME_NET
ipvar TELNET_SERVERS $HOME_NET
ipvar SSH_SERVERS $HOME_NET
ipvar FTP_SERVERS $HOME_NET
portvar HTTP_PORTS
[79,80,81,82,311,591,593,901,1220,1414,1830,2301,2381,2809,3128,3702,5250,7001,7777,7779,8000,8008,8028,8080,8088,8118,8123,8180,8181,8243,8280,8888,9090,9091,9443,9999,11371]
portvar SHELLCODE_PORTS !80
portvar ORACLE_PORTS 1024:
portvar SSH_PORTS 22
portvar FTP_PORTS [21,2100,3535]
ipvar AIM_SERVERS
[64.12.24.0/23,64.12.28.0/23,64.12.161.0/24,64.12.163.0/24,64.12.200.0/24,205.188.3.0/24,205.188.5.0/24,205.188.7.0/24,205.188.9.0/24,205.188.153.0/24,205.188.179.0/24,205.188.248.0/24]
ipvar DNP3_SERVER $HOME_NET
ipvar DNP3_CLIENT $HOME_NET
portvar DNP3_PORTS 20000
ipvar MODBUS_CLIENT $HOME_NET
ipvar MODBUS_SERVER $HOME_NET
ipvar ENIP_CLIENT $HOME_NET
ipvar ENIP_SERVER $HOME_NET
config disable_decode_alerts
config disable_tcpopt_experimental_alerts
config disable_tcpopt_obsolete_alerts
config disable_tcpopt_ttcp_alerts
config disable_tcpopt_alerts
config disable_ipopt_alerts
config checksum_mode: none
config logdir: /tmp
config pcre_match_limit: 3500
config pcre_match_limit_recursion: 1500
config detection: search-method ac search-optimize max-pattern-len 20
config event_queue: max_queue 8 log 3 order_events content_length
dynamicpreprocessor directory /usr/local/snort/lib/snort_dynamicpreprocessor/
dynamicengine /usr/local/snort/lib/snort_dynamicengine/libsf_engine.so
preprocessor normalize_ip4
preprocessor normalize_tcp: ips ecn stream
preprocessor normalize_icmp4
preprocessor normalize_ip6
preprocessor normalize_icmp6
preprocessor frag3_global: max_frags 65536
preprocessor frag3_engine: policy windows detect_anomalies
overlap_limit 10 min_fragment_length 100 timeout 180
preprocessor stream5_global: track_tcp yes, \
   track_udp yes, \
   track_icmp no, \
   max_tcp 262144, \
   max_udp 131072, \
   max_active_responses 2, \
   min_response_seconds 5
preprocessor stream5_tcp: policy windows, detect_anomalies, require_3whs 180, \
   overlap_limit 10, small_segments 3 bytes 150, timeout 180, \
    ports client 21 22 23 25 42 53 79 109 110 111 113 119 135 136 137 139 143 \
        161 445 513 514 587 593 691 1433 1521 2100 3306 6070 6665 6666
6667 6668 6669 \
        7000 8181 32770 32771 32772 32773 32774 32775 32776 32777 32778 32779, \
    ports both 80 311 443 465 563 591 593 636 901 989 992 993 994 995
1220 1414 1830 2301 2381 2809 3128 3702 5250 7907 7001 7802 7777 7779
\
        7801 7900 7901 7902 7903 7904 7905 7906 7908 7909 7910 7911
7912 7913 7914 7915 7916 \
        7917 7918 7919 7920 8000 8008 8028 8080 8088 8118 8123 8180
8243 8280 8888 9090 9091 9443 9999 11371
preprocessor stream5_udp: timeout 180
preprocessor http_inspect: global iis_unicode_map unicode.map 1252
compress_depth 65535 decompress_depth 65535
preprocessor http_inspect_server: server default \
    chunk_length 500000 \
    server_flow_depth -1 \
    client_flow_depth 0 \
    post_depth 65495 \
    oversize_dir_length 500 \
    max_header_length 750 \
    max_headers 100 \
    ports { 80 311 591 593 901 1220 1414 1830 2301 2381 2809 3128 3702
5250 7001 7777 7779 8000 8008 8028 8080 8088 8118 8123 8180 8181 8243
8280 8888 9090 9091 9443 9999 11371 } \
    non_rfc_char { 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 } \
    enable_cookie \
    extended_response_inspection \
    inspect_gzip \
    normalize_utf \
    unlimited_decompress \
    apache_whitespace no \
    ascii no \
    bare_byte no \
    directory no \
    double_decode no \
    iis_backslash no \
    iis_delimiter no \
    iis_unicode no \
    multi_slash no \
   utf_8 no \
    u_encode yes \
    webroot no
preprocessor ssl: ports { 443 465 563 636 989 992 993 994 995 7801
7802 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912
7913 7914 7915 7916 7917 7918 7919 7920 }, trustservers,
noinspect_encrypted
preprocessor sensitive_data: alert_threshold 1
preprocessor sip: max_sessions 10000, \
   ports { 5060 5061 }, \
   methods { invite \
             cancel \
             ack \
             bye \
             register \
             options \
             refer \
             subscribe \
             update \
             join \
             info \
             message \
             notify \
             prack }, \
   max_uri_len 512, \
   max_call_id_len 80, \
   max_requestName_len 20, \
   max_from_len 256, \
   max_to_len 256, \
   max_via_len 1024, \
   max_contact_len 512, \
   max_content_len 1024
include classification.config
include reference.config
include /etc/snort/debug.rules
include threshold.conf


You can mess with the rules any way you want, but the only way to get
it so that a flowbit is not attached is to add a content match.  I've
tried making it non-bidrectional, messing with the flow settings, etc.
 I've gone through the debugging for awhile now, but I still am not
sure which function is continuing when it should be bugging out.

On Mon, Jun 27, 2011 at 10:17 AM, Russ Combs <rcombs at ...402...> wrote:
> Thanks Eoin - I've opened a bug on this.
>
> On Mon, Jun 27, 2011 at 11:10 AM, Joel Esler <jesler at ...402...> wrote:
>>
>> It's relevant for regression testing.
>>
>> 1. We can reproduce it with your pcap
>> 2. Developers fix bug.
>> 3. We can't reproduce it anymore.
>> 4. test
>> 5. test
>> 6. create more pcaps
>> 7. test.
>>
>>
>>
>> On Jun 27, 2011, at 11:01 AM, Martin Holste wrote:
>>
>> > I understand you guys have standard bug-filing protocols, but a pcap
>> > isn't really relevant here.  If you have a rule that solely checks for
>> > a SYN flag and you set a flowbit for it, that flowbit will be
>> > erroneously attached to ALL flow sessions everywhere, regardless of
>> > source or dest.  So, if you set a bit on one packet using a SYN flag,
>> > you set that bit on ALL packets that flow through Snort.
>> >
>> > On Mon, Jun 27, 2011 at 8:57 AM, Joel Esler <jesler at ...402...>
>> > wrote:
>> >> Eoin,
>> >>
>> >> I've been asked to get a hold of you from the developers, they are
>> >> heads down in coding this week and we need to confirm or deny the remaining
>> >> bugs that we know about.
>> >>
>> >> Do you have pcaps for this?  I know I could make my own, and may have
>> >> to, but with the bugs I have in my cue as well, it may take me awhile to get
>> >> to it.
>> >>
>> >> Can you provide them to me?
>> >>
>> >> Joel
>> >>
>> >> On Jun 24, 2011, at 4:10 PM, Eoin Miller wrote:
>> >>
>> >>> We were having some issues when setting flowbits for sessions based
>> >>> upon IP lists. I think I have narrowed down the problem after creating and
>> >>> running these rules:
>> >>>
>> >>> alert tcp $HOME_NET any <>
>> >>> [127.0.0.1,127.0.0.2,127.0.0.3,127.1.0.0/24,127.2.0.0/24,127.127.0.0/16] any
>> >>> (msg:"TEST talking to localhost"; flags:S; flowbits:set,AOL.test;
>> >>> classtype:bad-unknown; sid:7000004; rev:1;)
>> >>> alert tcp $HOME_NET any -> $EXTERNAL_NET $HTTP_PORTS (msg:"TEST
>> >>> http_uri to localhost"; flowbits:isset,AOL.test; content:"/"; http_uri;
>> >>> classtype:bad-unknown; sid:7000005; rev:1;)
>> >>>
>> >>> The first rule never creates alerting output. But the second rule will
>> >>> fire on every HTTP request from our client net while these are both running.
>> >>> What I think is occurring is that the packet causes an alert and a flowbit
>> >>> to be set for the stream because it sees the initial SYN packet (which is
>> >>> true). But the alert output is never created because it is actually checked
>> >>> against the SRC/DST networks in the rule and therefor it gets suppressed.
>> >>> But, the flowbit must not be getting compared against the SRC/DST network
>> >>> ranges and ports and unset if it doesn't match. Can I bug you guys to take a
>> >>> look into this?
>> >>>
>> >>>
>> >>> # snort --version
>> >>>   ,,_     -*> Snort! <*-
>> >>>  o"  )~   Version 2.9.0.5 IPv6 GRE (Build 135)
>> >>>   ''''    By Martin Roesch & The Snort Team:
>> >>> http://www.snort.org/snort/snort-team
>> >>>           Copyright (C) 1998-2011 Sourcefire, Inc., et al.
>> >>>           Using libpcap version 1.1.1
>> >>>           Using PCRE version: 8.02 2010-03-19
>> >>>           Using ZLIB version: 1.2.3
>> >>>
>> >>> I haven't really gone through the code to much to see if this is the
>> >>> issue, but I think the reasoning is sound based upon output review/testing.
>> >>>
>> >>> -- Eoin
>> >>>
>> >>>
>> >>>
>> >>> ------------------------------------------------------------------------------
>> >>> All the data continuously generated in your IT infrastructure contains
>> >>> a
>> >>> definitive record of customers, application performance, security
>> >>> threats, fraudulent activity and more. Splunk takes this data and
>> >>> makes
>> >>> sense of it. Business sense. IT sense. Common sense..
>> >>> http://p.sf.net/sfu/splunk-d2d-c1
>> >>> _______________________________________________
>> >>> Snort-devel mailing list
>> >>> Snort-devel at lists.sourceforge.net
>> >>> https://lists.sourceforge.net/lists/listinfo/snort-devel
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >> All of the data generated in your IT infrastructure is seriously
>> >> valuable.
>> >> Why? It contains a definitive record of application performance,
>> >> security
>> >> threats, fraudulent activity, and more. Splunk takes this data and
>> >> makes
>> >> sense of it. IT sense. And common sense.
>> >> http://p.sf.net/sfu/splunk-d2d-c2
>> >> _______________________________________________
>> >> Snort-devel mailing list
>> >> Snort-devel at lists.sourceforge.net
>> >> https://lists.sourceforge.net/lists/listinfo/snort-devel
>> >>
>>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.pcap
Type: application/cap
Size: 12602 bytes
Desc: not available
URL: <https://lists.snort.org/pipermail/snort-devel/attachments/20110628/8fcc3d85/attachment.bin>


More information about the Snort-devel mailing list