Security #8991
closedstream: desynchronization and detection bypass due to invalid TCP timestamp handling
149aa9705d7b82cc78f566acc5a725c8b97f03d0
75d23049378557401635d758d5b19b7e71ef8244
Description
- Summary
Suricata's TCP stream engine can reconstruct and inspect a different HTTP
request than the destination server executes.
The attacker is an ordinary client. No spoofing, on-path position, or packet
insertion primitive is required. The attacker needs a raw socket to control
TCP timestamps on its own connection.
- Mechanism
Suricata accepts established-state TCP data segments whose timestamp option
violates PAWS while a Linux endpoint rejects them. An attacker can therefore
place a segment that the sensor accepts and the endpoint discards.
Because Suricata resolves the resulting overlap by keeping the bytes received
first, the real payload arriving later at the same sequence is discarded by
the sensor but processed by the server.
- Reproduction
Use one TCP connection with timestamps negotiated during the handshake,
followed by three client segments:
1. `GET /primer HTTP/1.1` at sequence S with TSval TSc+100. This advances the
endpoint's `ts.recent`.
2. `GET /benign-aaaaaa HTTP/1.1` at sequence S+len(primer) with stale TSval
TSc+2. The endpoint discards this through PAWS, but Suricata accepts it.
3. `GET /malicious-xxx HTTP/1.1` at the same sequence with fresh TSval
TSc+101. The endpoint accepts it as the first data at that sequence.
Suricata treats it as an overlapping retransmission and keeps the benign
bytes.
Replay command:
- Observed result
The Linux 6.8 endpoint parsed and served both `/primer` and
`/malicious-xxx`. It did not parse `/benign-aaaaaa`.
Replaying the same capture in Suricata with a rule matching `malicious`
produced no alerts. Suricata logged `/primer` and `/benign-aaaaaa`; the request
executed by the server was not inspected.
Removing the overlap isolates the timestamp behavior. A primer using TSval
TSc+100 followed by a request at a new sequence using stale TSval TSc+2 is
accepted by Suricata, and `stream-event:pkt_invalid_timestamp` does not fire.
- Affected versions
The behavior was reproduced on:
- Suricata 8.0.6 built with unit tests;
- Suricata 8.0.6 built without unit tests; and
- development `main` at commit
`7ca947114506800fa9cd6beefaa56ecad17f002e`, identifying as 9.0.0-dev.
A clean malicious request alerts normally on each build.
- Configuration and visibility
The bypass reproduces with `stream.liberal-timestamps` set to either `false`
or `true` and with Linux, old-Linux, Windows, BSD, and Solaris host OS
policies.
The run produces only flow and stats events. No invalid-timestamp event fires,
and `tcp.overlap_diff_data` remains zero.
- Limitations
The endpoint behavior was tested with Linux 6.8 and
`net.ipv4.tcp_timestamps=1`. Other endpoint stacks were not tested.
- Reproducer artifacts
The supplied reproducer consists of:
- `EXACT3.pcap`: complete bidirectional exchange demonstrating the bypass;
- `W0_control.pcap`: control capture that alerts normally;
- `X1_stale_no_overlap.pcap`: timestamp-only isolation case;
- `suricata.rules`: detection rule;
- `test.yaml`: Suricata-Verify characterization test; and
- `generate_pcap.py`: network-namespace and Scapy generation harness.
The artifacts are synthetic, lab-generated, and contain no production or
personal traffic.
- Credit
Maksim Hayder
GitHub: torjan0
Files
OT Updated by OISF Ticketbot 3 months ago
- Subtask #8992 added
OT Updated by OISF Ticketbot 3 months ago
- Label deleted (
Needs backport to 8.0)
SB Updated by Shivani Bhardwaj 3 months ago
- Subject changed from Suricata 8.0.6 and 9.0.0-dev: TCP timestamp handling on established-state data allows stream desynchronization and detection bypass to stream: desynchronization and detection bypass due to invalid TCP timestamp handling
PA Updated by Philippe Antoine 3 months ago
- Severity set to HIGH
I propose HIGH severity as an evasion with a wide scope (basically everything on TCP)
PA Updated by Philippe Antoine 3 months ago
- Status changed from New to Triaged
PA Updated by Philippe Antoine 3 months ago
- Status changed from Triaged to Assigned
- Assignee changed from OISF Dev to Philippe Antoine
I have a simple small fix
PA Updated by Philippe Antoine 3 months ago
- Status changed from Assigned to In Review
Gitlab MR
LS Updated by Lukas Sismis about 1 month ago
- Assignee changed from Philippe Antoine to Lukas Sismis
JI Updated by Jason Ish about 1 month ago
- Severity changed from HIGH to MODERATE
Reclassifying TCP bypasses to MODERATE.
PA Updated by Philippe Antoine 25 days ago
- Status changed from In Review to Resolved
staged