Sound Exchange libsox sphere.c start_read() heap-based buffer overflow vulnerability
A heap-based buffer overflow exists in libsox's sphere.c start_read() due to an off-by-one in lsx_reads and incorrect size accounting, allowing a crafted .sph file to overwrite heap memory. An attacker can provide a malicious file to trigger the overflow, potentially leading to code execution.
Originally disclosed on Cisco Talos
A heap-based buffer overflow vulnerability exists in the sphere.c startread() functionality of Sound Exchange libsox 14.4.2 and master commit 42b3557e. A specially-crafted file can lead to a heap buffer overflow.
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 combination of an off-by-one in lsx_reads (which writes len+1 bytes) and the subsequent subtraction of strlen(buf)+1 from header_size causes an integer underflow, leading to a heap buffer overflow on the next read.
Impact
A crafted file could cause a heap buffer overflow, potentially leading to code execution or denial of service.
What the attacker needed
Victim opens a malicious .sph file
How it was found
- Craft a file starting with the magic bytes 'NIST_1A' followed by an 8-byte header size value.
- Set the header size such that after subtracting 16, the remaining size is small (e.g., 22).
- Include header lines that do not contain 'end_head', causing the loop to continue.
- Provide a long line that overflows the allocated buffer when read by lsx_reads.
- Follow with an 'end_head' line to allow processing to continue.
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 an audio library. When the library reads a specially crafted file, it writes more data into a memory buffer than the buffer can hold, which 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.