Skip to content

Commit 91ba587

Browse files
committed
LUKS related docs: self-review
Remove notes to write down credentials as they are chosen since linuxboot/heads#1875 witll provide confirmation screen with creds and Qr code to safely safeguard them as provisioned. No more typo. Signed-off-by: Thierry Laurion <insurgo@riseup.net>
1 parent ca40eaa commit 91ba587

File tree

3 files changed

+249
-225
lines changed

3 files changed

+249
-225
lines changed

About/Keys.md

Lines changed: 88 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ nav_order: 4
66
parent: About
77
---
88

9-
# Keys and passwords in Heads
9+
## Keys and passwords in Heads
1010

1111
There are "too many secrets" involved in booting a Heads system. Luckily most
1212
of them are stored in hardware and only a few need to be memorized by the
@@ -28,35 +28,37 @@ compromise the different keys.
2828

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

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

4547
An attacker who controls this key can flash new firmware via hardware means
4648
(and possibly remotely via software, unless other steps are taken).
4749

4850
## TPM Owner password
4951

5052
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?).
53+
password is set. This clears all existing NVRAM and spaces.
5354

54-
Are there any consequences of an attacker controlling this key?
55+
An attacker who controls this key can reseal TPMTOTP shared secret.
5556

5657
## TPMTOTP shared secret
5758

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

61+
Since humans have trouble doing RSA public key cryptography in their brains,
6062
Heads uses [TPM TOTP](https://trmm.net/Tpmtotp) to let the system attest to the
6163
user that the firmware is unmodified. During setup, a random 20-byte value is
6264
generated and shared (via QR code) to the user's phone and sealed with the
@@ -83,12 +85,12 @@ back to an old version.
8385
The TPM NVRAM stores one of the disk encryption keys, which is encrypted with
8486
the user's Disk Unlock Key passphrase and sealed with the TPM PCR values for
8587
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.
88+
their TPM Disk Unlock Key passphrase and the TPM will unseal and decrypt the
89+
disk encryption key if the firmware is unmodified and the passphrase matches.
90+
Since the TPMTOTP one-time code matched, the user can have confidence that the
91+
firmware is unmodified before they enter their TPM Disk Unlock Key passphrase.
92+
If the system is booted in recovery mode, the PCRs will not match and this key
93+
is not accessible to the user.
9294

9395
The Heads firmware inserts this key into the Qubes `initramfs.cpio` as
9496
`/secret.key`, which is listed in the `/etc/crypttab` file as the decryption
@@ -160,7 +162,7 @@ modify a dm-verity protected root filesystem.
160162
The root password is not enabled by default on Qubes, so it is functionally
161163
equivalent to the login password. Other operating systems might differ.
162164

163-
# TPM PCRs
165+
## TPM PCRs
164166

165167
![TPM]({{ site.baseurl }}/images/TPM.jpg)
166168

@@ -180,68 +182,67 @@ initrd)
180182

181183
6: Drive LUKS headers
182184

183-
184-
2: coreboot's Boot block, ROM stage, RAM stage, Payload (Heads linux kernel and initrd)
185-
186-
3: Nothing for the moment
187-
188-
4: Boot mode (0 during `/init`, then `recovery` or `normal-boot`)
189-
190-
5: Heads Linux kernel modules
191-
192-
6: Drive LUKS headers
193-
194185
7: Heads user-specific files stored in CBFS (config.user, GPG keyring, etc).
195186

196-
(16): Used for TPM futurecalc of LUKS header when setting up a TPM disk encryption key
197-
198-
Some history
199-
---
200-
Heads relied on coreboot patches until coreboot 4.8.1 for measured boot
201-
implementation, since coreboot had none.
202-
Heads measured boot scheme [changed](https://github.com/osresearch/heads/pull/793) to match coreboot 4.12's, which for the first time included seperated measured boot implementation from vboot implementation.
203-
204-
Since coreboot 4.12, Heads stopped patching coreboot to implement measured boot.
205-
coreboot measured boot implementation is the one filling PCR2, above.
206-
207-
Heads since then solely extends PCRs of it's own (PCRs 4-5-6-7 above) which are used when
208-
sealing/unsealing.
209-
210-
As you can see above, coreboot measures itself from bootblock then other boot phases up to its
211-
payload in PCR2, in conformity of their [SRTM](https://doc.coreboot.org/security/vboot/measured_boot.html#srtm-mode) measured boot policy.
212-
An example is given from [coreboot docs](https://doc.coreboot.org/security/vboot/measured_boot.html#platform-configuration-register).
213-
214-
TPM_Unseal errors
215-
---
216-
Consequently, if either coreboot phases, boot mode, kernel modules, LUKS headers
217-
or CBFS files are different then when those measurements were used to seal secrets,
218-
unseal operations will fail. HOTP/TOTP/TPM Disk Unlock Key passphrase should give errors
219-
in case of tempering.
220-
221-
The TPM Disk Unlock Key passphrase would fail with a different error then:
222-
`Error Authentication failed (Incorrect Password) from TPM_Unseal` when a user types
223-
a [TPM Disk Unlock key passphrase](/Keys/#disk-unlock-key-passphrase-prompt-output).
224-
225-
Indeed, the PCRs measurements used to seal the Disk Unlock Key in TPM NV memory cannot unseal
226-
that secret, even with a good TPM Disk Unlock Key passphrase, while HOTP/TOTP should not be able
227-
to unseal either.
228-
229-
230-
TCPA Event log
231-
---
232-
From the [Recovery Shell](/Recovery), it is possible to review PCR2 [TCPA event log](https://doc.coreboot.org/security/vboot/measured_boot.html#tcpa-eventlog) by typing:
233-
`cbmem -L`
234-
235-
236-
Disk Unlock Key passphrase prompt output
237-
====
238-
![Disk Unlock Key passphrase showed PCRs when passphrase fails](https://user-images.githubusercontent.com/827570/82279087-b2da2000-9959-11ea-8020-6ff36e947576.jpeg)
239-
240-
Here you can see that "Boot block, ROM stage, RAM stage, Heads payload", "Drive LUKS headers" and "Heads user-specific config files" have filled the registers PCR-02, PCR-06 and PCR-07 respectively. You can also see the TPM returning the error "Error Authentication failed (Incorrect Password)" which is an invitation to try again, this time typing more slowly. Measurements are consistent to what was sealed, but the passphrase is bad. This is good news.
241-
242-
After 3 unsuccessful attempts releasing TPM Disk Unlock Key, Heads will propose you to decrypt with your Disk Recovery Key passphrase, directly from the OS, bypassing Heads protection. Still good news.
243-
244-
If Disk Unlock Key passphrase throws a different error, it would be a good idea to meditate on your threat model and what happened to your computer since your last normal default boot.
245-
246-
The Disk Unlock Key is sealed in TPM NV memory with PCRs-2-4-5-6-7, which includes external content from the firmware, like your LUKS header measurements.
247-
187+
(16): Used for TPM futurecalc of LUKS header when setting up a TPM disk
188+
encryption key
189+
190+
### Some history
191+
Heads relied on coreboot patches until coreboot 4.8.1 for measured boot
192+
implementation, since coreboot had none. Heads measured boot scheme
193+
[changed](https://github.com/osresearch/heads/pull/793) to match coreboot
194+
4.12's, which for the first time included separated measured boot
195+
implementation from vboot implementation.
196+
197+
Since coreboot 4.12, Heads stopped patching coreboot to implement measured
198+
boot. coreboot measured boot implementation is the one filling PCR2, above.
199+
200+
Heads since then solely extends PCRs of its own (PCRs 4-5-6-7 above) which are
201+
used when sealing/unsealing.
202+
203+
As you can see above, coreboot measures itself from bootblock then other boot
204+
phases up to its payload in PCR2, in conformity of their
205+
[SRTM](https://doc.coreboot.org/security/vboot/measured_boot.html#srtm-mode)
206+
measured boot policy. An example is given from [coreboot
207+
docs](https://doc.coreboot.org/security/vboot/measured_boot.html#platform-configuration-register).
208+
209+
### TPM_Unseal errors
210+
Consequently, if either coreboot phases, boot mode, kernel modules, LUKS
211+
headers or CBFS files are different then when those measurements were used to
212+
seal secrets, unseal operations will fail. HOTP/TOTP/TPM Disk Unlock Key
213+
passphrase should give errors in case of tampering.
214+
215+
The TPM Disk Unlock Key passphrase would fail with a different error then:
216+
`Error Authentication failed (Incorrect Password) from TPM_Unseal` when a user
217+
types a [TPM Disk Unlock key passphrase](/Keys/#disk-unlock-key-passphrase-prompt-output).
218+
219+
Indeed, the PCRs measurements used to seal the Disk Unlock Key in TPM NV memory
220+
cannot unseal that secret, even with a good TPM Disk Unlock Key passphrase,
221+
while HOTP/TOTP should not be able to unseal either.
222+
223+
### TCPA Event log
224+
From the [Recovery Shell](/Recovery), it is possible to review PCR2 [TCPA event
225+
log](https://doc.coreboot.org/security/vboot/measured_boot.html#tcpa-eventlog)
226+
by typing: `cbmem -L`
227+
228+
### Disk Unlock Key passphrase prompt output
229+
![Disk Unlock Key passphrase showed PCRs when passphrase
230+
fails](https://user-images.githubusercontent.com/827570/82279087-b2da2000-9959-11ea-8020-6ff36e947576.jpeg)
231+
232+
Here you can see that "Boot block, ROM stage, RAM stage, Heads payload", "Drive
233+
LUKS headers" and "Heads user-specific config files" have filled the registers
234+
PCR-02, PCR-06 and PCR-07 respectively. You can also see the TPM returning the
235+
error "Error Authentication failed (Incorrect Password)" which is an invitation
236+
to try again, this time typing more slowly. Measurements are consistent to what
237+
was sealed, but the passphrase is bad. This is good news.
238+
239+
After 3 unsuccessful attempts releasing TPM Disk Unlock Key, Heads will propose
240+
you to decrypt with your Disk Recovery Key passphrase, directly from the OS,
241+
bypassing Heads protection. Still good news.
242+
243+
If Disk Unlock Key passphrase throws a different error, it would be a good idea
244+
to meditate on your threat model and what happened to your computer since your
245+
last normal default boot.
246+
247+
The Disk Unlock Key is sealed in TPM NV memory with PCRs-2-4-5-6-7, which
248+
includes external content from the firmware, like your LUKS header measurements.

0 commit comments

Comments
 (0)