Project

General

Profile

Actions

Security #9144

closed
PA PA

tcp: evasion as window scale above 14 is treated as 0

Security #9144: tcp: evasion as window scale above 14 is treated as 0

Added by Philippe Antoine about 2 months ago. Updated 7 days ago.

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

b63d2aeee7f7ac17b467d903892ac26e8f075cdb

Severity:
MODERATE
Disclosure Date:
12/27/2026

Description

Original report

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.
TCP window scale above 14 is treated as 0 instead of 14, letting an endpoint hide traffic from Suricata
TLDR
The vulnerability is that the TCP decoder in `src/decode-tcp.c` stores a window-scale option value as `0` whenever it is larger than 14, instead of clamping it to 14 the way RFC 7323 requires and the way real Linux/BSD/Windows TCP stacks do. Because Suricata then uses this scale to size the peer's receive window (`window << wscale`), an attacker who puts window-scale = 15 and a small window value in a single SYN makes Suricata compute a receive window up to 16384x smaller than the real host uses. Data that the real host happily accepts is rejected by Suricata as `STREAM_EST_PACKET_OUT_OF_WINDOW` and never reaches stream reassembly or app-layer (HTTP/TLS/file) inspection, so reassembly-based and app-layer signatures on that traffic never fire. The root cause is lines 98-101 of `src/decode-tcp.c`.
Root cause
https://github.com/OISF/suricata/blob/bc48b4f44c7d3bdd06bf670405a2f016bb1157a1/src/decode-tcp.c#L96-L102 
```c
p->l4.vars.tcp.wscale_set = 1;
const uint8_t wscale = (tcp_opts[tcp_opt_cnt].data);
if (wscale <= TCP_WSCALE_MAX) {
p->l4.vars.tcp.wscale = wscale;
} else {
p->l4.vars.tcp.wscale = 0;
}
```
`TCP_WSCALE_MAX` is 14. When a SYN advertises a window-scale shift count greater than 14, this `else` branch stores `0`. That is the opposite of what a real TCP endpoint does: RFC 7323 §2.3 says "If a Window Scale option is received with a shift.cnt value larger than 14, the TCP SHOULD log the error but MUST use 14 instead of the specified value", and Linux/BSD/Windows all clamp to 14. A scale of 0 means "multiply the advertised window by 1"; a scale of 14 means "multiply by 16384". So Suricata ends up believing the endpoint's receive window is up to 16384x smaller than it really is.
This wrong value is what Suricata uses to decide whether a segment is inside the receiver's window. Because the check is `seq + payload_len <= next_win` and `next_win` is derived from `window << wscale`, an undersized `wscale` makes Suricata reject in-window segments that the real host accepts, and a rejected segment is dropped before it ever reaches reassembly or the app-layer parsers.
Dataflow from the attacker's SYN to the missed inspection:
A client sends a SYN whose window-scale option carries shift count 15 and whose window field is small (e.g. 16). The decoder parses the option in the `TCP_OPT_WS` case (https://github.com/OISF/suricata/blob/bc48b4f44c7d3bdd06bf670405a2f016bb1157a1/src/decode-tcp.c#L88) and, because 15 > 14, stores `wscale = 0` (https://github.com/OISF/suricata/blob/bc48b4f44c7d3bdd06bf670405a2f016bb1157a1/src/decode-tcp.c#L101).
`TCP_GET_WSCALE(p)` therefore returns 0 (https://github.com/OISF/suricata/blob/bc48b4f44c7d3bdd06bf670405a2f016bb1157a1/src/decode-tcp.h#L101).
The stream engine records this as the scale governing the client's advertised window: `ssn->server.wscale = TCP_GET_WSCALE(p)` (https://github.com/OISF/suricata/blob/bc48b4f44c7d3bdd06bf670405a2f016bb1157a1/src/stream-tcp.c#L1451).
Suricata scales the client's advertised receive window by this stored scale, `window << ssn->server.wscale`, to form the edge `ssn->server.next_win` up to which the server is allowed to send (https://github.com/OISF/suricata/blob/bc48b4f44c7d3bdd06bf670405a2f016bb1157a1/src/stream-tcp.c#L3029). With `wscale = 0` this edge is up to 16384x too small.
Each server-to-client segment is then gated on that edge in `HandleEstablishedPacketToClient` (https://github.com/OISF/suricata/blob/bc48b4f44c7d3bdd06bf670405a2f016bb1157a1/src/stream-tcp.c#L3175). Segments the real host accepts fall outside Suricata's shrunken window, so Suricata raises `STREAM_EST_PACKET_OUT_OF_WINDOW` and returns before calling reassembly (https://github.com/OISF/suricata/blob/bc48b4f44c7d3bdd06bf670405a2f016bb1157a1/src/stream-tcp.c#L3209).
Because `StreamTcpReassembleHandleSegment` is never reached for those bytes, the response is never added to the reassembly buffer and never reaches the app-layer parsers, so `http.`, `file.data`, `tls.`, and any content match that relies on the reassembled stream (including content that spans more than one segment) never fire on that direction. (Suricata still runs per-packet detection on the rejected packet, so a plain `content` match that happens to fit entirely inside a single packet's payload can still match — the evasion defeats stream-reassembly and app-layer inspection, not single-packet payload matching.)
I confirmed this end to end by building Suricata at the current `main` commit and replaying two captures that are byte-for-byte identical except for the single window-scale byte in the client SYN. With shift count 14, an HTTP response body containing a marker triggers `http.response_body`, `file.data`, and `http.stat_code` rules. With shift count 15, those app-layer rules all go silent and Suricata instead logs `STREAM ESTABLISHED packet out of window` for the response — the endpoint hides its response from Suricata using one byte in one packet. Suricata's own unit test `TCPGetWscaleTest02` asserts the erroneous `0`, so the behaviour is currently baked in rather than treated as a bug.
The primary damage is on the direction whose window scale was corrupted. A client-controlled SYN corrupts the server-to-client window, which hides server responses: malware and file downloads, HTTP/TLS response content, and the response side of attacker-controlled C2. An attacker who controls both endpoints (C2, tunneling) can desync either or both directions at will. This works in Suricata's default IDS/passive configuration and needs no special options.
Suggested fix
In the `else` branch, clamp to the maximum instead of dropping to zero, matching RFC 7323 and real TCP stacks:
```c
if (wscale <= TCP_WSCALE_MAX) {
p->l4.vars.tcp.wscale = wscale;
} else {
p->l4.vars.tcp.wscale = TCP_WSCALE_MAX;
}
```
This guarantees Suricata's computed receive window is never smaller than the destination host's, closing the out-of-window mismatch. The `TCPGetWscaleTest02` unit test should be updated to expect 14 rather than 0.
Reproducing with the attached suricata-verify test
Attached to this email are four files that make up a self-contained suricata-verify test: `test.yaml`, `test.rules`, `input.pcap`. The test fails on the affected code and passes once the fix below is applied. Steps to run it:
Build Suricata at the affected commit so that `src/suricata` exists in your Suricata source tree (the usual `./autogen.sh && ./configure && make`).
Get suricata-verify next to it: `git clone https://github.com/OISF/suricata-verify.git`
Create the test directory and drop the four attached files into it (keep the filenames exactly as attached):
```
mkdir -p suricata-verify/tests/stream-tcp-wscale-oow-evasion
cp test.yaml test.rules input.pcap suricata-verify/tests/stream-tcp-wscale-oow-evasion/
```
From the Suricata source/build directory (the one containing `src/suricata` and `suricata.yaml`), run the test:
```
cd /path/to/suricata
python3 /path/to/suricata-verify/run.py stream-tcp-wscale-oow-evasion
```
On the unpatched engine the test fails: sub test #1 reports `expected 1 matches; got 0` (the server response is never inspected) and sub test #2 reports `expected 0 matches; got 1` (the response is wrongly rejected as out-of-window). After applying the fix, the same command prints `stream-tcp-wscale-oow-evasion: OK` and passes. The test pins `--runmode single` in `test.yaml`, so it behaves identically regardless of how many CPU cores the host has.
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.
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.

Kind regards,
Adam Korczynski

Subtasks 1 (0 open — 1 closed)

Security #9145: tcp: evasion as window scale above 14 is treated as 0 (8.0.x backport)ClosedPhilippe AntoineActions

OT Updated by OISF Ticketbot about 2 months ago Actions #1

  • Subtask #9145 added

OT Updated by OISF Ticketbot about 2 months ago Actions #2

  • Label deleted (Needs backport to 8.0)

PA Updated by Philippe Antoine about 2 months ago Actions #3

Proposing severity HIGH as a generic TCP evasion

PA Updated by Philippe Antoine about 2 months ago Actions #5

  • Status changed from New to Triaged

JI Updated by Jason Ish about 2 months ago Actions #6

  • Disclosure Date set to 12/27/2026

PA Updated by Philippe Antoine about 2 months ago Actions #7

  • Status changed from Triaged to Assigned
  • Assignee changed from OISF Dev to Philippe Antoine

PA Updated by Philippe Antoine about 2 months ago Actions #8

  • Status changed from Assigned to In Review

Gitlab MR

JI Updated by Jason Ish about 1 month ago Actions #9

  • GHSA set to GHSA-9rgg-8f9w-rqv4

SB Updated by Shivani Bhardwaj about 1 month ago Actions #10

  • Subject changed from tcp: evasion as window scale above 14 is treated as 0 instead of 14 to tcp: evasion as window scale above 14 is treated as 0

JI Updated by Jason Ish about 1 month ago Actions #11

  • Severity changed from HIGH to MODERATE

Reclassifying TCP bypasses to MODERATE.

PA Updated by Philippe Antoine 25 days ago Actions #12

  • Status changed from In Review to Resolved

staged

JI Updated by Jason Ish 25 days ago Actions #13

  • Git IDs updated (diff)

PA Updated by Philippe Antoine 25 days ago Actions #14

  • Status changed from Resolved to Closed

JI Updated by Jason Ish 7 days ago Actions #15

  • Private changed from Yes to No
Actions

Also available in: PDF Atom