Skip to content
GoogleGHSA-42j5-mmpp-3vwg

Cisco NX OS: Bootloader Script Execution Vulnerability

HighCVE-2024-20397 · Published Dec 6, 2024 · updated Jan 25, 2025

### Summary During boot, the bootloader (cisco-grub) will enumerate all potential boot drives and probe for a menu.lst script file. If an adversary manages to place such a file on the system’s SSD or on an external USB drive, the bootloader will trust that file and execute all commands in it. This can be used to gain arbitrary code execution in the bootloader and/or bypass image signature verification checks that the bootloader would normally perform before executing an NX OS image. For example, the “displaymem” command allows exposing a small part of grub’s heap layout: ![displaymem](https://github.com/user-attachments/assets/daec7280-d76b-45bf-ab2e-031536f19f7d) We can confirm that the memory layout never changes across reboots, which indicates the absence of exploit mitigations such as ASLR. This is unfortunately still common in such bootloaders and UEFI firmware. Combined with the “memrw” command, it is possible to read and write arbitrary memory: ![memrw](https://github.com/user-attachments/assets/0340a908-8a08-4785-b35f-2c35041160a4) The previous screenshots show that the commands were executed by simply entering them through the serial console. ### Severity High - A suc...

GitHub advisory

Affected versions

PackageAffectedFixed in
Grub
Product
<= 10.4.2No fix yet
Details and references

### Summary During boot, the bootloader (cisco-grub) will enumerate all potential boot drives and probe for a menu.lst script file. If an adversary manages to place such a file on the system’s SSD or on an external USB drive, the bootloader will trust that file and execute all commands in it. This can be used to gain arbitrary code execution in the bootloader and/or bypass image signature verification checks that the bootloader would normally perform before executing an NX OS image. For example, the “displaymem” command allows exposing a small part of grub’s heap layout: ![displaymem](https://github.com/user-attachments/assets/daec7280-d76b-45bf-ab2e-031536f19f7d) We can confirm that the memory layout never changes across reboots, which indicates the absence of exploit mitigations such as ASLR. This is unfortunately still common in such bootloaders and UEFI firmware. Combined with the “memrw” command, it is possible to read and write arbitrary memory: ![memrw](https://github.com/user-attachments/assets/0340a908-8a08-4785-b35f-2c35041160a4) The previous screenshots show that the commands were executed by simply entering them through the serial console. ### Severity High - A successful exploit could allow the attacker to elevate privileges to root. The vulnerable code can be triggered both via physical access and remotely, by modifying the device's file system. ### Proof of Concept To demonstrate that this also works without any user interaction, we created a simple menu.lst configuration file and placed it on a USB drive. As long as the USB drive is formatted using one of the file systems that grub supports (ext2, FAT32), it will try and open the script from /boot/grub/menu.lst.local and if it exists, it executes all commands in it, as shown in the following screenshots: For example, the “displaymem” command allows exposing a small part of grub’s heap layout: ![menu lst local contents](https://github.com/user-attachments/assets/c7830730-1166-4d48-b79e-c08d496ccec8) ![serial console log](https://github.com/user-attachments/assets/b8d8a9f4-ea97-4829-991d-c4000bfa8db2) Serial Console Log, showing how grub executes commands from our malicious menu.lst.local file without user interaction. This leads to arbitrary code execution since adversaries can use this and overwrite sections of grub itself, inject their own code or simply patch the signature verification in grub, which would allow booting any compromised version of NX OS. A secure erase operation removes the menu.lst file only if the system is not compromised already. If the attack is carried out carefully, attackers may try to bypass secure erase procedures. ### Further Analysis We believe that the identified vulnerability has a “Critical” severity since once the script has been placed, compromise happens without user interaction and all availability, integrity or confidentiality that the device would provide is permanently lost or controlled by the attacker. Attackers can use this vulnerability to bypass image verification and load arbitrary NX OS images, which can contain and execute any attacker-controlled code. Detecting this compromise from within a compromised NX OS image can be challenging since the attacker can mask their presence and there is no hardware root of trust that could provide cryptographically verifiable, tamper-resident evidence on which firmware was executed and how it was configured. Devices generally permit downgrades and out of the box, NX OS provides features that allow placing the payload, which paves the way for remote attacks that only require valid credentials and no further vulnerabilities. To exploit this vulnerability, attackers only need to be able to modify the contents of the boot flash or those of any attached USB storage device. There are several ways to achieve this and each system might require a different, but similar approach: - Use physical access to program the device’s boot SSD - U

Severity from
GitHub (reviewed advisory)

More Google advisories

All Google
Advisory
Linux Kernel: Out of bounds Read in ksmbd_vfs_stream_read
Critical9.1Jan 9, 2025
Apple: WebKit Canvas Denoising
MediumDec 26, 2024
MacPorts: Remote Code Execution
MediumDec 23, 2024
KVM: Out-Of-Bounds Read in nested_svm_get_tpd_pdptr
MediumDec 9, 2024
Linux Kernel: TOCTOU in Exec System
MediumDec 2, 2024
ION Group: Account Takeover
CriticalNov 11, 2024

Critical advisories by email

Wednesdays: the week’s critical and high advisories in the AI and data stack, with the fixed versions. Only in weeks that have some.

Double opt-in. Unsubscribe any time.