The Biosig Project libbiosig MFER default NS mismatch heap-based buffer overflow vulnerability
A heap-based buffer overflow exists in libbiosig's MFER file parsing because the channel array is allocated with zero elements while the parser assumes at least one channel. An attacker can supply a crafted MFER file to trigger out-of-bounds writes, potentially leading to arbitrary code execution.
Originally disclosed on Cisco Talos
A heap-based buffer overflow vulnerability exists in the MFER parsing functionality of The Biosig Project libbiosig 3.9.0 and Master Branch (35a819fa). A specially crafted MFER 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 channel array is allocated with zero elements by constructHDR, but the MFER parser initialises the channel count to one and writes to the first channel entry without resizing the array.
Impact
This flaw can potentially lead to arbitrary code execution, and some writes are at least partially attacker-controlled.
What the attacker needed
Victim opens a crafted MFER file
How it was found
- Craft an MFER file that does not include a tag 5 frame, so the channel array is never resized.
- Feed the file to libbiosig's sopen_extended function.
- The parser initialises hdr->NS to 1 and enters the channel processing loop.
- The loop writes to members of the first CHANNEL_TYPE structure, which lies beyond the allocated heap buffer.
- AddressSanitizer reports a heap-buffer-overflow on the write to hc->Transducer[0].
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.
A medical file reader sets aside a tiny amount of memory for channel information but then writes a full channel record into it, spilling past the end. This is like pouring a large drink into a small cup: the extra liquid goes everywhere. An attacker can craft a file that causes this overflow, and in some cases control what data is written, which could let them 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.