Skip to content
Memory corruption Write-up Advanced

Your Amiibo’s Haunted

A buffer overflow in Flipper Zero's NFC file loader allows out-of-bounds writes on a heap buffer when parsing a crafted NFC file with too many pages. An attacker could crash the device and potentially execute code by controlling a callback pointer.

VVX7 Follow

Published on vvx7.io

Flipper Zero is a self-described portable multi-tool for pentesters and geeks in a toy-like body. The device comes with several built-in applications to transmit and recieve sub-1GHz frequencies, such as RFID, NFC, and Bluetooth.

VVX7, on vvx7.io

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

The NFC file loader does not validate that the number of pages or the data size read from the file is within the fixed buffer size (MF_UL_MAX_DUMP_SIZE).

Impact

The overflow can cause various crashes including a BusFault and NULL pointer exception, and in some cases the device becomes unresponsive to a reboot and must be re-flashed; the author suggests code execution may be possible but does not demonstrate it.

What the attacker needed

A crafted NFC file; Victim loads the file on a vulnerable Flipper Zero

The fix

The vulnerability was fixed by adding a check that the data size and data read do not exceed the buffer length, breaking the parsing if they do.

How it was found

  1. Create an NFC file with more than 510 pages of data.
  2. Load the file on a vulnerable Flipper Zero (firmware up to 0.65.2).
  3. The loader writes page data beyond the 2040-byte buffer, corrupting heap memory.
  4. Craft the overflow to overwrite the loading_cb function pointer in the dev struct.
  5. The program calls the overwritten callback, potentially executing attacker-controlled code.

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 buffer overflow happens when a program writes more data into a fixed-size memory area than it can hold, spilling into nearby memory. Here, the Flipper Zero reads an NFC file and copies page data into a buffer without checking if the file has too many pages, so extra data overwrites other parts of memory. This can crash the device and, in some cases, let an attacker 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.

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.