osresearch / safeboot

Scripts to slightly improve the security of the Linux boot process with UEFI Secure Boot and TPM support
https://safeboot.dev/
GNU General Public License v2.0
268 stars 28 forks source link

Using EKhash = H(EKpub), when the EKpub is derived from an EKcert, is problematic #170

Open nicowilliams opened 1 year ago

nicowilliams commented 1 year ago

In HCP we use Safeboot w/ an EKcert, then we derive an EKpub from the EKcert, then we compute a hash of the EKpub and name the enrollment after that hash. At attestation time the client sends its EKpub and the server looks up the enrollment by EKhash = H(EKpub).

The way the EKcert->EKpub conversion is done is simple:

But there are at least two ways in which the TPM2B_PUBLIC of an EK as produced by the TPM where it resides, and as produced by another TPM as used above can differ:

The upshot is that either we must

(Readers should note that enrollment also supports enrolling with an EKpub directly, and this is for the case where virtual TPMs are used where there is a mechanism other than EKcerts for validating the legitimacy of a TPM.)

nicowilliams commented 1 year ago

I think the normalization approach will probably be the best.

osresearch commented 1 year ago

Normalizing the EKpub on the server might make more sense? The server is the one choosing to use the hash, not the client, and a different server might choose an equality test or something else like checking the modulus, which means that the client doesn't know what fields are important.

This normalization is also easier to do in the Python server than the shell scripts of the client, right?

nicowilliams commented 1 year ago

This normalization is also easier to do in the Python server than the shell scripts of the client, right?

I'm thinking it's just tpm2_loadexternal then tpm2_readpublic to normalize.

The swtpm does remember whether the exponent was given as 0x00010001 or 0x00000000, so we'll have to resort to ugly games.

A dd command works. However, I fear this is too ugly, and that we might need to do something else.

Options: