The Biosig Project libbiosig Nex parsing heap-based buffer overflow vulnerability
A heap-based buffer overflow exists in libbiosig's Nex file parsing because the total event count used to allocate the event table differs from the count used when writing to it. An attacker can supply a crafted .nex file to trigger the overflow, potentially leading to arbitrary code execution.
Originally disclosed on Cisco Talos
A heap-based buffer overflow vulnerability exists in the Nex parsing functionality of The Biosig Project libbiosig 3.9.0 and Master Branch (35a819fa). A specially crafted .nex file can lead to arbitrary code execution.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The event table is allocated using a total event count that only includes channels of type 0, 1, or 2, but the code that fills the table adds the per-channel event count for every channel regardless of type, so the write index can exceed the allocated size.
What the attacker needed
Victim opens a crafted .nex file
How it was found
- Craft a .nex file whose header starts with the Nex magic bytes and contains channel entries with a type greater than 2 and a non-zero event count.
- Open the crafted file with libbiosig so that sopen_extended parses it as a Nex file.
- The channel code computes hdr->EVENT.N using only channels of type 0, 1, or 2, and reallocEventTable allocates buffers of that size.
- The event code iterates over all channels, adds each channel's event count to N regardless of type, and writes to hdr->EVENT.POS[N+l] using the larger N, overflowing the heap buffer.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is a memory corruption bug in a library that reads medical signal files. When the library calculates how much memory to reserve for event data, it uses one number, but later it writes using a larger number, so it writes past the end of the reserved memory. That can crash the program or let an attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.