Skip to content
RCE Write-up Advanced

SSD Advisory – GNU GRUB Command Injection

A vulnerability in GNU GRUB's grub-mkconfig script allows an attacker who controls a removable device to inject arbitrary GRUB commands into the generated grub.cfg, leading to command execution with elevated privileges when the system reboots.

ssd-disclosure.com

Published on ssd-disclosure.com

Find out how a vulnerability in GNU GRUB allows users on a Linux system to inject commands into the process of grub-mkconfig which allows them to execute arbitrary commands with elevated privileges.

SSD Secure Disclosure technical team, on ssd-disclosure.com

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, grub-mkconfig does not properly parse GRUB commands and copies entire lines that start with certain commands, allowing injection via a semicolon.

Impact

An attacker could execute arbitrary commands with elevated privileges on the target system, but the infected device must remain attached until reboot.

What the attacker needed

Control over a removable device; target runs grub-mkconfig; device stays attached until reboot

The fix

The vendor has released patches that were distributed across all affected distributions.

How it was found

  1. Create a GRUB module that hooks into GRUB after processing grub.cfg and replaces linux commands.
  2. Compile the module and prepare a rootfs with a crafted grub.cfg.
  3. Find the UUID of the target device and replace the dummy UUID in the crafted grub.cfg.
  4. Mount the target device and copy the prepared files onto it.
  5. Wait for the target system to run grub-mkconfig (e.g., during a kernel upgrade) and reboot.

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.

GRUB is the program that loads your operating system when you turn on your computer. The script that updates GRUB's configuration doesn't properly check the contents of other disks, so someone can put a malicious file on a USB stick and trick the script into adding harmful commands. When the computer restarts, those commands run with high privileges.

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.