mackron dr_libs dr_wav drwav__read_cue_to_metadata_obj out-of-bounds write vulnerability
A specially crafted WAV file can cause an out-of-bounds write in dr_wav's metadata parsing because a mismatched smpl chunk makes the parser advance its metadata cursor without reserving space. An attacker can supply a malicious file to trigger a write-what-where with file-controlled address and value.
Originally disclosed on Cisco Talos
A out-of-bounds write vulnerability exists in the drwav drwavreadcuetometadataobj functionality of drlibs (version(s): 0.14.5). A specially crafted .wav file can lead to an out-of-bounds write.
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 pass-1 and pass-2 metadata parsing disagree: pass 1 skips reserving a slot when a smpl chunk's loop count does not match its size, but pass 2 still increments metadataCursor, so later chunks write into unaccounted heap space.
Impact
An attacker could cause an out-of-bounds write with a file-controlled destination address and value, potentially leading to code execution or a crash.
What the attacker needed
Victim opens a crafted WAV file; application uses dr_wav metadata API
The fix
The pass-2 metadataCursor increment should be corrected so it only advances when pass 1 reserved a slot.
How it was found
- Craft a WAV file containing a smpl chunk whose loop count does not match the size-derived calculated loop count.
- Place a cue chunk after the mismatched smpl chunk.
- Call drwav_init_with_metadata, drwav_init_file_with_metadata, or drwav_init_memory_with_metadata on the file.
- The parser processes the cue chunk at an out-of-bounds metadata slot and writes cue point data through a corrupted pointer.
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.
dr_wav is a small library for reading WAV audio files. When it reads extra information chunks, it first counts how much memory it needs and then fills that memory. A bug lets a crafted file make the second step write past the reserved memory, and the attacker controls both where it writes and what it writes.
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.