Security #9161
closeddefrag: BSD overlap can undo an earlier left trim
c19c0907d4a5b35f9eaa990c0e61e7610de8fa0e
Description
Hello,
This is a disclosure for a vulnerability in Suricata that was found by Anthropic
using their models and agents. I have reviewed the vulnerability and consider
it to be true according to Suricata's threat model.
BSD defrag policy can undo an earlier trim, so Suricata reassembles different bytes than the target host¶
TLDR¶
The vulnerability is that the BSD overlap handling in DefragInsertFrag() insrc/defrag.c overwrites the left-trim (ltrim) of the next fragment instead of
only raising it (lines 694 and 716). A fragment that arrives later can therefore
lower a trim that an earlier fragment already set. This brings back bytes that
should have been replaced. Because reassembly copies fragments in offset order,
those old bytes are copied last and win. The reassembled packet that Suricata
inspects then differs from the one a BSD-style host builds, so an attacker can
hide the bytes a signature looks for. BSD is Suricata's default defrag policy
(default_policy = DEFRAG_POLICY_BSD), and the same code is in main and in the
7.0.x and 8.0.x branches. Both IPv4 and IPv6 use this code.
Root cause¶
ltrim tells reassembly how many bytes at the start of a stored fragment have
been replaced by other fragments. It must only grow. The prev update at lines
708-713 respects this: it only writes prev_ltrim if it is larger than the
current value. The next update at lines 715-717 (and 693-695) does not. It
always writes frag_end - next->offset, even when next->ltrim is already
larger because of an earlier overlap.
[Editorial omission: detailed trigger analysis, vulnerable code excerpts, and execution dataflow are not reproduced here.]
Suggested fix¶
Make the next update work like the prev update, so it only ever raises the
trim. Apply this at both places (lines 693-695 and 715-717):
if ((next != NULL) && (frag_end > next->offset)) {
uint16_t next_ltrim = frag_end - next->offset;
if (next_ltrim > next->ltrim) {
next->ltrim = next_ltrim;
}
}
[Editorial omission: the specific fragment sequence requested for the unit test is not reproduced here.]
Reproducer (suricata-verify test)¶
[Editorial omission: operational reproducer details and execution instructions are not reproduced here. The source report includes test.yaml, test.rules, suricata.yaml, and input.pcap.]
Disclosure¶
This report follows a 90-day coordinated disclosure deadline. I'm happy to
coordinate on the exact timing and to provide any further detail you need.
Attribution¶
Please attribute Anthropic and Ada Logics. This issue was found by Anthropic
by using agents to study security of open source projects, and I have helped
validate the found issue, create the report and communicate it to you.
JI Updated by Jason Ish about 2 months ago
- Description updated (diff)
JI Updated by Jason Ish about 2 months ago
- Status changed from New to Assigned
- Assignee changed from OISF Dev to Jason Ish
- Target version changed from TBD to 9.0.0-beta1
- Label Needs backport to 8.0 added
JI Updated by Jason Ish about 2 months ago
- Related to Security #9160: defrag: bsd policy only trims the immediate right neighbour added
OT Updated by OISF Ticketbot about 2 months ago
- Subtask #9164 added
OT Updated by OISF Ticketbot about 2 months ago
- Label deleted (
Needs backport to 8.0)
JI Updated by Jason Ish about 2 months ago
- Status changed from Assigned to In Review
JI Updated by Jason Ish about 2 months ago · Edited
- Severity set to LOW
Recommendations:
Severity:
│ Low, CVSS 3.1 3.7 (AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N), CWE-437.
│ Limited to evasion of payload inspection; the required fragment overlap is
│ still detected and alerted on by the decoder event rules (sid 2200070/2200072).
Impact:
│ With the BSD defrag policy (default), a later overlap could lower an existing
│ fragment trim, restoring replaced data, so crafted IPv4/IPv6 fragments can
│ make Suricata inspect different data than the host reassembles, evading rules.
JI Updated by Jason Ish about 1 month ago
- GHSA set to GHSA-g479-hvv2-45w7