OGOPSEC Brand Mark
OGOPSECOBSIDIAN GOOSE

OGOPSEC // Dispatch

Evil Maid Attacks on Linux and How to Reduce the Risk

By Jamie Folsom ·

The evil maid attack on Linux is not about theft — it is about a device that leaves your sight and comes back. The name comes from the hotel scenario: you leave an encrypted laptop in the room, a "maid" with brief physical access tampers with the boot path, and when you return and type your passphrase, the tampered code captures it. The next time the device is unattended, the attacker collects the key. Full-disk encryption alone does not stop this, because the attack targets the unlocking step, not the ciphertext.

This is a harder threat than opportunistic theft, and no defense is absolute. The goal is to make tampering detectable and expensive rather than invisible and cheap.

How the attack works

On a typical encrypted Linux laptop, the disk is encrypted but something must run unencrypted to ask for the passphrase — historically the /boot partition and the bootloader. The classic evil maid steps are:

  1. Gain brief physical access to the powered-off machine.
  2. Modify the bootloader or initramfs to log the passphrase, or boot a malicious image.
  3. Leave. The victim returns, boots, and enters the passphrase, which is now recorded.
  4. Regain access later and retrieve the captured key, or exfiltrate it.

Variants attack firmware or hardware directly, but the boot-path version is the most accessible and the one most defenses target.

Defense 1: Measured boot with the TPM

A TPM 2.0 can measure each stage of boot into Platform Configuration Registers (PCRs). If the bootloader, kernel, or initramfs changes, the measurements change. You can seal a secret to a known-good set of PCR values so that it only unseals when boot has not been tampered with. If an evil maid alters the boot path, the measurements no longer match and the sealed secret stays locked — turning a silent compromise into a visible failure.

# Inspect current PCR values (requires tpm2-tools)
tpm2_pcrread sha256

# Systems using systemd can enroll a TPM-sealed LUKS key:
sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/nvme0n1p3

Honest limit: PCR policy is fragile — legitimate firmware or kernel updates change measurements and will lock you out until you re-enroll, so always keep a passphrase fallback. And measured boot detects boot-path tampering, not every hardware implant.

Defense 2: Secure Boot and signed boot components

Secure Boot makes the firmware refuse to run boot code that is not signed by a trusted key. Combined with your own signing (enrolling a Machine Owner Key), it raises the cost of substituting a malicious bootloader. It is not a complete answer — signed components can still contain bugs, and firmware-level attacks sit below it — but it closes the easiest substitution path.

Defense 3: Shrink the unencrypted surface

The less that runs unencrypted before unlock, the less there is to tamper with. Options include encrypting /boot itself (GRUB can unlock a LUKS /boot), or keeping the bootloader and keys on a small USB device you carry, so the laptop left in the room has no boot path to poison. Carrying the boot medium is a genuinely strong mitigation because the attacker never has the piece they need to modify.

Defense 4: Tamper-evidence and firmware passwords

  • Set a firmware/UEFI password so boot order and settings cannot be changed silently.
  • Use tamper-evident seals on case screws; they will not stop an attacker but they make intrusion visible.
  • Note hardware details (screw torque, sticker placement) so you notice disturbance.

These are low-tech, but the evil maid relies on leaving no trace. Anything that forces a trace helps.

What reducing evil-maid risk does and doesn't buy you

Measured boot, Secure Boot, a carried boot medium, and firmware locks together make the boot-path evil maid attack detectable and costly, which for most people is enough to deter it. They do not defend against a well-resourced attacker who replaces hardware, implants the keyboard, or attacks firmware below your controls, and they do nothing if you ignore a failed measurement and type your passphrase anyway. The discipline — investigate unexpected unlock failures instead of forcing past them — is as important as the technology.

Where hardware binding helps

Tying authentication and your encrypted home to a device you physically carry is one of the more practical evil-maid mitigations, because the secret is never left with the machine. That hardware-binding model is what Dire Wolf is built around — TPM-bound, fail-closed, key-in-your-pocket. Keep its scope in mind: it binds login and encrypts your home directory, and you still want measured boot and a passphrase fallback for the boot-path guarantees described above. Make tampering visible, keep the key with you, and never unlock a machine that is behaving strangely.