Skip to content

SCTP decoder and sticky buffers v4 - #15482

Closed
glongo wants to merge 12 commits into
OISF:mainfrom
glongo:dev-4251-sctp-v4
Closed

SCTP decoder and sticky buffers v4#15482
glongo wants to merge 12 commits into
OISF:mainfrom
glongo:dev-4251-sctp-v4

Conversation

@glongo

@glongo glongo commented May 29, 2026

Copy link
Copy Markdown
Contributor

Link to ticket: https://redmine.openinfosecfoundation.org/issues/4251

Describe changes:

  • Rebase / Fix Ci

Open questions:

  • Do we want to add sctp.{has_init, has_data, has_abort} keywords?

Previous PR: #15386

SV_BRANCH=OISF/suricata-verify#2999

glongo added 12 commits May 29, 2026 11:30
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
Add a boolean NOOPT keyword to match SCTP packets containing
an INIT chunk.

Ticket OISF#4251
Add a boolean NOOPT keyword to match SCTP packets containing
a DATA chunk.

Ticket OISF#4251
Add a boolean NOOPT keyword to match SCTP packets containing
an ABORT chunk.

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

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.40898% with 109 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.74%. Comparing base (9c76480) to head (9e21b7a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15482      +/-   ##
==========================================
- Coverage   82.76%   82.74%   -0.02%     
==========================================
  Files         998     1008      +10     
  Lines      272286   273082     +796     
==========================================
+ Hits       225344   225975     +631     
- Misses      46942    47107     +165     
Flag Coverage Δ
fuzzcorpus 61.35% <41.44%> (-0.06%) ⬇️
livemode 18.30% <17.98%> (+<0.01%) ⬆️
netns 22.72% <17.98%> (-0.03%) ⬇️
pcap 44.94% <36.84%> (-0.05%) ⬇️
suricata-verify 66.46% <72.80%> (-0.01%) ⬇️
unittests 58.45% <64.21%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@suricata-qa

Copy link
Copy Markdown

WARNING:

field baseline test %
SURI_TLPW2_single_stats_chk
.decoder.event.sctp.chunk_too_small - 0 -
.decoder.event.sctp.chunk_len_invalid - 0 -
.decoder.event.sctp.init_chunk_not_alone - 0 -
.decoder.event.sctp.init_with_non_zero_vtag - 0 -
.decoder.event.sctp.data_with_zero_vtag - 0 -
.sctp.init - 0 -
.sctp.init_ack - 0 -
.sctp.data - 0 -
.sctp.abort - 0 -
.sctp.shutdown - 0 -
SURI_TLPW2_autofp_stats_chk
.decoder.event.sctp.chunk_too_small - 0 -
.decoder.event.sctp.chunk_len_invalid - 0 -
.decoder.event.sctp.init_chunk_not_alone - 0 -
.decoder.event.sctp.init_with_non_zero_vtag - 0 -
.decoder.event.sctp.data_with_zero_vtag - 0 -
.sctp.init - 0 -
.sctp.init_ack - 0 -
.sctp.data - 0 -
.sctp.abort - 0 -
.sctp.shutdown - 0 -
SURI_TLPW1_stats_chk
.decoder.event.sctp.chunk_too_small - 0 -
.decoder.event.sctp.chunk_len_invalid - 0 -
.decoder.event.sctp.init_chunk_not_alone - 0 -
.decoder.event.sctp.init_with_non_zero_vtag - 0 -
.decoder.event.sctp.data_with_zero_vtag - 0 -
.sctp.init - 0 -
.sctp.init_ack - 0 -
.sctp.data - 0 -
.sctp.abort - 0 -
.sctp.shutdown - 0 -
SURI_TLPR1_stats_chk
.decoder.event.sctp.chunk_too_small - 0 -
.decoder.event.sctp.chunk_len_invalid - 0 -
.decoder.event.sctp.init_chunk_not_alone - 0 -
.decoder.event.sctp.init_with_non_zero_vtag - 0 -
.decoder.event.sctp.data_with_zero_vtag - 0 -
.sctp.init - 0 -
.sctp.init_ack - 0 -
.sctp.data - 0 -
.sctp.abort - 0 -
.sctp.shutdown - 0 -
IPS_AFP_stats_chk
.decoder.event.sctp.chunk_too_small - 0 -
.decoder.event.sctp.chunk_len_invalid - 0 -
.decoder.event.sctp.init_chunk_not_alone - 0 -
.decoder.event.sctp.init_with_non_zero_vtag - 0 -
.decoder.event.sctp.data_with_zero_vtag - 0 -
.sctp.init - 0 -
.sctp.init_ack - 0 -
.sctp.data - 0 -
.sctp.abort - 0 -
.sctp.shutdown - 0 -
TREX_GENERIC_stats_chk
.decoder.event.sctp.chunk_too_small - 0 -
.decoder.event.sctp.chunk_len_invalid - 0 -
.decoder.event.sctp.init_chunk_not_alone - 0 -
.decoder.event.sctp.init_with_non_zero_vtag - 0 -
.decoder.event.sctp.data_with_zero_vtag - 0 -
.sctp.init - 0 -
.sctp.init_ack - 0 -
.sctp.data - 0 -
.sctp.abort - 0 -
.sctp.shutdown - 0 -

Pipeline = 31761

@victorjulien

Copy link
Copy Markdown
Member

Lets drop the has_init, has_data, has_abort keywords. While syntactically nicer, they are actually inferior implementations lacking prefilter support. Given that chunk_type can also express this, we don't need them.

@victorjulien victorjulien left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment on the keywords

@glongo

glongo commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Replaced with #15497

@glongo glongo closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants