By Andrea Braschi
Overview
Partition identifiers such as PARTUUID and PARTLABEL are often assumed to be unique, but nothing enforces it. In a two-stage boot process, that assumption can let an attacker get an unverified root filesystem mounted while every integrity check still passes. Andrea Braschi walks through a repeatable QEMU demonstration of the attack against a U-Boot and Linux boot flow, covers single-disk and multi-disk variations, and shows how dm-verity with a signed FIT image mitigates it. The full lab is available on GitHub.
Read Andrea's walkthrough below.
During the various security assessments Anvil has conducted, we have observed a common practice that can result in trusting the wrong partition. A frequent assumption is that partition entry fields such as PARTUUID and PARTLABEL are unique identifiers. While uniqueness is an intended property of these fields, it is not enforced, allowing duplicate values to exist and potentially causing software to trust an unexpected or attacker-controlled partition.
Ordinarily, this does not present a problem. However, in a two-stage boot process where one component verifies the integrity of a partition before handing control to another component that subsequently uses it, this assumption can introduce a security vulnerability. If the two components enumerate partitions differently, the verifying component may validate a different partition than the one ultimately used, even though both components identify the partition using the same PARTUUID or PARTLABEL. An attacker who can create duplicate identifiers may exploit this discrepancy to bypass the intended integrity verification.
In practice, PARTUUID is often a more attractive target because developers frequently assume that a UUID is inherently unique and therefore more trustworthy than a text-based label. Neither PARTUUID nor PARTLABEL is guaranteed to be unique, and both are equally susceptible to this class of attack.
A classic example, and where we observed this issue the most, is the hand over between U-Boot and Linux. U-Boot is a common Linux bootloader. It is the piece of software that runs to load the kernel before everything starts. Loaded by the device's boot ROM, it is in charge of different tasks, and it is used as a core part in the chain of trust to verify the integrity of the boot artifacts.
As shown in the schema below, a possible attack scenario relies exactly on these assumptions. In this scenario, U-Boot locates the root filesystem using the PARTLABEL, verifies its integrity, and then passes the PARTUUID of the resolved partition to the Linux kernel via the kernel command line. Linux subsequently locates and mounts the root filesystem using the supplied PARTUUID. If multiple partitions share the same PARTUUID, Linux selects the first matching partition.
To exploit this behavior, an attacker constructs a partition table containing two partitions with the same PARTUUID. The first partition contains a malicious root filesystem, while the second contains the legitimate, signed root filesystem and is the only partition with the expected PARTLABEL. As a result, U-Boot resolves and verifies the legitimate partition using its PARTLABEL, but Linux resolves the duplicated PARTUUID to the first partition and mounts the attackerโs malicious root filesystem instead.
In this blogpost, we want to provide a repeatable demonstration of this technique and then show possible solutions and mitigations.
Demonstration
All the material shown in this blogpost can be found in Anvil Git Repository.
The test was conducted using QEMU to run two custom Linux builds natively on an arm64 macOS. The two builds were minimal and did nothing other than booting and logging which version is running. Essentially the so-called GOOD or GOLDEN image contained an /etc/rootfs-id file and a /init.sh script that parses the rootfs-id file to log which image has been run (the only difference between the two partitions consists in the output of a startup script that logs which partition is booting, whether it is the GOOD or the EVIL one). On the contrary the so-called EVIL image contained the same /init.sh script but a different rootfs-id. The build environment was set up in a Dockerfile to enhance reproducibility.
In this way via Makefile, it was possible to configure the various virtual machines with the different configurations under analysis, run them and automatically parse their logs to verify which image was loaded.
To keep the example simple and avoid a separate set of issues loading U-Boot environment variables, we embedded the environment and boot scripts into the U-Boot binary:
-
CONFIG_ENV_IS_NOWHEREstops U-Boot from reading an environment from storage, -
CONFIG_ENV_SOURCE_FILEcompiles our environment file, boot command and boot script combined, into the image.
The kernel is loaded as an RSA-signed FIT.
CONFIG_ENV_SOURCE_FILE="partguid" CONFIG_ENV_IS_NOWHERE=y CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_FIT_FULL_CHECK=y CONFIG_RSA=y CONFIG_SHA256=y CONFIG_CMD_HASH=y CONFIG_HASH=y # CONFIG_USE_BOOTCOMMAND is not set
The two parts of that environment that matter for this demonstration are the rootfs verification and the hand-off to Linux:
verify_rootfs=
part number virtio ${bootdev} ${rootname} rootpart;
part start virtio ${bootdev} ${rootpart} rootstart;
part size virtio ${bootdev} ${rootpart} rootblocks;
setexpr rootbytes ${rootblocks} * 0x200;
virtio device ${bootdev};
virtio read ${rootbuf_addr} ${rootstart} ${rootblocks};
hash sha256 ${rootbuf_addr} ${rootbytes} vhash;
if test "${vhash}" = "${goodhash}"; then
echo " U-Boot: ROOTFS VERIFIED OK";
else
echo " U-Boot: ROOTFS VERIFICATION FAILED -> refusing to boot";
reset;
fi
setup_bootargs=
part uuid virtio ${bootdev}:${rootpart} rootuuid;
setenv rootspec PARTUUID=${rootuuid};
setenv bootargs "console=${console} root=${rootspec} rootfstype=ext4 rootwait rw init=/sbin/init panic=-1";
U-Boot locates the partition by name and hashes the whole partition, not a single file, comparing the digest with the golden one. If they match it derives root= from the PARTUUID of the very partition it just verified and boots the signed kernel. The variable rootname is set to rootfs by the build script.
For brevity the golden hash is hardcoded in the U-Boot environment. A production device would instead keep a public key in the bootloader or in OTP/eFuse and use it to verify a signature over that hash.
The following demonstrates the issue. If we have a system with only the GOOD partition, it boots properly and the system logs to be running on the GOOD partition. While, if the system has only the EVIL, it wonโt boot and logs the error. However, when the system has both the partitions accessible, it boots but mounts the EVIL partition. And this happens because the partitions have the same PARTUUID and the boot script parses them in a different order from the one used by Linux once starting.
Baseline: Boot with only the GOOD partition [ACCEPTED]
U-Boot booted from virtio 0 (the medium carrying the boot slot) Partition Map for virtio device 0 -- Partition Type: EFI 1 0x00000800 0x000107ff "spare" โ filler: keeps all three images geometrically identical guid: aaaaaaaa-1111-2222-3333-444444444444 2 0x00010800 0x000507ff "boot" 3 0x00050800 0x000607ff "rootfs" guid: 11111111-2222-3333-4444-555555555555 โ one partition, one PARTUUID --- verify_image: hash the WHOLE partition named rootfs on virtio 0 --- U-Boot: rootfs(name=rootfs, virtio 0:0x3) sha256 = b2854cbe7eb432b7a57504edfc26d1f25b63db315acdb066e8e3264f22229759 U-Boot: ROOTFS VERIFIED OK -> U-Boot TRUSTS rootfs on virtio 0:0x3 [...] [ 0.404118] EXT4-fs (vda3): mounted filesystem a941861c-6b80-4d08-a69e-b733a61063f0 r/w <- good.img [ 0.484546] VFS: Mounted root (ext4 filesystem) on device 254:3. โ 254:3 = vda3 ######################################################################## # ROOTFS IDENTITY : GOOD (golden, the partition U-Boot intends to validate) # kernel cmdline : console=ttyAMA0 root=PARTUUID=11111111-2222-3333-4444-555555555555 ... ######################################################################## Golden rootfs is running โ the intended partition was mounted this boot.
Baseline: Boot with only the EVIL partition [REFUSED]
U-Boot booted from virtio 0 (the medium carrying the boot slot) Partition Map for virtio device 0 -- Partition Type: EFI 1 0x00000800 0x000107ff "spare" โ filler: keeps all three images geometrically identical guid: aaaaaaaa-1111-2222-3333-444444444444 2 0x00010800 0x000507ff "boot" 3 0x00050800 0x000607ff "rootfs" guid: 11111111-2222-3333-4444-555555555555 โ one partition, one PARTUUID --- verify_image: hash the WHOLE partition named rootfs on virtio 0 --- U-Boot: rootfs(name=rootfs, virtio 0:0x3) sha256 = fa7f201f58eac76a7c63d8794fdf50d16c484263203ee445645b0c2db704e3f8 U-Boot: ROOTFS VERIFICATION FAILED -> refusing to boot resetting ...
Boot with both the partitions [Mounts the EVIL partition]
Partition Map for virtio device 0 -- Partition Type: EFI
1 0x00000800 0x000107ff "rootfs-decoy"
guid: 11111111-2222-3333-4444-555555555555 โ same PARTUUID...
2 0x00010800 0x000507ff "boot"
3 0x00050800 0x000607ff "rootfs"
guid: 11111111-2222-3333-4444-555555555555 โ ...on two partitions
[...]
U-Boot: rootfs(name=rootfs, virtio 0:0x3) sha256 = b2854cbe7eb432b7a57504edfc26d1f25b63db315acdb066e8e3264f22229759
U-Boot: ROOTFS VERIFIED OK -> U-Boot TRUSTS rootfs on virtio 0:0x3 โ golden hash: it verifies p3
[...]
[ 0.408044] EXT4-fs (vda1): mounted filesystem ac19e604-acbd-4091-a6fe-c9681f77610d r/w โ evil.img!
[ 0.365124] VFS: Mounted root (ext4 filesystem) on device 254:1. โ 254:1 = vda1
########################################################################
# ROOTFS IDENTITY : EVIL (attacker-controlled, reachable only via PARTUUID confusion)
# kernel cmdline : console=ttyAMA0 root=PARTUUID=11111111-2222-3333-4444-555555555555 ...
########################################################################
*** ROOTFS VERIFICATION BYPASSED VIA PARTITION-ID CONFUSION ***
U-Boot verified the rootfs it selected BY NAME ('rootfs'), and that
check passed on the GOLDEN partition. Yet THIS partition is running:
Linux re-resolved the root identifier (PARTUUID/PARTLABEL) to a
different, attacker-controlled partition. The verified partition and
the mounted partition are not the same one.
Variations
The same confusion applies when the root filesystem is located by label rather than by UUID. On a single disk the attack does not work: U-Boot and Linux both pick the first partition named rootfs, so they agree and the verification catches the malicious copy. Making the two disagree requires a second disk.
Instead, on a multi-disk scenario the bug would be repeated successfully. Indeed, the external disk with the evil partition has no boot slots and thus is ignored by U-Boot. But it is the first one considered by the Linux Kernel. A multi-disk scenario is a more realistic attack scenario where an attacker plugs a USB stick (or SD card) into the target device and reboots it, getting their rootfs partition mounted, then gains access to the device. The experiment demonstrated that the PARTUUID attack also works fine on the multi-disk scenario.
We reused the same U-Boot configuration and changed only how root is expressed:
setup_bootargs=
setenv rootspec PARTLABEL=${rootname};
The main difference lies in line 20 where the rootfs partition is identified by PARTLABEL.
The snippet below shows the output of the partlabel target, with a summary table showing the results obtained.
Baseline multi-disk: only the internal disk with good partition [ACCEPTED]
U-Boot booted from virtio 0 (the medium carrying the boot slot) โ a single disk โ virtio 0 Partition Map for virtio device 0 -- Partition Type: EFI 1 0x00000800 0x000107ff "rootfs" 2 0x00010800 0x000507ff "boot" U-Boot: rootfs(name=rootfs, virtio 0:0x1) sha256 = b2854cbe7eb432b7a57504edfc26d1f25b63db315acdb066e8e3264f22229759 U-Boot: ROOTFS VERIFIED OK -> U-Boot TRUSTS rootfs on virtio 0:0x1 [...] [ 0.250829] virtio_blk virtio0: [vda] 458752 512-byte logical blocks (235 MB/224 MiB) [ 0.260746] vda: vda1 vda2 โ the internal disk, on its own [ 0.399360] EXT4-fs (vda1): mounted filesystem a941861c-6b80-4d08-a69e-b733a61063f0 r/w # ROOTFS IDENTITY : GOOD Golden rootfs is running โ the intended partition was mounted this boot.
Baseline multi-disk: only the internal disk with the EVIL partition [REFUSED]
U-Boot booted from virtio 0 (the medium carrying the boot slot) Partition Map for virtio device 0 -- Partition Type: EFI 1 0x00000800 0x000107ff "rootfs" 2 0x00010800 0x000507ff "boot" U-Boot: rootfs(name=rootfs, virtio 0:0x1) sha256 = fa7f201f58eac76a7c63d8794fdf50d16c484263203ee445645b0c2db704e3f8 U-Boot: ROOTFS VERIFICATION FAILED -> refusing to boot resetting ...
Both disks connected: multi-disk PARTLABEL bypass [Mounting EVIL partition]
Hit any key to stop autoboot: 2 1 0 ** Invalid partition 2 ** โ virtio 0 (the USB) has no boot slot Couldn't find partition virtio 0:2 Can't set block device U-Boot booted from virtio 0 (the medium carrying the boot slot) Partition Map for virtio device 0 -- Partition Type: EFI 1 0x00000800 0x000107ff "rootfs" guid: 1c464bad-abb6-40f5-9d83-5e7183cbcbaa โ same PARTLABEL, different PARTUUID U-Boot: no signed /kernel.itb in slot boot on virtio 0 -- trying next slot ## Executing script at 40200000 ================================================================== U-Boot booted from virtio 1 (the medium carrying the boot slot) Partition Map for virtio device 1 -- Partition Type: EFI Part Start LBA End LBA Name 1 0x00000800 0x000107ff "rootfs" โ golden (internal disk) 2 0x00010800 0x000507ff "boot" โ boot slot --- load_kernel (signed FIT /kernel.itb from boot slot boot on virtio 1) --- --- verify_image: hash the WHOLE partition named rootfs on virtio 1 --- sha256 for 48000000 ... 49ffffff ==> b2854cbe7eb432b7a57504edfc26d1f25b63db315acdb066e8e3264f22229759 U-Boot: ROOTFS VERIFIED OK -> U-Boot TRUSTS rootfs on virtio 1:0x1 --- setup_bootargs: Linux will locate root BY PARTLABEL=rootfs --- ================================================================== [...] [ 0.263113] virtio_blk virtio0: [vda] 131072 512-byte logical blocks (67.1 MB/64.0 MiB) [ 0.274033] vda: vda1 โ 64 MiB, 1 partition = the attacker USB [ 0.278495] virtio_blk virtio1: [vdb] 458752 512-byte logical blocks (235 MB/224 MiB) [ 0.280684] vdb: vdb1 vdb2 โ 224 MiB, 2 partitions = the internal disk [...] [ 0.393400] EXT4-fs (vda1): mounted filesystem ac19e604-acbd-4091-a6fe-c9681f77610d r/w [ 0.391756] VFS: Mounted root (ext4 filesystem) on device 254:1. # ROOTFS IDENTITY : EVIL *** ROOTFS VERIFICATION BYPASSED VIA PARTITION-ID CONFUSION ***
In this blogpost, for the sake of readability, we have shown only a few of the scenarios we covered. The public repository contains the full matrix, including the single-disk PARTLABEL case, where the two resolvers agree and U-Boot correctly refuses to boot, and the dm-verity mitigation. The experiments are driven by a Makefile: make experiments builds each disk layout, boots it under QEMU, and programmatically asserts the expected outcome against the boot log.
Mitigations
To avoid these scenarios there are different possible mitigations, the simplest could be to use a RAM disk for the rootfs and make sure to load and then verify it in RAM and then boot from the RAM disk. All components, loading, verifying, booting uses the same data, mitigating this issue.
A more robust solution is to use dm-verity to provide integrity protection for the root filesystem. dm-verity is a Linux device-mapper target that verifies a read-only block device as it is read. The image is split into fixed-size blocks, each hashed at build time, and those hashes are hashed in turn to form a Merkle tree stored alongside the filesystem. The kernel checks every block against the tree on each read.
The root hash is the top of that tree. Every block contributes to it, so any change to the filesystem changes it. To establish trust in the filesystem, the dm-verity root hash must be authenticated. One way to authenticate the root hash within a U-Boot boot flow is to embed the root hash within a signed FIT image and rely on U-Bootโs built-in FIT image signature verification. In addition to the Linux kernel, a FIT image can contain other boot artifacts, such as the kernel command line, allowing the authenticated dm-verity root hash to be passed to the kernel at boot time. The diagram below illustrates this process.
Because the root hash is authenticated before the kernel boots, the kernel can verify every block read from the root filesystem. A malicious partition with the same PARTUUID or PARTLABEL will not produce the expected hash tree, causing dm-verity to detect the tampering and prevent the filesystem from being trusted.
Conclusion
Partition identifiers such as PARTUUID and PARTLABEL are not unique by construction, and nothing in the GPT specification enforces that they are. When one component verifies a partition and another re-resolves the same identifier to decide what to mount, the two can legitimately disagree. An attacker who adds a partition with a colliding identifier turns that disagreement into unsigned code running as root while every signature check still reports success.
The defense is to stop treating an identifier as proof of identity: bind the integrity of the root filesystem to its content with dm-verity and anchor the root hash in an artifact that is itself signed.
The whole code used in this lab is hosted in Anvil Git Repository and the experiments make target runs all the experiments; execution logs are saved in the results/ folder, and the snippet below shows the output of the experiment summary table with all the results.
% make experiments scripts/experiments.sh [exp] rootfs ground-truth UUIDs: good.img = a941861c-6b80-4d08-a69e-b733a61063f0 evil.img = ac19e604-acbd-4091-a6fe-c9681f77610d ########## BASELINE (verification accepts good, rejects evil) ########## ########## PARTUUID (duplicate-PARTUUID bypass) ########## ########## PARTLABEL (caught single-disk, bypassed multi-disk) ########## ########## DM-VERITY (root hash anchored in a signed FIT) ########## ==================== EXPERIMENT SUMMARY ==================== BASELINE [OK] 1. good-only boots (GOOD) [OK] 2. evil-only refused (no boot) [OK] 5. multi-disk internal-only boots (GOOD) [OK] 6. multi-disk internal-evil refused (no boot) PARTUUID [OK] 3. PARTUUID single-disk bypass (EVIL) [OK] 7. PARTUUID multi-disk bypass (EVIL) PARTLABEL [OK] 4. PARTLABEL single-disk: U-Boot catches it (no boot) [OK] 8. PARTLABEL multi-disk bypass (EVIL) DM-VERITY [OK] verity-signed good (rsa OK + GOOD boots) [OK] verity-signed / PARTUUID: evil blocked (panic) [OK] verity-signed / tampered FIT refused =========================================================== [exp] ALL ROWS MATCHED EXPECTATIONS
About the Author
Andrea Braschi is a Senior Security Engineer at Anvil Secure with over a decade of experience in offensive security. He is a passionate programmer with a strong interest in emerging technologies, especially large language models (LLMs) and their applications in cybersecurity.
Over the past few years, Andrea has focused on exploring how LLMs can support and enhance offensive testing workflows. This work led to the creation of ByteBanter, an open-source BurpSuite plugin that integrates LLMs for automated payload generation.



