Commit Graph

7741 Commits (14bf32c031febef495f7caa7ea1d1079bf20880a)
 

Author SHA1 Message Date
Victor Julien 14bf32c031 detect/depth: reject rules with depth smaller than content 7 years ago
Victor Julien 12c880a778 http: allow shinking in HTPRealloc 7 years ago
Wolfgang Hotwagner 6aafca25ff conf: fix NULL-pointer dereference in CoredumpLoadConfig
An empty value for coredump.max-dump in the config-file leads to a segfault because of a NULL-pointer dereference in CoredumpLoadConfig().

Here is a configuration example:

coredump.max-dump: []

This lets suricata crash with a segfault:

ASAN-output:
==9412==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f22e851aa28 bp 0x7ffd90006fc0 sp 0x7ffd90006740 T0)
    0 0x7f22e851aa27 in strcasecmp (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x51a27)
    1 0x5608a7ec0108 in CoredumpLoadConfig /root/suricata-1/src/util-coredump-config.c:52
    2 0x5608a7e8bb22 in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2752
    3 0x5608a7e8c577 in main /root/suricata-1/src/suricata.c:2892
    4 0x7f22e4c622b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
    5 0x5608a7a30c59 in _start (/usr/local/bin/suricata+0xc4c59)

Bug #2276
7 years ago
Wolfgang Hotwagner 9d77ad50cb conf: fix NULL-pointer dereference in ConfGetInt
If there are empty values in the config-file where integer values are expected, strtoimax in the ConfGetInt-function will segfault because of NULL-pointer dereference.

Here is a configuration example:

pcre.match-limit: []

This will let suricata crash with a segfault.
ASAN-output:

ASAN:DEADLYSIGNAL =================================================================
16951ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fa690e3ccc5 bp 0x000000000000 sp 0x7ffd0d770ad0 T0)
0 0x7fa690e3ccc4 (/lib/x86_64-linux-gnu/libc.so.6+0x36cc4)
1 0x7fa6946a6534 in strtoimax (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x44534)
2 0x55e0aeba6499 in ConfGetInt /root/suricata-1/src/conf.c:390
3 0x55e0aed2545d in DetectPcreRegister /root/suricata-1/src/detect-pcre.c:99
4 0x55e0aec1b4ce in SigTableSetup /root/suricata-1/src/detect.c:3783
5 0x55e0aeeed58d in PostConfLoadedSetup /root/suricata-1/src/suricata.c:2690
6 0x55e0aeeee4f2 in main /root/suricata-1/src/suricata.c:2892
7 0x7fa690e262b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
8 0x55e0aea92d39 in _start (/usr/local/bin/suricata+0xc7d39)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x36cc4)

This commit fixes Ticket #2275
7 years ago
Wolfgang Hotwagner 393db61706 conf: fix NULL-pointer dereference in ParseSizeString
If someone accidently writes invalid characters in some parts of the suricata.yaml-configfile, the size-parameter of the ParseSizeString-function becomes NULL and gets dereferenced. Suricata crashes with SEGV. This commit fixes Ticket #2274

The following config value leads to a Segfault:
app-layer.protocols.smtp.inspected-tracker.content-inspect-window: *4096
7 years ago
Peter Manev 723e23dd67 valgrind: suppressions for NIC offloading calls 7 years ago
Victor Julien b6617ede04 detect: handle very large byte_extract'ed values in isdataat 7 years ago
Victor Julien 148d6e9fb7 detect: implement byte_extract support for isdataat 7 years ago
Victor Julien f8a4848e98 detect: add debug statements for byte_extract/isdataat 7 years ago
Victor Julien 055c054b8e changelog: update for 3.2.4 7 years ago
Victor Julien 2b3d960401 runmodes: fix 'threads' option parsing
Don't cast int to uint8_t for no reason. Add warning that upper
limit for theads is 1024.

Small code cleanups.

Bug: #2243
7 years ago
Victor Julien aab2548df5 output: harden output deinit
If thread setup fails allow output deinit code to be called with
NULL data without crashing.
7 years ago
Victor Julien 9fdecfffc1 stream: improve error handling of ssn pool
With large number of threads the default memcap leads to pool setup
failures. Make sure these are reported properly so that the user
knows what is going on.

Bug: #2242
7 years ago
qiangbei b9e76ed1b6 detect/state: fix offset mask logic
changed 0xef to 0x7f
7 years ago
Victor Julien f6cd2069fc dcerpc: set hard limit for stub data buffer size
Avoid traffic being able to endlessly grow the stub buffer by
setting a 1MB hard limit.

Bug #2241
7 years ago
Victor Julien 1a39ab99f3 detect: don't rescan when just distance is used
Content inspection optimization: when just distance is used without
within we don't need to search recursively.

E.g. content:"a"; content:"b"; distance:1; will scan the buffer for
'a' and when it finds 'a' it will scan the remainder for 'b'. Until
now, the failure to find 'b' would lead to looking for the next 'a'
and then for 'b' after that. However, we already inspected the
entire buffer for 'b', so we know this will fail.
7 years ago
Victor Julien 7419bb2bac detect: avoid needless recursive scanning
Don't recursively inspect a detect list if the recursion
doesn't increase chance of success.
7 years ago
Victor Julien 6133bbd195 doc/file_data: add note on negated matching
Explain issue #2216 and how to avoid it.

Backport http_server_body notes from 4.0 branch.
8 years ago
Victor Julien b12a5fe5b0 debug: free pcre memory used for output filtering 8 years ago
Victor Julien 04e7d04633 tls: don't set event on small input data
On very small data the max loop count could be 0. Make sure
it's always at least 1.
8 years ago
Eric Leblond 36a1916894 prscript: update urls to use OISF repo 8 years ago
Derek 243fd7dc74 dns: fix last timestamp handling
Fixes incorrect variable in ticket #2207

In app-layer-dns-tcp.c in the DNSTCPResponseParse function
a variable is set to last_req when it should be last_resp.
This makes it consistent with UDP DNS response parsing.
8 years ago
Eric Leblond 030e1b5432 af-packet: free bpf program
This fixes a small memory leak when Suricata is running with a
BPF filter.
8 years ago
Eric Leblond 197d14b352 af-packet: call thread deinit function 8 years ago
Andreas Herz 9f01c51561 doc: reflect most recent cpu affinity settings
Some settings like output-cpu-set never been used and detect got renamed
to worker. This reflects those changes already present in the yaml also
within the documentation.
8 years ago
Mats Klepsland a10819a405 app-layer-ssl: fix bug with >255 records in one stream 8 years ago
Andreas Herz 74b365c349 rule-parser: bump sids within siggroup test 8 years ago
Andreas Herz 4d2a6f5406 rule-parser: detect duplicate rev keyword 8 years ago
Andreas Herz 7d037ae266 rule-parser: detect duplicate sid keyword 8 years ago
Andreas Herz 1e97b03fe0 rule-parser: detect duplicate classtype keyword 8 years ago
Victor Julien 543ac95d2b afpacket: free ring mem on error 8 years ago
Alexander Gozman 705ebc9d9a Bug #2201: af_packet - treat BPF filter error as fatal
There is no need to try to set erroneous BPF filter again and again. Such attempts
lead to constant mmap() calls without corresponding munmap() when 'use-mmap' is enabled.
8 years ago
Mats Klepsland 49e61c7c1e app-layer-tls: don't decode client certificates
Decoding client certificate overwrites the validity dates from the
server certificate, so we therefore don't decode it, since we don't
do anything with it (right now) anyway.

Fixes Bug #2050
8 years ago
Victor Julien 2b19824c4b detect-msg: cleanup error message 8 years ago
Andreas Herz f36c7a93d4 rule-parser: ignore duplicated msg keyword 8 years ago
Eric Leblond 49514082b4 af-packet: optimize BPF
This patch turn on code optimization on BPF filter building by
libpcap. This allow to reduce the size of the BPF bytecode and
thus increase the size of BPF filter supported by Suricata.

Reported-by: Martijn van Oosterhout
8 years ago
Victor Julien 020d9abb0e gcc7: format-truncation fix for lua 8 years ago
Julian 0179514576 redis: support for rpush in list mode
This adds a new redis mode rpush. Also more consistent config keywords orientated at the redis command: lpush and publish.
Keeping list and channel config keywords for backwards compatibility. Removed unnecessary checks.
8 years ago
Victor Julien aa9264987f changelog: update for 3.2.3 release 8 years ago
Victor Julien 53d8e29831 der/asn1: limit recursion
Limit the number of recursive calls in the DER/ASN.1 decoder to avoid
stack overflows.

Found using AFL.
8 years ago
Victor Julien 257db74f89 stream: don't reset state on syn/ack resend
Bug #1958.

The reset was originally created for issue #523, but that works
well without the reset as well.
8 years ago
Victor Julien c907709352 radix: fix risky malloc call
GCC7 said:
  CC       util-radix-tree.o
In file included from util-debug-filters.h:29:0,
                 from util-debug.h:34,
                 from suricata-common.h:421,
                 from util-radix-tree.c:26:
util-radix-tree.c: In function ‘SCRadixAddKey’:
util-mem.h:177:12: error: argument 1 range [18446744071562067968, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
     ptrmem = malloc((a)); \
     ~~~~~~~^~~~~~~~~~~~~
util-radix-tree.c:749:42: note: in expansion of macro ‘SCMalloc’
             if ( (inter_node->netmasks = SCMalloc((node->netmask_cnt - i) *
                                          ^~~~~~~~
In file included from suricata-common.h:69:0,
                 from util-radix-tree.c:26:
/usr/include/stdlib.h:443:14: note: in a call to allocation function ‘malloc’ declared here
 extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
              ^~~~~~

scan-build said:
util-radix-tree.c:749:42: warning: Call to 'malloc' has an allocation size of 0 bytes
            if ( (inter_node->netmasks = SCMalloc((node->netmask_cnt - i) *
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-mem.h:177:14: note: expanded from macro 'SCMalloc'
    ptrmem = malloc((a)); \
             ^~~~~~~~~~~
1 warning generated.
8 years ago
Victor Julien f77412dce5 gcc7: fix format-truncation warnings in runmodes
Example:

util-runmodes.c: In function ‘RunModeSetIPSAutoFp’:
util-runmodes.c:496:40: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
         snprintf(qname, sizeof(qname), "pickup%d", thread+1);
                                        ^~~~~~~~~~
util-runmodes.c:496:9: note: ‘snprintf’ output between 8 and 17 bytes into a destination of size16
         snprintf(qname, sizeof(qname), "pickup%d", thread+1);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Solved by reducing 'thread' to a uint16_t and limiting the max
thread count to 1024.
8 years ago
Victor Julien a73e84ea50 gcc7: fix format truncation warning
detect-rpc.c: In function ‘DetectRpcParse’:
detect-rpc.c:225:50: error: ‘%s’ directive argument is null [-Werror=format-truncation=]
                 SCLogError(SC_ERR_INVALID_VALUE, "invalid rpc option %s",args[i]);
                                                  ^
util-debug.h:239:77: note: in definition of macro ‘SCLogErr’
             int _sc_log_ret = snprintf(_sc_log_msg, SC_LOG_MAX_LOG_MSG_LEN, __VA_ARGS__);   \
                                                                             ^~~~~~~~~~~
detect-rpc.c:225:17: note: in expansion of macro ‘SCLogError’
                 SCLogError(SC_ERR_INVALID_VALUE, "invalid rpc option %s",args[i]);
                 ^~~~~~~~~~
8 years ago
Victor Julien 82e1af58cc gcc7: fixes for format string warnings
GCC 7.1.1 on Fedora gave several warnings with -Wimplicit-fallthrough
and -Wformat-truncation

This patch addresses the warnings.
8 years ago
Victor Julien 9d3a99bf0b pcap: fix linktype raw issues
On OpenBSD 6.0 and 6.1 the following pcap gets a datalink type of
101 instead of our defined DLT_RAW.

    File type:           Wireshark/tcpdump/... - pcap
    File encapsulation:  Raw IP
    File timestamp precision:  microseconds (6)
    Packet size limit:   file hdr: 262144 bytes
    Number of packets:   23
    File size:           11 kB
    Data size:           11 kB
    Capture duration:    7,424945 seconds
    First packet time:   2017-05-25 21:59:31,957953
    Last packet time:    2017-05-25 21:59:39,382898
    Data byte rate:      1536 bytes/s
    Data bit rate:       12 kbps
    Average packet size: 496,00 bytes
    Average packet rate: 3 packets/s
    SHA1:                120cff9878b93ac74b68fb9216027bef3b3c018f
    RIPEMD160:           35fa287bf30d8be8b8654abfe26e8d3883262e8e
    MD5:                 13fe4bc50fe09bdd38f07739bd1ff0f0
    Strict time order:   True
    Number of interfaces in file: 1
    Interface #0 info:
                         Encapsulation = Raw IP (7/101 - rawip)
                         Capture length = 262144
                         Time precision = microseconds (6)
                         Time ticks per second = 1000000
                         Number of stat entries = 0
                         Number of packets = 23

On Linux it is 12.

On the tcpdump/libpcap site the DLT_RAW is defined as 101:
http://www.tcpdump.org/linktypes.html

Strangely, on OpenBSD the DLT_RAW macro is defined as 14 as expected.
So for some reason, libpcap on OpenBSD uses 101 which seems to match
the tcpdump/libpcap documentation.

So this patch adds support for datalink 101 as RAW.
8 years ago
Victor Julien 24fe3c99f1 log: destroy file mutex 8 years ago
Jason Ish 076188308d log: wrap rotation and write in lock
The application log is subject to rotation, so the check for
rotation, the actual rotation and write needs to be done under
lock to ensure the file pointer is in a consisten state
at the time of write().

Fixes issue:
https://redmine.openinfosecfoundation.org/issues/2155
8 years ago
Victor Julien 913071f672 changelog: update for 3.2.2 release 8 years ago
Victor Julien 2c25180d8e pcre: on ppc64 disable only for specific versions
Disable jit only for libpcre 8.39 and 8.40 as those were the buggy
versions.

Thanks to Zoltán Herczeg.
8 years ago