Skip to content
RCE Write-up Advanced

World’s First MIDI Shellcode

The author reverse-engineered a Yamaha synth's firmware and found a hidden shell that runs over MIDI SysEx messages, reachable over USB. Because that shell exposes arbitrary memory read and write commands, an attacker can write code into RAM and overwrite the call stack so the synth executes it, achieving code execution from a MIDI file.

psi3.ru

Published on psi3.ru

I gained remote code execution via MIDI messages to trick my synth into playing Bad Apple on its LCD. This blog post is about my journey with this reverse engineering project.

The author, on psi3.ru

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 hidden debug shell left enabled in production firmware that accepts arbitrary memory read/write commands over MIDI SysEx, with no authentication beyond a trivial login and no protection against overwriting the call stack.

Impact

An attacker who can get a crafted MIDI file played on the device, or who can send MIDI messages to it, could run arbitrary code on the synth; the author warns the file is firmware-version specific and may behave unpredictably on other devices.

What the attacker needed

Physical USB connection to the synth; ability to send MIDI or play a MIDI file; matching firmware version

How it was found

  1. Connect the synth to a computer over USB and observe that it exposes only a MIDI interface.
  2. Reverse the firmware to find a shell that speaks a custom protocol over MIDI SysEx messages.
  3. Log in to the shell and use its memory read/write commands to place a small code snippet in unused RAM.
  4. Send another memory write that overwrites the call stack so the snippet runs when the command finishes.
  5. Package the same messages into a MIDI file that the synth plays back.

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 synthesiser is a musical instrument with a small computer inside. The researcher found that this computer listens to special MIDI messages (the signals instruments use to talk to each other) and that some of those messages let you read and write its memory directly. By writing a small program into memory and changing where the computer thinks it should return to, he made the instrument run his own code.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.