The Biosig Project libbiosig ABF parsing integer overflow to heap-based buffer overflow vulnerability
An integer overflow in the ABF file parsing of libbiosig allows a crafted file to cause a heap-based buffer overflow, potentially leading to arbitrary code execution.
Originally disclosed on Cisco Talos
An integer overflow vulnerability exists in the ABF parsing functionality of The Biosig Project libbiosig 3.9.0 and Master Branch (35a819fa). A specially crafted ABF 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 sum of two 32-bit fields from the file overflows, causing a smaller allocation than the loop that writes into it.
Impact
A crafted file could lead to arbitrary code execution, though the overflow may be limited by heap layout and the fixed value written to one buffer.
What the attacker needed
Victim opens a malicious ABF file
The fix
The integer overflow should be prevented by validating the sum of the two fields before using it for allocation and loop bounds.
How it was found
- Craft an ABF file with a header that passes the ABF magic check.
- Set lActualEpisodes and lNumTagEntries to values that cause an integer overflow when summed.
- Open the file with libbiosig, which calls sopen_extended and then sopen_abf_read.
- The overflowed event count leads to undersized heap buffers for event positions and types.
- The loop writing events then writes past the end of those buffers.
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.
When a program reads a file, it often uses numbers from the file to decide how much memory to set aside. If those numbers are very large, adding them together can wrap around to a small number, so the program sets aside too little memory. Then it writes more data than fits, spilling into other memory and possibly letting 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.