Commit Graph

19154 Commits (ae58cc6491fcace0d1c9476248f728300854e171)
 

Author SHA1 Message Date
Giuseppe Longo ae58cc6491 rules: add sip-events.rules
Ticket #8524
1 month ago
Giuseppe Longo 695b4f4a3d sip: remove incomplete data event
It's no longer useful to set an event when the data is incomplete,
since an error is returned.

Ticket #8524
1 month ago
Giuseppe Longo ba5e850264 sip: make pattern matching more robust
SIP and SSDP share method names like NOTIFY and SUBSCRIBE,
causing SSDP traffic to be misidentified as SIP.
Add a probing parser callback that checks for "SIP/" in the
payload before accepting a pattern match.

Example of a misidentified flow before the fix:
{"timestamp":"2014-02-27T19:44:43.164211+0100","flow_id":986757542077835,"event_type":"flow","src_ip":"192.168.1.1","src_port":9489,"dest_ip":"239.255.255.250
","dest_port":1900,"ip_v":4,"proto":"UDP","app_proto":"sip","flow":{"..."}}

After the fix:
{"timestamp":"2014-02-27T19:44:43.164211+0100","flow_id":986757542077835,"event_type":"flow","src_ip":"192.168.1.1","src_port":9489,"dest_ip":"239.255.255.250
","dest_port":1900,"ip_v":4,"proto":"UDP","app_proto":"failed","flow":{"..."}}

Ticket #8355
1 month ago
Philippe Antoine 762b725e1f ci: check-doc-rules copies data(sets) files into tmpdir
Allows to use datasets load
1 month ago
Victor Julien d154484cc6 detect/firewall: support hook LTE mode for built-in hooks
LTE support depended on registered hook names, but did not support the
built-in names. This commit adds the support.

Ticket: #8645.
1 month ago
Victor Julien b02fa53134 detect: add helper for getting hook name
To fetch hook name from app-layer, or use built-ins.
1 month ago
Victor Julien 2a2cb40336 detect: misc debug log additions 1 month ago
Victor Julien 569d27e153 detect: propagate inspect engine setup failures 1 month ago
Victor Julien d64954a873 detect: don't register unrelated inspect engines
For rules that specify an explicit app-layer hook,
e.g. http1:request_headers, don't register inspect engines for
other protocols like HTTP/2. These have their own progress tracking,
so should be excluded from these rules.
1 month ago
Urval 3b9dc5ad37 output-json: avoid freeing caller-owned JSON builder
EveEmailLogJsonData() freed the provided SCJsonBuilder when
SMTP state was unavailable, even though ownership remains with
the caller. The caller may continue using the builder for
cleanup after the function returns failure.

Return failure without freeing the builder and add defensive
NULL checks in EveSmtpDataLogger().

Signed-off-by: Urval Kheni <urvalkheni777@gmail.com>
1 month ago
Shivani Bhardwaj 0345b91ddd rust: exclude DETECT_BYTEMATH_ENDIAN_DEFAULT from bindings
to deal with the failure due to cbindgen updates and mismatches in
generated bindings.

detect-bytemath.c:61: error: "DETECT_BYTEMATH_ENDIAN_DEFAULT" redefined [-Werror]
   61 | #define DETECT_BYTEMATH_ENDIAN_DEFAULT (uint8_t) BigEndian
      |
In file included from rust.h:34,
                 from detect-bytemath.c:32:
./../rust/gen/rust-bindings.h:5071: note: this is the location of the previous definition
 5071 | #define DETECT_BYTEMATH_ENDIAN_DEFAULT BigEndian
      |
1 month ago
Denis Balashov 3b5bdc4261 examples: check rate filter callback registration result
Check DetectEngineEnabled() before registering, and warn if the
registration call returns false.
1 month ago
Denis Balashov 17151571b8 detect: guard rate filter callback registration, return bool on failure
SCDetectEngineRegisterRateFilterCallback() dereferences the result of
DetectEngineGetCurrent() unconditionally. Add a NULL guard with
SCLogError and return false so callers can detect registration failure.

Flagged by Svace and confirmed by gcc -fanalyzer.

Ticket: 8560
1 month ago
Denis Balashov 4d4c6227e1 detect/parse: assert HashListTableLookup results in duplicate sig check
Add DEBUG_VALIDATE_BUG_ON() at four sites in DetectEngineSignatureIsDuplicate()
where HashListTableLookup() is assumed to return non-NULL. Documents the
invariant that every Signature in sig_list has a dup_sig_hash_table entry
and catches violations in debug builds.

Flagged by Svace static analyzer.

Ticket: 8635
1 month ago
Denis Balashov 3828de20ed decode: propagate PacketAlertCreate failure instead of crashing
PacketAlertCreate is called from PacketInit on the packet allocation
path. Make PacketInit return bool and propagate the NULL result from
PacketAlertCreate up through PacketGetFromAlloc, which already returns
NULL to signal allocation failure to its callers.

Update the UNITTESTS-only helpers in defrag.c accordingly: helpers
returning Packet * use an explicit NULL check; the one returning int
keeps the existing FAIL_IF style.
1 month ago
Denis Balashov 344e89e3c6 qa/cocci: fix broken regex alternation in malloc-error-check
Coccinelle uses OCaml Str, not PCRE. The '|' and '()' characters are
literals in OCaml Str, so 'identifier func =~ "(SCMalloc|SCCalloc|...)"'
never matched anything — making the entire script a no-op since its
introduction.

Replace all five patterns with OCaml Str alternation syntax 'A\|B'.

Ticket: 8641
1 month ago
Denis Balashov 7124fdebf1 tests/fuzz: guard SCCalloc result in fuzz_decodebase64
If SCCalloc fails, decoded is NULL and the subsequent SCBase64Decode
call would dereference it. Return early on allocation failure.
1 month ago
Denis Balashov 2c16fb716b util/mpm-hs: fix null check parentheses; simplify SCHSConfigInit
Two fixes:
- Remove extra parentheses in existing NULL check: (*ext) -> *ext,
  which was causing the cocci script to miss the check as a false negative.
- Simplify SCHSConfigInit to return SCCalloc() directly; the caller
  in detect-engine.c already checks the return value for NULL.
1 month ago
Denis Balashov 04a1de1192 detect/reference: guard SCStrdup calls in DetectReferenceParse
Two SCStrdup calls that set ref->key had no NULL check. On allocation
failure the pointer would be used immediately, causing a NULL dereference.
1 month ago
Denis Balashov 01f64ea335 detect/flowbits: check SCRealloc result before overwriting pointer
The original pointer was overwritten with the SCRealloc result before
checking for NULL, causing a memory leak if reallocation fails.
Check the temporary pointer first before assigning.
1 month ago
Denis Balashov 21bcbe14c1 detect/alert: guard SCStrdup result before use
SCStrdup result was stored and immediately used without checking for
NULL, which would cause a NULL dereference if allocation fails.
1 month ago
Denis Balashov b2cd08bb91 util/log-redis: guard SCCalloc result for redis stream format
When Redis output is configured in stream/xadd mode with a positive
stream-maxlen, SCConfLogOpenRedis() allocates redis_setup.stream_format
and immediately passes it to snprintf().

If SCCalloc() fails, snprintf() receives a NULL destination pointer and
the process can crash during Redis output initialization. Handle this
unrecoverable setup failure with FatalError(), matching the surrounding
Redis initialization error handling.

Ticket: 8588
1 month ago
dependabot[bot] 39688a6252 github-actions: bump codecov/codecov-action from 6.0.1 to 7.0.0
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 6.0.1 to 7.0.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](e79a6962e0...fb8b3582c8)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
1 month ago
dependabot[bot] 6150d61d79 github-actions: bump github/codeql-action from 4.36.1 to 4.36.2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.36.1 to 4.36.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v4.36.1...v4.36.2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.36.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
1 month ago
Giuseppe Longo d892eb8e0e doc/sctp: add sctp keywords
Add documentation for all sctp keywords.

Ticket #4251
1 month ago
Giuseppe Longo dc44447ce6 detect/sctp: add sctp.chunk_data sticky buffer
Add a sctp.data sticky multi-buffer that allows content matching on the bytes
inside any of the SCTP DATA chunks extracted.

Ticket #4251
1 month ago
Giuseppe Longo 1413b082d3 decode/sctp: set p->payload to data chunk
Track the first DATA chunk's data offset and length during chunk iteration,
then reassign p->payload to point at the user data.

When no DATA chunk is present (INIT, SACK, HEARTBEAT, etc.),
payload_len is set to 0 since there is no application data.

Ticket #4251
1 month ago
Giuseppe Longo ede1bce923 output/json: add sctp metadata to alerts
Log SCTP-specific fields in the EVE JSON "sctp" object for alert events.

Ticket #4251
1 month ago
Giuseppe Longo 2116c3cafc detect/sctp: add sctp.vtag keyword
Add a U32 numeric keyword to match the SCTP verification tag
from the common header with prefilter support.

Ticket #4251
1 month ago
Giuseppe Longo 855f49b649 detect/sctp: add sctp.chunk_cnt keyword
Add a U8 numeric keyword to match the number of SCTP chunks
parsed in a packet with prefilter support.

Ticket #4251
1 month ago
Giuseppe Longo 88f17d7b20 detect/sctp: add sctp.chunk_type keyword
Add a U8 numeric keyword to match the first SCTP chunk type in a packet
with prefilter support.

Ticket #4251
1 month ago
Giuseppe Longo bbd0ecb616 detect/sctp: add sctp.hdr sticky buffer
Implement a sticky buffer to match the raw SCTP header
(common header + chunks)

Ticket #4251
1 month ago
Giuseppe Longo 21d35f6b37 decoder/sctp: extend decoder
Extend the SCTP decoder to parse chunk headers after the 12-byte common
header. Each chunk is validated for minimum header size and length
consistency per RFC 4960 sec 3.2.

Add SCTPChunkHdr and SCTPVars structs to track per-packet chunk metadata

Add five new decoder events for protocol violations:
- SCTP_CHUNK_TOO_SMALL: insufficient data for a chunk header
- SCTP_CHUNK_LEN_INVALID: chunk length < 4 or exceeds packet
- SCTP_INIT_CHUNK_NOT_ALONE: INIT/INIT_ACK bundled (RFC 4960 sec 6.10)
- SCTP_INIT_WITH_NON_ZERO_VTAG: INIT with vtag != 0 (RFC 4960 sec 8.5.1)
- SCTP_DATA_WITH_ZERO_VTAG: DATA chunk with vtag == 0

Ticket #4251
1 month ago
Martin Rehak 2ce2ebcdba suricata: guard RLIMIT_NPROC usage
Only use RLIMIT_NPROC when the platform exposes that resource limit constant.
1 month ago
Martin Rehak f34acfdeed util/cpu: enable SPARC misalignment emulation at startup
Call a SPARC-specific helper during pre-init so the kernel emulates unaligned accesses for this process instead of terminating on alignment faults. This matches the Solaris/SPARC portability fix that motivated the original patch.
1 month ago
Martin Rehak 1faa2921c1 util/syslog: guard LOG_FTP for Solaris
Only expose the ftp facility when the platform syslog headers define LOG_FTP.
1 month ago
Martin Rehak 823322cb1c util/time: avoid tm_gmtoff on Solaris
Skip tm_gmtoff and tm_zone initialization on Solaris where those struct tm members are not available.
1 month ago
Martin Rehak cf65f7692a build/solaris: use __sun and Solaris byteorder helpers
Replace uses of the non-standard sun macro with __sun and use Solaris byte swap helpers from <sys/byteorder.h>. This keeps the Solaris-specific code paths reachable when building with standard-conforming toolchains.
1 month ago
Martin Rehak 955827bc59 util/path: handle missing d_type definitions on Solaris
Guard DT_REG usage so directory walking code still builds on platforms where dirent does not expose d_type or DT_REG, such as Solaris.
1 month ago
Philippe Antoine e39075557a rust: check llmnr format
Ticket: 3836
1 month ago
Philippe Antoine 4144d9c709 rust: format snmp files
Ticket: 3836
1 month ago
Antoine Abou Faysal b09b04857a doc/userguide: add dataset match subdomain documentation
Ticket: 8385
1 month ago
Antoine Abou Faysal a3ab00e920 detect/dataset: add match subdomain option
Ticket: 8385

Add a new match subdomain option that enables blocking a domain and all its subdomains using datasets.
1 month ago
Shivani Bhardwaj 899eb38691 flowbits: deprecate toggle command
toggle command is not used by any major rulesets and increases the state
complexity of flowbits management. Also, all operations can be carried
out with the combination of other available commands. So, remove it.

Task 8595
1 month ago
Jason Ish 546209ff12 bindgen: fix include ordering
At some point, bindgen include ordering changed such that
AppLayerGetFileState was being bindgen'd as opaque, as the definition of
StreamBufferingConfig was not available when bindgen hit
AppLayerGetFileState, and bindgen processes in order.

Move the util includes before the app-layer includes to fix the ordering
problem, but still keep util includes grouped.

The sys diff is large as many things have been re-ordered.
1 month ago
Philippe Antoine 42fc785e12 fuzz/iprep: initialize to 0 buffer buffer before writing to it
And make MSAN happy
1 month ago
William Ling 30628e45bc rust: replace helper with built-in
Replace custom u32_as_bytes with built-in to_be_bytes

Issue: 5785
1 month ago
William Ling e7edc2a1e2 unittests: convert util-spm tests to FAIL/PASS API
Issue: 6334
1 month ago
Philippe Antoine 9318bbfbdb rust: format tftp files
Ticket: 3836
1 month ago
Philippe Antoine 9ec200e834 rust: format x509 files
Ticket: 3836
1 month ago