Project

General

Profile

Actions

Security #9161

closed
JI JI

defrag: BSD overlap can undo an earlier left trim

Security #9161: defrag: BSD overlap can undo an earlier left trim

Added by Jason Ish about 2 months ago. Updated 7 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Affected Versions:
Label:
CVE:
Git IDs:

c19c0907d4a5b35f9eaa990c0e61e7610de8fa0e

Severity:
LOW
Disclosure Date:
12/27/2026

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() in
src/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.


Subtasks 1 (0 open — 1 closed)

Security #9164: defrag: BSD overlap can undo an earlier left trim (8.0.x backport)ClosedJason IshActions

Related issues 1 (0 open — 1 closed)

Related to Suricata - Security #9160: defrag: bsd policy only trims the immediate right neighbourClosedJason IshActions
Actions

Also available in: PDF Atom