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.
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
- Create a GRUB module that hooks into GRUB after processing grub.cfg and replaces linux commands.
- Compile the module and prepare a rootfs with a crafted grub.cfg.
- Find the UUID of the target device and replace the dummy UUID in the crafted grub.cfg.
- Mount the target device and copy the prepared files onto it.
- 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.