Hacking the Nintendo DSi Browser
A use-after-free vulnerability in the Nintendo DSi browser's handling of CSS media rules allowed an attacker to execute arbitrary code by reclaiming freed memory with canvas pixel data and jumping to shellcode.
Published on farlow.dev
I managed to exploit the Nintendo DSi browser 15 years after it was released in Japan. This post will go over the journey and the technical details.
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 a use-after-free in the browser's CSS rule handling, where deleting rules frees memory but a dangling pointer is later dereferenced.
Impact
An attacker could execute arbitrary code on the DSi, but the exploit worked only about half the time and required a specific browser version without mitigations.
What the attacker needed
Nintendo DSi with vulnerable browser; User visits malicious webpage
How it was found
- Create many canvases with width and height set to 1.
- Trigger the insertRule/deleteRule bug to free the cssRules memory.
- Write the address of the NOP sled into the canvases as RGBA pixels to reclaim the freed memory.
- Spray NOP sleds and shellcode.
- Evaluate mediaRule.cssRules.length to jump to the NOP sled.
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.
The DSi browser had a bug where deleting certain CSS rules left a pointer to memory that had been freed. An attacker could fill that freed memory with their own data and trick the browser into jumping to it, running their 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.