r/archlinux • u/AppointmentNearby161 • 25d ago
SUPPORT Setup for unlocking LUKS with TPM
I know auto unlocking of LUKS based FDE with the TPM is a decisive, lets ignore the dislike and just focus on making it as secure as possible. In particular I want to prevent
https://wiki.archlinux.org/title/Systemd-cryptenroll#Trusted_Platform_Module:
Only binding to PCRs measured pre-boot (PCRs 0-7) opens a vulnerability from rogue operating systems. A rogue partition with metadata copied from the real root filesystem (such as partition UUID) can mimic the original partition. Then, initramfs will attempt to mount the rogue partition as the root filesystem (decryption failure will fall back to password entry), leaving pre-boot PCRs unchanged. The rogue root filesystem with files controlled by an attacker is still able to receive the decryption key for the real root partition. See Brave New Trusted Boot World and BitLocker documentation for additional information.
Using PCR policies seems like the right approach: https://wiki.archlinux.org/title/Trusted_Platform_Module#PCR_policies bu the recommendations seem like a moving target and the discussion page is not reassuring. Is the following a "correct" way to go about TPM based unlocking with a UKI?
/etc/kernel/uki.conf
[UKI]
SecureBootSigningTool=systemd-sbsign
SignKernel=false
SecureBootPrivateKey=
/etc/kernel/secure-boot-private-key.pem
SecureBootCertificate=
/etc/kernel/secure-boot-certificate.pem
PCRPKey=/etc/systemd/tpm2-pcr-public-key-initrd.pem
Splash=/usr/share/systemd/bootctl/splash-arch.bmp
SignInitrdPCRs=yes
[PCRSignature:initrd]
Phases=enter-initrd
PCRPrivateKey=/etc/systemd/tpm2-pcr-private-key-initrd.pem
PCRPublicKey=/etc/systemd/tpm2-pcr-public-key-initrd.pem/etc/kernel/uki.conf
# systemd-cryptenroll --wipe-slot=tpm2 --tpm2-device=auto --tpm2-public-key-policyref=initrd \
--tpm2-public-key=/etc/systemd/tpm2-pcr-public-key-initrd.pem \
/dev/disk/by-designator/root-luks
1
u/archover 25d ago edited 25d ago
I use physical control and a non trivial LUKS passphrase for years, and feel it's not an inconvenience and I'm protected. I am however, thinking about Secure Boot. Laptop used outside the house a lot.
Hope you get some ideas here, and good day.
2
u/Toaster_Strudel_517 25d ago
I'm using both pcr7+15 and pubkey.
2
u/Vannoway 25d ago
This is what I use:
/etc/kernel/uki.conf:/etc/crypttab(thetpm2-measure-pcr=yesis what puts the volume key into PCR 15):You can pin the volume key hash, so the initrd refuses any volume with a different key. After the first boot with the TPM unlock working:
Add
fixate-volume-key=<that hash>to the options in the crypttab line above, then:If you typo the hash the root volume won't attach, so keep a live USB around. Also, this only works with Secure Boot on, since PCR 7 is in the policy.
2
u/Synthetic451 25d ago
I prefer using two separate keys for the different phases but using --tpm2-public-key-policyref is fine as long as systemd is newer than 262. Here's what I use
Then I enroll using this
You should still bind to PCR 7 so that Secure Boot being disabled will immediately prevent TPM from releasing the secrets.
EDIT: I should mention that I use sbctl to sign instead of sbsign, so adjust accordingly.
0
u/bozehaan 25d ago
Why not lock the bios, set the internal drive as only allowed boot disk, require password for different drives. If you're really paranoid about physical access, there's tamper protection stickers you can put over the screws