The Biosig Project libbiosig RHS2000 parsing heap-based buffer overflow vulnerability
A heap-based buffer overflow exists in libbiosig's RHS2000 file parsing because the channel array is allocated with zero elements and later written to as if it held at least one channel. An attacker can supply a crafted RHS2000 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 RHS2000 parsing functionality of The Biosig Project libbiosig 3.9.0 and Master Branch (35a819fa). A specially crafted RHS2000 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
Likely the channel array is allocated with zero elements by constructHDR, and sopen_rhs2000_read writes to the time channel without ensuring the array was resized when no signal groups are enabled.
Impact
This could lead to arbitrary code execution, though the write destination is at a fixed offset and the written data is only partially attacker-controlled.
What the attacker needed
Victim opens a crafted RHS2000 file
How it was found
- Craft an RHS2000 file with the magic bytes and numberOfSignalGroups set to 0 or all signal groups disabled.
- Feed the file to libbiosig through sopen_extended.
- The parser reaches the time channel code and writes to hdr->CHANNEL[0].
- The write goes past the small allocation, causing a heap-based buffer overflow.
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.
The library allocates a list of channels with zero entries, then later writes data into the first entry as if it existed. Writing past the end of allocated memory is called a heap-based buffer overflow, and a malicious file can trigger it. This can crash the program or, in some cases, 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.