OGOPSEC Brand Mark
OGOPSECOBSIDIAN GOOSE

OGOPSEC // Dispatch

Measured Boot and the TPM: Detecting Tampering on Linux

By Jamie Folsom ·

There is a difference between stopping a boot and noticing that one was tampered with. Secure Boot tries to do the former by refusing unsigned components. Measured boot does the latter: it lets everything run but records a fingerprint of each stage, so that afterward you can tell whether the chain was exactly what you expected. TPM measured boot on Linux is the quiet, honest half of boot integrity — it does not block, it testifies.

The value is subtle but real. If you can prove the system booted through a known-good sequence, you can make secrets conditional on that proof. If you cannot, you at least learn that something changed before you type a passphrase into it.

How measuring works

Each component in the boot chain — firmware, bootloader, kernel, initramfs, configuration — is hashed before control passes to it. That hash is "extended" into a Platform Configuration Register in the TPM. Extending is not overwriting: the new value is the hash of the old value concatenated with the new measurement, so the PCR becomes a running summary of everything measured, in order. Change any step, or reorder them, and the final PCR value differs.

# Read the current PCR bank
sudo tpm2_pcrread sha256

# The UEFI event log explains what each measurement was
sudo tpm2_eventlog /sys/kernel/security/tpm0/binary_bios_measurements

The event log is the Rosetta Stone here: it lists, in human terms, what was measured into each PCR, so an unexpected value is something you can actually investigate rather than just distrust.

Turning measurement into enforcement: sealing

Measuring by itself only produces numbers. The protection appears when you seal a secret to a set of PCR values. The TPM will then only unseal that secret if the registers currently hold the sealed values — meaning the system booted the way it did when you sealed.

  • Seal a LUKS key to the PCRs covering firmware and bootloader, and the disk unlocks automatically only on an untampered boot path.
  • Tamper with the bootloader and the PCRs no longer match, so the key is withheld and you fall back to a passphrase — the tampering turned into a visible failure instead of a silent compromise.

Systemd exposes this directly, which makes it approachable:

# Bind a LUKS keyslot to TPM PCRs 0 and 7
sudo systemd-cryptenroll --tpm2-device=auto \
  --tpm2-pcrs=0+7 /dev/nvme0n1p3

What measured boot catches

  • A modified bootloader or kernel image — the hash changes, the PCR changes.
  • An inserted boot component or an "evil maid" bootkit that alters the early chain.
  • Rollback of a boot component to a vulnerable version, if that component is measured.

What it does not catch

This is where restraint matters. Measured boot attests to the boot path, and only to what is actually measured. It says nothing about what happens after the last measurement — userspace malware, a malicious package installed later, or a compromised application all run on a perfectly "good" set of PCRs. Choosing which PCRs to seal against is a genuine tradeoff: seal to too many and every legitimate firmware update breaks unlocking; seal to too few and you narrow what tampering you can detect. And measured boot does not stop the boot; it only makes tampering detectable, so you still need the policy — like withholding a key — that turns detection into consequence. On a firmware TPM, the measurements are only as trustworthy as the firmware doing the measuring.

Measured boot is a witness, not a guard. It can tell you the room was entered; it is up to your sealing policy to decide the door stays locked when it was.

A sane place to start

You do not need to seal anything to benefit on day one. Read your PCRs and your event log, note the normal values, and reboot after a kernel or firmware update to watch which registers move and why. Once the numbers are familiar, sealing a disk key to a small, stable PCR set is a reasonable next step — with a passphrase fallback always configured, because a legitimate update will eventually change the measurements.

At OGOPSEC we lean on measured-boot primitives as part of a tamper-aware posture rather than as a standalone promise, and Dire Wolf's TPM binding assumes the same honest framing: detection plus a fail-closed response, never the claim that an attacker was prevented from ever touching the machine. The chip remembers what happened. Your policy decides what that memory is worth.