SCTP decoder and sticky buffers v6 - #15534
Conversation
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 OISF#4251
Implement a sticky buffer to match the raw SCTP header (common header + chunks) Ticket OISF#4251
Add a U8 numeric keyword to match the first SCTP chunk type in a packet with prefilter support. Ticket OISF#4251
Add a U8 numeric keyword to match the number of SCTP chunks parsed in a packet with prefilter support. Ticket OISF#4251
Add a U32 numeric keyword to match the SCTP verification tag from the common header with prefilter support. Ticket OISF#4251
Log SCTP-specific fields in the EVE JSON "sctp" object for alert events. Ticket OISF#4251
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 OISF#4251
Add a sctp.data sticky multi-buffer that allows content matching on the bytes inside any of the SCTP DATA chunks extracted. Ticket OISF#4251
Add documentation for all sctp keywords. Ticket OISF#4251
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #15534 +/- ##
==========================================
- Coverage 82.85% 82.85% -0.01%
==========================================
Files 999 1006 +7
Lines 272609 273370 +761
==========================================
+ Hits 225881 226508 +627
- Misses 46728 46862 +134
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
WARNING:
Pipeline = 31840 |
| ] | ||
| } | ||
| }, | ||
| "has_abort": { |
There was a problem hiding this comment.
should these also reference keyword sctp.chunk_type?
There was a problem hiding this comment.
I was wondering whether it makes sense to log these boolean fields. Thoughts?
| "type": "integer", | ||
| "description": "SCTP DATA chunk with verification tag == 0" | ||
| }, | ||
| "init_chunk_not_alone": { |
There was a problem hiding this comment.
don't have a suggestion, but this doesn't sound great
| alert sctp any any -> any any (msg:"SURICATA SCTP INIT with non-zero vtag"; decode-event:sctp.init_with_non_zero_vtag; classtype:protocol-command-decode; sid:2239005; rev:1;) | ||
| alert sctp any any -> any any (msg:"SURICATA SCTP DATA with zero vtag"; decode-event:sctp.data_with_zero_vtag; classtype:protocol-command-decode; sid:2239006; rev:1;) | ||
| alert sctp any any -> any any (msg:"SURICATA SCTP too many chunks"; decode-event:sctp.too_many_chunks; classtype:protocol-command-decode; sid:2239007; rev:1;) | ||
| alert sctp any any -> any any (msg:"SURICATA SCTP too many data chunks"; decode-event:sctp.too_many_data_chunks; classtype:protocol-command-decode; sid:2239008; rev:1;) |
There was a problem hiding this comment.
nit: we generally have a next sid comment at the bottom of these files
| # SCTP decoder event rules. | ||
| # SID's fall in the 2239000+ range. See rules/README.md | ||
|
|
||
| alert sctp any any -> any any (msg:"SURICATA SCTP packet too small"; decode-event:sctp.pkt_too_small; classtype:protocol-command-decode; sid:2239001; rev:1;) |
There was a problem hiding this comment.
is the packet still marked as sctp in this case? Is there a SV test?
There was a problem hiding this comment.
Yes, the packet is still identified as SCTP. Adding a SV test.
| return -1; | ||
| } | ||
|
|
||
| if (p->l4.vars.sctp.data_chunk_cnt > 0) { |
There was a problem hiding this comment.
can you add a comment about what p->payload is after this assignment? Is this also reflected in the docs?
|
Looking at codecov it seems we have tests exercising the prefilter support, so that needs to be added. |
|
Replaced with #15580 |
Link to ticket: https://redmine.openinfosecfoundation.org/issues/4251
Describe changes:
SCTP_MAX_TRACKED_CHUNKSandSCTP_MAX_DATA_CHUNKSSCTPVarslayoutDEBUG_VALIDATE_BUG_ONchunk_idxpassed inGetBufferforsctp.chunk_dataMIN(const SCTPChunkHdr *)(pkt + offset);withmemcpyPrevious PR: #15497
SV_BRANCH=OISF/suricata-verify#2999