Redux: compromising Linux using... SNES Ricoh 5A22 processor opcodes?!
Two missing bounds checks in the Game Music Emu SNES audio emulator allowed an out-of-range X or SP register to be created, and cascading side effects of the MUL and DIV instructions could turn these into large or negative memory offsets. An attacker could then corrupt host heap memory and achieve a reliable drive-by code execution against Fedora 25 with Chrome and Ubuntu 16.04.
Published on scarybeastsecurity.blogspot.com
TL;DR: full reliable 0day drive-by exploit against Fedora 25 + Google Chrome, by breaking out of Super Nintendo Entertainment System emulation via cascading side effects from a subtle and interesting emulation error. Very full details follow.
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 write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the emulator failed to clamp the X register after the MOV (X)+,A instruction and the SP register after RET1, and the MUL and DIV instructions then propagated those out-of-range values without clamping.
Impact
A crafted media file could achieve reliable code execution in media parsing processes on Fedora 25 and Ubuntu 16.04, though on Fedora the vulnerable plugin is not installed by default and the user may be prompted to install it.
What the attacker needed
Victim opens a crafted media file; gstreamer bad plugins installed; no sandbox on the parsing process
The fix
The emulator should clamp the X and SP registers after every modifying instruction and clamp the Y result of MUL and DIV.
How it was found
- Place the chosen opcode sequence at offset 0x100 of a skeleton SPC file.
- Use the MOV (X)+,A instruction to push the X register past 0xff.
- Transfer the oversized X value into A and Y, then use MUL to exponentiate it.
- Use DIV with crafted A, X and Y inputs to produce a negative Y value.
- Use the negative value as an address so writes land before the virtual RAM on the host heap.
- Corrupt host heap structures to redirect execution and run a payload.
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 write-up has not been written yet. The Original tab links to the source.
A music player can include a small emulator that runs code from a game console to generate sound. The emulator had a bug where a register (a small numbered storage slot) could grow past its allowed size, and later maths instructions made that number huge or negative. That let a crafted music file write outside the emulator's memory and take over the program that opened it.
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.