Lion Cipher Lab
Guarantee a read-only root filesystem's integrity with dm-verity
- Cyber / Security Engineer
- Advanced
- ~70 min
- Free · no account required
Why it matters
Encryption gets all the attention, but a huge class of real attacks never touches your secrets — it changes your system. A rootkit in a system binary, a poisoned shared library, a backdoored init script: none of that is a confidentiality breach, it's an INTEGRITY breach, and encryption alone does nothing to stop it. dm-verity is the Linux answer, and it's not a niche tool — it is the mechanism underneath Android Verified Boot and ChromeOS, guaranteeing that the system partition on billions of devices is byte-for-byte what the vendor shipped. The idea is beautiful and worth internalizing by…
What you'll learn
- what a Merkle (hash) tree is and how dm-verity uses one to verify a whole device from a single root hash
- building a throwaway ext4 filesystem image in a plain file and attaching it with a loop device
- generating a verity hash tree with `veritysetup format` and capturing the ROOT HASH it prints
- opening a verified device-mapper device with `veritysetup open` and mounting it read-only
- proving the integrity guarantee by TAMPERING one byte with dd and watching the read fail with an I/O error
- reading the `dm-verity: ... corruption` message in dmesg and knowing exactly what it means
- why the root hash is the entire trust anchor, and why an UNSIGNED root hash is recomputable by an attacker
- the integrity-vs-confidentiality distinction: verity is not encryption, and how it pairs with dm-crypt/LUKS
- corruption policy modes (I/O error vs restart vs panic) and where each belongs
- where verity actually lives in the real world: Android Verified Boot, ChromeOS, immutable/ostree distros, signed container base images
Steps in this lab
- What dm-verity actually is: a Merkle tree over a read-only device
- Install veritysetup and confirm device-mapper works here
- Build a small read-only ext4 image and populate it
- Format the hash tree and capture the ROOT HASH
- Open the verified device, mount it read-only, and prove normal reads work
- The money shot: tamper one byte and watch the read FAIL
- The root hash is the whole trust anchor (and why unsigned = worthless)
- When NOT to use verity, and the confidentiality gap
- The judgment: what verity really buys, and how a pro ships it