Skip to content
Memory corruption Disclosed report Advanced

[3DS][SSL] Use of uninitialized class member leads to RCE in eShop movie player

The eShop movie player fails to initialise pointers to audio decoder objects, so with the raw pcm16 codec it uses uninitialised memory as a decoder pointer. An attacker who can control the heap could turn this into an arbitrary jump and achieve remote code execution in usermode.

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

  • Platform : (New) Nintendo 3DS
  • Region: ALL
  • System version: 11.13 (latest at the time of writing)

#Description The eShop video player does not initialize pointers to some decoder objects when creating a video player object. With a specific audio codec this induces the use of uninitialized data that an attacker can potentially control through heap massaging, allowing to get remote code execution.

#Vulnerability The eShop movie player does not clear pointers to audio decoder objects when initializing a new video player object. This is not an issue when using codecs like fastaudio or imadpcm because a new decoder is allocated and the pointer is overwritten. However when using the raw pcm16 codec, even though there is no need for a decoder, it still tries to initialize a decoder object using the uninitialized decoder field:

void create_audio_decoder(u8 codec, ..., audio_decoder** out_decoder) {
    if(codec == fastaudio) {
      decoder = create_fastaudio_decoder(...);
      *out_decoder = decoder;
    }
    else if(codec == imadpcm)
      [...]
    else if(codec == pcm16)
      decoder = *out_decoder; // *out_decoder is not initialized!

   if(decoder)
      decoder->init(); //if decoder is controlled this gives an arbitrary jump!
}

This function is the first function called in the first virtual method of what seems to be the Player class?

It is possible to massage the heap such that the value of *out_decoder is controlled because just before the movie player is loaded, the application frees some JPEG images (the screenshot images displayed on the title information page). Thus one can send some carefully crafted binary files instead of valid screenshots to write controlled values in memory and hopefully writes them where the player object is then allocated.

If the data actually get written at the right location, we get an arbitrary jump through the virtual function call decoder->init(), which is enough to get remote code execution.

Impact

Because of #894922, anyone can exploit this vulnerability and get remote code execution in usermode under the eShop application. Moreover, this could potentially(?) be exploited without any SSL flaw by someone able to submit games to the eShop catalog, however since I don't know the validation process and checks performed, I cannot ensure this is possible. Note that one can exploit this vulnerability without any noticeable change to the eShop application behavior, except that the screenshots on the title details page are just not displayed. This means the user has no way to know something bad is happening before launching the video playback.

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 player object's decoder pointer is not cleared during initialisation, and the pcm16 code path reads it instead of allocating a decoder.

Impact

An attacker could get remote code execution in usermode under the eShop application, and the only visible sign is that title screenshots are not displayed.

What the attacker needed

Nintendo 3DS (affected system version 11.13); Ability to deliver crafted files to the eShop; May rely on a separate SSL flaw (#894922), though possibly…

How it was found

  1. Load a title information page so the eShop frees the JPEG screenshot images.
  2. Send crafted binary files in place of valid screenshots to write controlled values into freed memory.
  3. Trigger playback of a movie using the raw pcm16 codec so the uninitialised decoder pointer is used.
  4. The virtual call through the controlled pointer causes an arbitrary jump.

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.

When a program creates an object, it should set every field to a known value first. Here one pointer field is left holding whatever was in memory before, and the program later calls a function through that pointer. If an attacker can arrange for that leftover memory to contain a value they choose, the program jumps to code they control.

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.