Skip to content

Commit ca40eaa

Browse files
committed
LUKS related docs: make sure verbiage is consistent, unify format
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
1 parent 53889a6 commit ca40eaa

File tree

3 files changed

+116
-113
lines changed

3 files changed

+116
-113
lines changed

About/Keys.md

Lines changed: 114 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ nav_order: 4
66
parent: About
77
---
88

9-
Keys and passwords in Heads
10-
====
9+
# Keys and passwords in Heads
1110

12-
There are "too many secrets" involved in booting a Heads system. Luckily most
13-
of them are stored in hardware and only a few need to be memorized by the
14-
users. This page attempts to document their usage and the risks if an attacker
15-
can compromise the different keys.
11+
There are "too many secrets" involved in booting a Heads system. Luckily most
12+
of them are stored in hardware and only a few need to be memorized by the
13+
users. This page documents their usage and the risks if an attacker can
14+
compromise the different keys.
1615

1716
<!-- markdownlint-disable MD033 -->
1817
<details open markdown="block">
@@ -25,159 +24,163 @@ There are "too many secrets" involved in booting a Heads system. Luckily most
2524
</details>
2625
<!-- markdownlint-enable MD033 -->
2726

28-
Management Engine and Bootguard ACM fuses
29-
---
27+
## Management Engine and Bootguard ACM fuses
3028

3129
![Bootguard fuses]({{ site.baseurl }}/images/Bootguard_fuses.jpg)
3230

33-
The very first key used in the system is Intel's public key that signs the
34-
Management Engine firmware partition table in the SPI flash. This key is
35-
stored in the on-die ROM of the ME and the ME will not start up if this
36-
signature does not match. An attacker who controls this key (which is highly
37-
unlikely) can subvert the Bootguard checks as well as the measured boot
38-
process.
39-
40-
The [Bootguard fuses](https://trmm.net/Bootguard) fuses provide protection
41-
against most "evil maid" attacks against the firmware. The hash of the ACM
42-
signing key is set in write-once fuses in the CPU chipset and during the CPU
43-
bringup phase the ME and the CPU microcode cooperate in some undocumented way
44-
to validate the "Startup ACM" in the SPI flash. Since this key is fused into
45-
hardware, an evil maid attack would need to replace the CPU to install
46-
malicious firmware into the SPI flash. The x230 Thinkpads do not support
47-
bootguard and only the Librem laptops ship with unfused keys.
31+
The first key used is Intel's public key that signs the Management Engine
32+
firmware partition table in the SPI flash. This key is stored in the on-die ROM
33+
of the ME and the ME will not start up if this signature does not match. An
34+
attacker who controls this key (highly unlikely) can subvert the Bootguard
35+
checks and the measured boot process.
36+
37+
The [Bootguard fuses](https://trmm.net/Bootguard) provide protection against
38+
most "evil maid" attacks against the firmware. The hash of the ACM signing key
39+
is set in write-once fuses in the CPU chipset. During CPU bringup, the ME and
40+
the CPU microcode validate the "Startup ACM" in the SPI flash. An evil maid
41+
attack would need to replace the CPU to install malicious firmware into the SPI
42+
flash. The x230 Thinkpads do not support Bootguard and only the Librem laptops
43+
ship with unfused keys.
4844

4945
An attacker who controls this key can flash new firmware via hardware means
50-
(and possibly remotely via software, unless other steps are taken).
46+
(and possibly remotely via software, unless other steps are taken).
5147

52-
TPM Owner password
53-
---
48+
## TPM Owner password
5449

55-
As part of setting up Heads the TPM is "owned" by the user and the owner
56-
password is set. This clears all existing NVRAM and spaces (but does not reset
57-
counters?).
50+
As part of setting up Heads, the TPM is "owned" by the user and the owner
51+
password is set. This clears all existing NVRAM and spaces (but does not reset
52+
counters?).
5853

5954
Are there any consequences of an attacker controlling this key?
6055

61-
TPMTOTP shared secret
62-
---
56+
## TPMTOTP shared secret
6357

6458
![TPMTOTP in use]({{ site.baseurl }}/images/TPMTOTP_in_use.jpg)
6559

66-
Since humans have trouble doing RSA public key cryptography in their brains,
67-
Heads uses [TPM TOTP](https://trmm.net/Tpmtotp) to let the system attest to the
68-
user that the firmware is unmodified. During system setup a random 20-byte
69-
value is generated and shared (via QR code) to the user's phone as well as
70-
sealed with the correct TPM PCR values into the TPM NVRAM. On subsequent boots
71-
the TPM will unseal the secret if and only if the PCRs match, and the computer
72-
then generates a one-time password based on the current clock time, which the
73-
user can compare to the value displayed on their phone. A new secret must be
74-
generated each time the firmware is updated since this will change the PCRs.
60+
Heads uses [TPM TOTP](https://trmm.net/Tpmtotp) to let the system attest to the
61+
user that the firmware is unmodified. During setup, a random 20-byte value is
62+
generated and shared (via QR code) to the user's phone and sealed with the
63+
correct TPM PCR values into the TPM NVRAM. On subsequent boots, the TPM will
64+
unseal the secret if the PCRs match, and the computer generates a one-time
65+
password based on the current clock time, which the user can compare to the
66+
value displayed on their phone. A new secret must be generated each time the
67+
firmware is updated since this will change the PCRs.
7568

7669
If an attacker can control this shared secret (such as by directly sending PCR
77-
values into the TPM) they can install malicious firmware in the SPI flash and
78-
generate valid TOTP codes.
70+
values into the TPM), they can install malicious firmware in the SPI flash and
71+
generate valid TOTP codes.
7972

80-
TPM counter key
81-
---
73+
## TPM counter key
8274

8375
The TPM's increment-only counters can be used to prevent roll-back attacks on
84-
the signed kernel and initramfs configurations. An attacker who controls this
85-
key can increment the counter, causing a denial of service attack against the
86-
system, but it does not provide any access to encrypted data nor any way to
87-
roll back to an old version.
88-
89-
TPM disk encryption key
90-
---
91-
92-
The TPM NVRAM also stores one of the disk encryption keys, which is encrypted
93-
with the user's disk unlock password and sealed with the TPM PCR values for
94-
the firmware and the LUKS headers on the disk. On every boot the user types in
95-
their password and the TPM will unseal and decrypt the disk encryption key if
96-
and only if the firmware is unmodified and the password matches. Since the
97-
TPMTOTP one-time code matched, the user can have confidence that the firmware
98-
is unmodified before they enter their password. If the system is booted in
99-
recovery mode, the PCRs will not match and this key is not accessible to the
100-
user.
76+
the signed kernel and initramfs configurations. An attacker who controls this
77+
key can increment the counter, causing a denial of service attack against the
78+
system, but it does not provide access to encrypted data nor any way to roll
79+
back to an old version.
80+
81+
## TPM Disk Unlock key
82+
83+
The TPM NVRAM stores one of the disk encryption keys, which is encrypted with
84+
the user's Disk Unlock Key passphrase and sealed with the TPM PCR values for
85+
the firmware and the LUKS headers of the disk. On every boot, the user types in
86+
their TPM Disk Unlock Key passphrase and the TPM will unseal and decrypt the disk encryption key if
87+
the firmware is unmodified and the passphrase matches. Since the TPMTOTP
88+
one-time code matched, the user can have confidence that the firmware is
89+
unmodified before they enter their TPM Disk Unlock Key passphrase. If the system is booted in
90+
recovery mode, the PCRs will not match and this key is not accessible to the
91+
user.
10192

10293
The Heads firmware inserts this key into the Qubes `initramfs.cpio` as
103-
`/secret.key`, which is listed in the `/etc/crypttab` file as the decryption
104-
key for the various partitions. The dracut/systemd startup scripts will read
105-
the `/etc/crypttab` file and use it to decrypt the drives without further user
106-
intervention.
94+
`/secret.key`, which is listed in the `/etc/crypttab` file as the decryption
95+
key for the various partitions. The dracut/systemd startup scripts will read
96+
the `/etc/crypttab` file and use it to decrypt the drives without further user
97+
intervention.
10798

10899
The sealed blob is not secret since it is both encrypted and sealed, but if an
109-
attacker can extract this unsealed and decrypted key they can decrypt the data
110-
on the disk. If they extract the TPM they can set the PCRs to the correct
111-
values and attempt to brute force the unlock code, although the TPM should
112-
provide some rate limiting. TODO: Can the TPM also flush the keys if too many
113-
attempts are made?
100+
attacker can extract this unsealed and decrypted key, they can decrypt the data
101+
on the disk. If they extract the TPM, they can set the PCRs to the correct
102+
values and attempt to brute force the unlock code, although the TPM should
103+
provide some rate limiting. TODO: Can the TPM also flush the keys if too many
104+
attempts are made?
114105

115-
Disk recovery key
116-
---
106+
## Disk Recovery Key
117107

118-
During initial system setup the disk is encrypted with a user chosen passphrase.
119-
This key is only entered if the TPM PCRs have been changed, such as following a
120-
firmware update, or if the disk has been moved to a new machine and the user
121-
needs to back up the code. If the system is booted into recovery mode, the TPM
122-
PCRs will not match the TPM sealed encryption key, so the user will need to
123-
enter the recovery key to decrypt the drives.
108+
During initial system setup, the disk is encrypted with a user-chosen
109+
passphrase. When a TPM Disk Unlock Key is set up, this key is only entered if
110+
the TPM PCRs have changed, such as following a firmware update, or if the disk
111+
has been moved to a new machine and the user needs to back up the code. If the
112+
system is booted into recovery mode, the TPM PCRs will not match the TPM sealed
113+
Disk Unlock Key, so the user will need to enter the recovery key to decrypt the
114+
drives.
124115

125-
If an attacker gains control of this recovery key they can decrypt the disk to
126-
get access to the data, but not necessarily the system configuration if
127-
dm-verity is configured. They can also add additional disk decryption keys,
128-
although this will be detected by the TPM measurement of the LUKS headers.
116+
If an attacker gains control of this recovery key, they can decrypt the disk to
117+
access the data, but not necessarily the system configuration if dm-verity is
118+
configured. They can also add additional disk decryption keys, although this
119+
will be detected by the TPM measurement of the LUKS headers.
129120

130-
LUKS disk encryption key
131-
---
121+
## LUKS Keys and Passphrases
132122

133-
The TPM disk encryption and user's disk recovery keys are not the actual
134-
encryption keys for the disk; they are passed through [PBKDF2](https://en.wikipedia.org/wiki/PBKDF2)
135-
and the result is used to encrypt the actual disk encryption key, which is
136-
stored in the LUKS header on the disk. Under normal circumstances this key is
137-
not visible to the user and is only an implementation detail.
123+
The TPM Disk Unlock and user's Disk Recovery passphrases are not the actual
124+
encryption keys for the disk. These passphrases are processed through
125+
[PBKDF2](https://en.wikipedia.org/wiki/PBKDF2) (LUKS1) or [Argon2]
126+
(https://en.wikipedia.org/wiki/Argon2) (LUKS2) to derive a key. This derived
127+
key then decrypts the actual disk encryption key stored in the LUKS header.
138128

139-
Access to this key has the same risks as the disk recovery key.
129+
The disk encryption key itself remains hidden from users, serving only as an
130+
implementation detail for the encryption process.
140131

141-
Owner's GPG key
142-
---
132+
## Owner's GPG key
143133

144134
![Yubikey]({{ site.baseurl }}/images/Yubikey.jpg)
145135

146-
The owner of the machine generates a GPG key pair as part of installing Heads.
147-
Ideally the private key does not live on the machine, but instead is in a
148-
Yubikey or other USB Security dongle.
136+
The owner of the machine generates a GPG key pair as part of installing Heads.
137+
Ideally, the private key does not live on the machine, but instead is in a
138+
Yubikey or other USB Security dongle.
149139

150-
The security dongle may be used in the disk decryption process. Some of the [Linux distros](https://docs.puri.sm/Librem_Key/Getting_Started/User_Manual.html#decrypt-luks-encrypted-drives-with-librem-key) have incorporated this using /etc/crypttab with a keyscript option.
140+
The security dongle may be used in the disk decryption process. Some of the
141+
[Linux distros](https://docs.puri.sm/Librem_Key/Getting_Started/User_Manual.html#decrypt-luks-encrypted-drives-with-librem-key)
142+
have incorporated this using /etc/crypttab with a keyscript option.
151143

152-
An attacker who controls this private key can replace executables in `/boot` and
153-
if they also control the disk encryption key they can tamper with files in a
154-
dm-verity protected root filesystem.
144+
An attacker who controls this private key can replace executables in `/boot`
145+
and if they also control the disk encryption key, they can tamper with files in
146+
a dm-verity protected root filesystem.
155147

156-
User login password
157-
---
148+
## User login password
158149

159-
The user's login password is used to control access to the system once it has booted.
150+
The user's login password is used to control access to the system once it has
151+
booted.
160152

161153
An attacker who controls this key can access the system and the decrypted disks
162-
if they gain physical access to the system while it is running or asleep. This
163-
provides access to the data on the drive, but not necessarily the ability to
164-
modify a dm-verityprotected root filesystem.
154+
if they gain physical access to the system while it is running or asleep. This
155+
provides access to the data on the drive, but not necessarily the ability to
156+
modify a dm-verity protected root filesystem.
165157

166-
Root password
167-
---
158+
## Root password
168159

169160
The root password is not enabled by default on Qubes, so it is functionally
170-
equivalent to the login password. Other operating systems might differ.
161+
equivalent to the login password. Other operating systems might differ.
171162

172-
TPM PCRs
173-
====
163+
# TPM PCRs
174164

175165
![TPM]({{ site.baseurl }}/images/TPM.jpg)
176166

177-
0: Nothing for the moment (Populated by binary blobs where applicable for [SRTM](https://doc.coreboot.org/security/vboot/measured_boot.html#ibb-crtm))
167+
0: Nothing for the moment (Populated by binary blobs where applicable for
168+
[SRTM](https://doc.coreboot.org/security/vboot/measured_boot.html#ibb-crtm))
178169

179170
1: Nothing for the moment
180171

172+
2: coreboot's Boot block, ROM stage, RAM stage, Payload (Heads linux kernel and
173+
initrd)
174+
175+
3: Nothing for the moment
176+
177+
4: Boot mode (0 during `/init`, then `recovery` or `normal-boot`)
178+
179+
5: Heads Linux kernel modules
180+
181+
6: Drive LUKS headers
182+
183+
181184
2: coreboot's Boot block, ROM stage, RAM stage, Payload (Heads linux kernel and initrd)
182185

183186
3: Nothing for the moment

Installing-and-Configuring/configuring-keys.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ This will go first briefly over a survey, asking you if you want to:
8989
- As explained on screen, anyone having a LUKS header backup could restore it and decrypt with
9090
past corresponding passphrase. Changing passphrase without reencrypting doesn't change the
9191
encryption key.
92-
- Change the disk encryption key passphrase (Say yes here if you didn't install the OS yourself)
92+
- Change the Disk Recovery Key passphrase (Say yes here if you didn't install the OS yourself)
9393
- You should have also said yes above.
9494
- Define a single shared passphrase across all security components (not recommended)
9595
- This option is used by some OEMs to provision initial secrets. Passphrases should be different

Installing-and-Configuring/install-os.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Default Boot and Disk Unlock
8282

8383
If you want to set a default option so that you don't have to choose at every
8484
boot, you can do so from the menu by selecting 'd' on the confirmation screen.
85-
You will also be able to seal your Disk Unlock Key into the TPM, which would be unsealed only when provided with the good TPM disk encryption key passphrase and when firmware measurement and LUKS header are the same as when the Disk Unlock Key was sealed when booting from detached signed default boot option selection.
85+
You will also be able to seal your Disk Unlock Key into the TPM, which would be unsealed only when provided with the good TPM Disk Unlock Key passphrase and when firmware measurement and LUKS header are the same as when the Disk Unlock Key was sealed when booting from detached signed default boot option selection.
8686

8787
This should work for Qubes OS, Fedora, Debian (and derivatives).
8888

0 commit comments

Comments
 (0)