Skip to content
Memory corruption Write-up Advanced

[0day] [exploit] Compromising a Linux desktop using... 6502 processor opcodes on the NES?!

A vulnerability in the gstreamer 0.10 NSF music player allows out-of-bounds read and write in the host heap due to missing bounds checks on ROM mapping and bank switching. An attacker could craft a malicious NSF file that, when processed (even just by opening a folder containing it), achieves code execution and bypasses ASLR and DEP.

Chris Evans Follow

Published on scarybeastsecurity.blogspot.com

A vulnerability and a separate logic error exist in the gstreamer 0.10.x player for NSF music files. Combined, they allow for very reliable exploitation and the bypass of 64-bit ASLR, DEP, etc.

Chris Evans, on scarybeastsecurity.blogspot.com

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 NSF decoder lacks bounds checking when mapping ROM data into the emulated 6502 address space and when handling bank switching, allowing out-of-bounds heap access.

Impact

An attacker could achieve code execution on the victim's machine with a crafted NSF file, bypassing ASLR and DEP, and the exploit triggers even when the user merely navigates to a folder containing the file (via thumbnail generation).

What the attacker needed

Victim uses affected gstreamer 0.10; victim processes a malicious NSF file; file may need .mp3 extension for auto-detection

The fix

The vulnerability should be fixed by adding proper bounds checking on ROM mappings and bank switching in the NSF decoder, and the report notes that removing the vulnerable plugin (libgstnsf.so) is a workaround since an alternative NSF player exists.

How it was found

  1. Craft an NSF file with a header specifying a ROM load address and bank-switching writes that map ROM to writable memory below 0x8000.
  2. Use 6502 opcodes to read out-of-bounds heap memory and locate the nes6502_context object via a known byte pattern.
  3. Remap virtual address 0x6000 to point to nes6502_context::mem_page[6] to gain read/write access to the host heap.
  4. Perform read/add/write sequences one per frame to calculate the BSS address and map it at virtual 0x7000.
  5. Overwrite the memset() GOT entry to point to system().
  6. Map the read_handler object and modify the apu_read() function pointer to redirect execution to the payload (e.g., xcalc).

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.

This report describes a bug in a music player that handles old Nintendo music files. The player emulates a classic processor and fails to check the size of the music data, letting a crafted file read and write outside its intended memory. An attacker could use this to run their own code on the victim's computer, even without the victim opening the file—just viewing the folder is enough.

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.

More by Chris Evans

View all

11 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.