Skip to content
Memory corruption Disclosed report Advanced

[3DS][StreetPass] Heap Overflow in Swapnote parser leads to userland StreetPass RCE

The Swapnote message parser copies data into fixed-size heap buffers using sizes taken from the message file, so a crafted message overflows heap chunks. Because messages travel over StreetPass, an attacker could achieve userland code execution remotely.

mrnbayoh Follow

Originally disclosed on HackerOne

Informational View original
  • Triaged in 8 days
  • Fixed in 4 months
  • Paid in 4 months
  • Disclosed after 6 months

Summary by the program

Summary by the researcher

#Affected Systems

  • System: Nintendo 3DS
  • Version: <= 11.13
  • Region: ALL

#Description When parsing TLRF chunks in message files the application calls memcpy using user provided sizes to copy controlled data over a fixed-size buffer. Thus one can overflow heap chunks which is enough to get code execution (unsafe unlink). Since messages can be exchanged through StreetPass, one can get remote code execution in userland. For example these kinds of calls are made:

u32 offset_0 = *(u32*)(TLRF_buffer + 0x6DC);
u32 size_0 = *(u32*)(TLRF_buffer + 0x70C);
 memcpy(heap_buffer_0, TLRF_buffer + offset_0, size_0);
[...]
u32 offset_1 = *(u32*)(TLRF_buffer + 0x6EC);
u32 size_1 = *(u32*)(TLRF_buffer + 0x71C); 
memcpy(heap_buffer_1, TLRF_buffer + offset_1, size_1);

Impact

An attacker is able to get RCE in userland through the Swapnote application.

The original report as published on HackerOne, by mrnbayoh. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 parser trusts offset and size fields from the message file and passes them to memcpy without validating them against the destination buffer size.

Impact

An attacker could get remote code execution in userland through the Swapnote application, since messages can be exchanged over StreetPass.

What the attacker needed

Nintendo 3DS on version 11.13 or lower; StreetPass message exchange with attacker

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.

A program often copies data from a file into a small reserved area of memory. Here it trusts a length written in the file instead of checking it, so a longer copy spills past the area and overwrites neighbouring memory. An attacker who can send a message can shape that spill to 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.

More by mrnbayoh

View all

6 more disclosed reports, best first.

More from Nintendo

View all

The newest disclosed reports for this program.

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.