Skip to content
Memory corruption Write-up Advanced

Back to 28: Grub2 Authentication 0-Day

An integer underflow in GRUB2's username and password input handling allows a local attacker to overwrite memory with zeros by pressing backspace repeatedly, redirecting execution to the interrupt vector table and ultimately reaching a rescue shell. This bypasses authentication and gives full control of the bootloader, enabling privilege escalation, information disclosure, and denial of service.

hmarco.org

Published on hmarco.org

A vulnerability in Grub2 has been found. Versions from 1.98 (December, 2009) to 2.02 (December, 2015) are affected.

The author, on hmarco.org

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

Impact

An attacker with local access could bypass authentication, obtain a rescue shell, escalate privileges, disclose information, or cause denial of service; the exploit depends on the specific system and is not generic.

What the attacker needed

Local access to the machine; GRUB2 version 1.98 to 2.02; GRUB asks for username/password

The fix

The bug was fixed by adding a check to ensure cur_len is greater than zero before decrementing it.

How it was found

  1. When GRUB asks for the username, press the Backspace key 28 times.
  2. Press Enter.
  3. The system reboots or you get a rescue shell, indicating the vulnerability is present.
  4. To exploit, press Backspace 17 times to overwrite the return address of grub_memset and redirect execution to address 0x0.
  5. The code at the interrupt vector table executes and eventually jumps to grub_rescue_run(), giving a rescue shell.
  6. From the rescue shell, use the write_word command to patch the authentication check and then run the normal command to return to the GRUB menu without authentication.

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.

GRUB2 is the program that loads Linux when you turn on your computer. It asks for a username and password if configured. A bug in how it handles the backspace key lets someone at the keyboard press backspace many times to corrupt memory and get a special rescue shell without knowing the password. From there they can take control of the machine.

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.