Security #8991
Updated by Jason Ish 3 months ago
## 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:
suricata -c <stock config> -S suricata.rules -r EXACT3.pcap \
-l <output dir> -k none
## 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
Please credit torjan0.