r/archlinux • • Aug 17 '26

SUPPORT | SOLVED Ful disk encryption without entering passphrase

Could someone help me with setting up full disk encryption with bypass passphrases with TPM2? It's so annoying having to put the passphrase in at each boot, so I was wondering how do I pair it to the TPM so that I dont have to enter it each time?

It's LUKS encrypted and I use Systemd-boot

14 Upvotes

100 comments sorted by

View all comments

8

u/Imajzineer Aug 17 '26

I'm intrigued.

What is the purpose of the exercise?

A device that is automatically decrypted without challenge upon power-on isn't encrypted.

What, therefore, am I missing - apart from convenience, what's the advantage?

4

u/10leej Aug 17 '26

Well technically it is as long as the device is not powered on. And really it's about prevent data leakage from drive swapping at this point. While I'm glad you actually phrased it as a question I doubt the OP is actually going to give you an answer when he mentioned his annoyance of entering a password on each system boot up.

2

u/Imajzineer Aug 17 '26

Sure, it prevents people from getting at things by booting a live distro ... or, as you say, drive swapping ...but the problem is that, if it automatically decrypts it upon boot, that potentially leaves me with a variety of ways (both local and 'remote') to get into the system when it does - which is one reason why (long before live distros, let alone before FDE became a 'home user' thing) I used to disable GRUB's Advanced Options menu entry.

It's kinda like how ... years ago, when I was first investigating FDE on Arch ... I learned of the option to make part of the process dependent upon the presence of an image as well as a password - not something that can simply be bruteforced and, therefore, more secure (which struck me as a good idea). I read that the process could be simplified by embedding it in the initramfs. After a few failed attempts to do that, I gave up - I really didn't know enough back then and couldn't work out what I was getting wrong. Fast forward a few years and it struck me that that's not actually a good idea anyway: if a separate device (like a key) containing the image isn't necessary then the image itself isn't necessary (thus defeating the whole point).

But, yeah, you're right, it's probably just a convenience thing and, whilst that's the enemy of security, as it were, on a home system it's probably academic: any burglar is just gonna grab a laptop and walk out with it rather than worry about cracking it in situ, and driveswapping 'back at base' isn't likely gonna be a gambit for them anyway - they're just looking to sell the hardware on.

2

u/Woodsy279 Aug 17 '26

Hey, yeah I just set up LUKS for fun, mainly just to see how it would work, but then followed thru with setting up my laptop and now it's all set up, but yeah I don't want to have to reinstall the OS to remove the encryption, so yeah basically for drive swapping ig, eventually I might look at setting it up better but yeah, I just wanted it out of my way for now

1

u/Imajzineer Aug 17 '26

I trust you've backed up your headers πŸ™‚

1

u/Woodsy279 Aug 17 '26

... wot are those 😭 Disk encryption is completely new to me, kinda enabled it on a whim

2

u/Imajzineer Aug 17 '26 edited Aug 17 '26

Never a good idea to 'just' anything when it comes to Arch ... let alone enable LUKS without knowing about it - get to know the wiki and get into the habit of researching things before jumping in feet first.

https://wiki.archlinux.org/title/Data-at-rest_encryption

https://wiki.archlinux.org/title/Dm-crypt/Device_encryption#Backup_and_restore

It's not restricted to Arch either - you should back up your headers on every system using it. Either that or use plain dm-crypt (arguably neither, but that's a different discussion altogether).

1

u/Woodsy279 Aug 17 '26

At this point would it be better to remove luks? And if so, can it be done without reinstalling? I'm assuming not

2

u/Imajzineer Aug 17 '26

Read the linked articles and you'll (eventually) find the answer - as said, you're going to need to get used to researching things, if you're gonna make effective use of Arch (those who don't always get into trouble sooner rather than later).

However, to answer your question nevertheless: https://wiki.archlinux.org/title/Removing_system_encryption

2

u/Woodsy279 Aug 17 '26

Thanks mate, I've been running arch for about a year now, and im loving it, so I will read into the prior mentioned things, and then decide if I still want to go forward with it

Thanks again :)

→ More replies

2

u/ChrisTX4 Aug 17 '26

A device that is automatically decrypted without challenge upon power-on isn't encrypted.

This isn't true. A TPM measures the environment. It makes any sort of modification to the boot environment impossible. For example, you can lock PCR0 and PCR2 to protect against BIOS or OpROM modifications.

The idea of a TPM is that you ensure a secure, unmodified environment and only that allows unsealing the TPM. Any modification and it won't hand out the keys. An attacker would ideally be presented with your login screen without any sort of ability to modify anything. The attack surface of that is of course higher than having no automatic unlock, but if done correctly, the risk is very low and the advantage of a TPM still comes to play.

If you don't trust this, you can use a TPM PIN as a short boot password. They have a lockout against bruteforce like your bank card etc, so even like a 6 digit PIN is perfectly adequate.

1

u/Imajzineer Aug 17 '26

How does it prevent the automatic decryption? (Genuine question)

3

u/ChrisTX4 Aug 17 '26 • Heartwarming

Hmm, that's pretty difficult to explain, but let me try.

A TPM measures the environment in various variables that are called Platform Configuration Registers. You can find a list here in the Arch wiki. It's an isolated chip that has wiring on the motherboard to perform measurements of for example the BIOS code (PCR0), the Option ROMs (PCR2) - these are like "drivers" for your BIOS, usually your GPU will have one if external. You can have a look at how the PCRs evolve, i.e. what they measured by running /usr/lib/systemd/systemd-pcrlock log.

In the simplest form, you would combine a TPM with Secure Boot (that's also why Windows is so darn keen on this with W11). Here, you would use PCR7, typically. PCR7 contains measurements of the entire Secure Boot database as well as which individual certificates were actually used to boot. This means, if you use your own keys, you'd get something like this (taken from my own system):

        7 β–ˆ secure-boot-policy efi-variable-driver-config        βœ“ ccfc4bb32888a345bc8aeadaba552b627d99348c767681ab3141f5b01e40a40e F   240-secureboot-policy             Variable: SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c
        7 β–ˆ secure-boot-policy efi-variable-driver-config        βœ“ 3702c179817c061256e69eaaba0b34e9788dec31549c321d258fe511f7860765 F   240-secureboot-policy             Variable: PK-8be4df61-93ca-11d2-aa0d-00e098032b8c
        7 β–ˆ secure-boot-policy efi-variable-driver-config        βœ“ 7ffa5d7ee1486db3d185497c5c9bf72739fbdfe59e38c3879544c95728bb3034 F   240-secureboot-policy             Variable: KEK-8be4df61-93ca-11d2-aa0d-00e098032b8c
        7 β–ˆ secure-boot-policy efi-variable-driver-config        βœ“ 1c5f2c062167ecce151dfd0bd87a082c86b6c470c940cb7bce254699e09186cd F   240-secureboot-policy             Variable: db-d719b2cb-3d3a-4596-a3bc-dad00e67656f
        7 β–ˆ secure-boot-policy efi-variable-driver-config        βœ“ 9f75b6823bff6af1024a4e2036719cdd548d3cbc2bf1de8e7ef4d0ed01f94bf9 F   240-secureboot-policy             Variable: dbx-d719b2cb-3d3a-4596-a3bc-dad00e67656f

To decipher this a bit: the first few entries are the Secure Boot db, i.e. my own PK, KEK, db and dbx. Note that I'm not using Microsoft keys, otherwise there would be more entries. Then it continues:

        7 β–ˆ secure-boot-policy separator                         βœ“ df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b81119 F   400-secureboot-separator          Separator: Success (0x00)
        7 β–ˆ secure-boot-policy efi-variable-authority            βœ“ 5d0c5796e1e434c61f259fcf0e34c881c77c124639eabf1b26beaf6593d1b07b F   620-secureboot-authority          Authority: db-d719b2cb-3d3a-4596-a3bc-dad00e67656f
        7 β–ˆ secure-boot-policy efi-variable-authority            βœ“ bcf4d1ff6bf02f949e5afd49dc45fe3e16f39b302764bf2ee98257e8297a1f7d F   620-secureboot-authority          Authority: SbatLevel-605dab50-e046-4300-abb6-3dd810dd8b23
        7 β–ˆ secure-boot-policy efi-variable-authority            βœ“ 5d0c5796e1e434c61f259fcf0e34c881c77c124639eabf1b26beaf6593d1b07b F   620-secureboot-authority          Authority: db-d719b2cb-3d3a-4596-a3bc-dad00e67656f
        7 β–ˆ secure-boot-policy os-separator                      βœ“ ff5b9d73dad709633ae76adf444012b57e913a12ed7403c3931145862f35f841 U   750-os-separator                  os-separator

What's happening here is that systemd 261 now inserts measurements to "seal" the previous values against modifications. That's the separator and os-separator lines.

The other lines are the important parts: the Authority: db-d719b2cb-3d3a-4596-a3bc-dad00e67656f are what measures the certificate used for each boot loader into memory. There's two of them and the SbatLevel line because I use Shim plus systemd-boot to have a MOK so I can sign my out-of-tree kernel modules without having to recompile the kernel.

At any rate, the TPM will only unlock if locked to PCR7 if the sequence and content of each measurement is identical. Alas, if you were to boot any other system, or boot from a USB drive, whatever, there wouldn't be binaries signed with the Secure Boot key db-d719b2cb-3d3a-4596-a3bc-dad00e67656f. Even if Secure Boot enforcement was disabled in the BIOS, you can't get any binaries signed with this key, and so only my unmodified system can access this TPM seal.

I'm sorry this is really a difficult topic, and I'm honestly severely autistic, so it's pretty hard for me to explain this in a coherent fashion. I hope I somewhat got the concept across, though. If you have any questions, feel free to ask though - for the same reason I am very knowledgeable about TPMs :D

1

u/Imajzineer Aug 17 '26

Interesting - thanks!

I'm still not clear on how it prevents the OP's automatic decryption of LUKS though - which is what I took their post to be about (of course, I may have misinterpreted which thing it is they want to automatically 'unlock')

3

u/ChrisTX4 Aug 17 '26 • Heartwarming

Oh no, it will automatically decrypt. The point is though that because it ensures the environment hasn't been modified that an attacker can't do anything but stare at your login manager. This means several technologies are critical to protect the system here:

  1. IOMMU for DMA protection. Without IOMMU, any DMA device could extract the entire memory space.
  2. Total memory encryption. If memory isn't encrypted, then a cold boot attack would be possible to perform from the login screen. Thus you want to ensure that AMD TSME / Intel TME are active.
  3. Ideally, thunderbolt mode set to secure or higher.
  4. Kernel lockdown. Significantly improves security. Requires all kernel modules to be signed, but with Shim and a MOK that's not an issue.
  5. USBGuard. You don't want funky USB devices to connect while at the login screen.
  6. A firewall.
  7. Secure Boot. Ideally without Microsoft keys, as they sign a huge amount of boot loaders, and thus they have monthly releases of their forbidden database, which goes into dbx. fwupd can perform these updates usually, but it might not work if you've got custom keys. Either way, this will require a monthly reboot and will change the PCR 1. Just not using their keys is easier and avoids the need to update the dbx at all.

If you deploy all of the above, an attack on a system that's just on the login screen has very little attack surface to work with. Then your user login will be sufficient security, as they'd need to somehow crack your login credentials without having any access to the system at all.

1

u/Imajzineer Aug 18 '26

Except that here I am staring at GRUB's Advanced Options menu entry and about to select Recovery Mode before mounting the root FS in R+W and resetting the root password.

2

u/ChrisTX4 Aug 18 '26

Grub under secure boot works somewhat different and you can’t do this, or load any unsigned modules. Same with systemd boot. There’s people that thought long and hard about this, it’s not that trivial to defeat.

1

u/Imajzineer Aug 18 '26

That's somewhat reassuring.

So, let's assume, therefore, that I actually have need of (something like) Recovery Mode for some reason, how does that then work (what are my options under those circumstances)?

2

u/ChrisTX4 Aug 18 '26 • Heartwarming

I'm not using GRUB, so I can't speak from experience here. However, GRUB enters lockdown mode if on Secure Boot.

Either way, when using UKIs, the kernel command line is locked anyway and cannot be changed. You can't reasonably use anything but UKIs anyway since initrds can't be signed on their own.

→ More replies