Stop parsing on a zero-length packet option
Some checks are pending
nmap multiplatform autobuilds / build (arm64, gcc, ubuntu-latest-gcc-arm64, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, freebsd-15-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, macos-15-clang, macos-15) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, macos-26-clang, macos-26) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, netbsd-10-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, openbsd-7-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, solaris-11-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, ubuntu-latest-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (egcc, openbsd-7-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, freebsd-15-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, netbsd-10-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, solaris-11-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, ubuntu-latest-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (msvc, windows-latest-msvc, windows-latest) (push) Waiting to run

Fixes #3368. Closes #3373.
This commit is contained in:
dmiller 2026-06-11 18:31:31 +00:00
parent 141bb72624
commit 7ef4ee030a
2 changed files with 8 additions and 3 deletions

View file

@ -1,5 +1,8 @@
#Nmap Changelog ($Id$); -*-text-*-
o [NSE][GH#3368] Fixed an out-of-memory issue in packet.lua when parsing a
zero-length TCP header option. [Maxim Suhanov]
o Fixed an issue where Nmap OS scan trusts a packet's ip_len to size a CRC32
computation over TCP RST payload data, which may result in reading arbitrary
heap data. Reported by Michael Bommarito.

View file

@ -686,10 +686,7 @@ function Packet:parse_options(offset, length)
local opt_ptr = 0
while opt_ptr < length do
local t, l, d
options[op] = {}
t = self:u8(offset + opt_ptr)
options[op].type = t
if t==0 or t==1 then
l = 1
d = nil
@ -699,6 +696,11 @@ function Packet:parse_options(offset, length)
d = self:raw(offset + opt_ptr + 2, l-2)
end
end
if l==0 then
break
end
options[op] = {}
options[op].type = t
options[op].len = l
options[op].data = d
opt_ptr = opt_ptr + l