A heap out-of-bounds write exists in the libnsbmp copy bundled in the
netsurf source package (libnsbmp/src/libnsbmp.c). A crafted BMP makes
the decoder compute a wrapped row stride in uint32_t (swidth =
sizeof(uint32_t) * width) and then write scanlines past the allocated
pixel buffer. The same wrapped value is used by the per-row bounds
check, so the check does not stop the write.
On the official i386 packages the out-of-bounds dwords overlap heap
objects, including the nsfb_t plotter function table. This is reachable
from an image loaded from the local filesystem or fetched over HTTP.
With ASLR enabled I verified code execution (arbitrary command) in the
browser process, with the privileges of the user opening the image; if
the guessed PIE base is wrong the process crashes instead.
Affected and tested:
* trixie: netsurf-fb 3.11-2, netsurf-gtk 3.11-2
* bookworm: netsurf-fb 3.10-1+b3, netsurf-gtk 3.10-1+b3
* upstream libnsbmp (0.1.7, commit 3e54099) and current master are
still affected
I have also reported this to security@netsurf-browser.org. The detailed
write-up (root cause, affected code locations, exploitability analysis
and suggested fix) is attached. A proof-of-concept is available
privately to the security team on request; I would prefer not to publish
exploit details before a fix or a coordinated disclosure date.
Please assign a CVE identifier for this issue (or advise whether it
should be requested from MITRE), and let me know the planned fix and
disclosure timeline. I am happy to test a proposed patch.
Thanks,
Yuxiang Huang