Out-of-bounds read in TCP SYN response option parsing
Hello Zakir,
Nebula Security is reporting an out-of-bounds read in the default TCP SYN scan response parser. The parser accepts a minimum 20-byte TCP header, then uses the header's data-offset field as the bound for TCP option parsing. A response that advertises a 60-byte TCP header while carrying only 20 bytes causes the parser to read beyond the captured packet.
Our initial message to [[email protected]](mailto:[email protected]) was returned as undeliverable, so we are
sending this report to you directly as well.
A scanned endpoint can build the response from the port and sequence number in
the incoming SYN. On the default Linux libpcap receive path, a short burst of
identical responses terminated both our CMake release build and Arch Linux's
zmap 4.4.0-1 package with SIGSEGV. The official package exited with status
139 after the server sent 50,000 responses. A 15,000-response burst was
sufficient with our build. The exact count depends on the capture-ring layout
and packet loss.
We reproduced the issue with ZMap 4.4.0 and at commit
217fcf70d7b507c0f69d993e2561c79ddedddb54 on x86-64 Linux. The crash occurred
in parse_tcp_opts() at
src/probe_modules/module_tcp_synscan.c:488 while reading beyond the end of a
libpcap TPACKET_V3 mapping.
The attached [zmap-tcp-synscan-options-oob-read-reproduction.zip](https://zmap-tcp-synscan-options-oob-read-reproduction.zip/) contains a
report in [REPORT.MD](https://report.md/) and a raw-socket server. The live test uses two Linux
hosts and one ordinary ZMap scan command. The server reads the source port and
sequence number from the probe before sending the responses.
We would appreciate a tracking ID for this report. If the project publishes an advisory, please credit "Nebula Security".
Regards,
Nebula Security
Source: zmap/zmap