Skip to contentSkip to conversation

IMA determinism

tpm2 Eduardo Falcão <eduardolfalcao at gmail.com> 1 participant 11 messages Jun 9, 2020 – Sep 2, 2020

lore
Share & tools
lore

Eduardo Falcão <eduardolfalcao at gmail.com>

#0 lore raw

Hi folks

I know this is not a TPM doubt, but it's related and some people may have had this issue.

Is there some form to make the digest collected through IMA deterministic? I rebooted my system several times, and on the very beginning of system initialization I've noticed the hash in PCR 10 of TPM is changing. The number of lines initializes equally, but it seems that the order the programs are ran always changes.

Any ideas for overcoming this issue?

[]'s

#1 lore raw

Have you tried the IMA list?

http://vger.kernel.org/vger-lists.html#linux-integrity

Quoted 24 lines

-----Original Message-----
From: Eduardo Falcão <eduardolfalcao(a)gmail.com>
Sent: Tuesday, June 9, 2020 10:45 AM
To: tpm2(a)lists.01.org
Subject: [tpm2] IMA determinism

Hi folks

I know this is not a TPM doubt, but it's related and some people may have had this issue.

Is there some form to make the digest collected through IMA deterministic? I rebooted my system several times, and on the very beginning of system initialization I've noticed the hash in PCR 10 of TPM is changing. The number of lines initializes equally, but it seems that the order the programs are ran always changes.

Any ideas for overcoming this issue?

[]'s
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

#2 lore raw
In reply to Eduardo Falcão <eduardolfalcao at gmail.com>

I don't think IMA was designed to be deterministic. And I think you should not rely on the TPM PCR 10 value being in an specific state for e.g. secret sealing.

The reason is the asynchronous nature of the OS. Things happens when they are ready, and IMA measures them as they are requested.

I think the sole purpose of the IMA Measurement and the TPM PCR 10 extension is to extend the hardware root of trust to the user space, and have user space remote attestation capabilities. For this, you need the IMA Measurement Log, and check that the quoted PCR 10 value matches the aggregated digest calculated from IMA Measurement Log.

You could reduce the IMA Measurement policy to a very reduced set of user files, like only measuring the Kernel Modules for example, but that will imply not measuring important parts of the Trusted Computing Base.

Could you expand on the reason to the a deterministic PCR 10?

#3 lore raw
Quoted 5 lines

I don't think IMA was designed to be deterministic. And I think you should not rely on the TPM PCR 10 value being in an specific state for e.g. secret sealing.

The reason is the asynchronous nature of the OS. Things happens when they are ready, and IMA measures them as they are requested.

Sure. I agree with you.

Quoted 11 lines

I think the sole purpose of the IMA Measurement and the TPM PCR 10 extension is to extend the hardware root of trust to the user space, and have user space remote attestation capabilities. For this, you need the IMA Measurement Log, and check that the quoted PCR 10 value matches the aggregated digest calculated from IMA Measurement Log.

You could reduce the IMA Measurement policy to a very reduced set of user files, like only measuring the Kernel Modules for example, but that will imply not measuring important parts of the Trusted Computing Base.

Could you expand on the reason to the a deterministic PCR 10?

My main goal is to attest the state of a VM. I was thinking in booting a fresh installed Ubuntu, and add some application to run after boot. I am trying to prove this application runs in an incorrupt VM.

At first, I would get the digest of PCR10, and would consider this hash as the unique acceptable hash for considering my VM healthy. I would use this value for remote attestation purposes. But, as you mentioned, the indeterminism of programs' execution order makes this strategy unfeasible.

I'm considering only PCR10 because I know that PCRs 0-7 are hashed to a boot agregate, which is the first line of the measurements file. Thus, somehow, PCRs 0-7 are directly bound to PCR10.

As you said, reducing the IMA Measurement policy to measure less files reduces the security surface. I won't follow this path.

So, I think your idea would be sending the IMA Measurement Log along with the quote. If the quote is can be verified and matches with IMA digest, then, the second step would be to check the hashes of each file separately. If all files have the expected hash, then I have a healthy state...

Did I get it right?

Thanks, Nicolas, for your comments.

#4 lore raw
Quoted 7 lines

Sure. I agree with you.

My main goal is to attest the state of a VM. I was thinking in booting a fresh installed Ubuntu, and add some application to run after boot. I am trying to prove this application runs in an incorrupt VM.

Quoted 8 lines

At first, I would get the digest of PCR10, and would consider this hash as the unique acceptable hash for considering my VM healthy. I would use this value for remote attestation purposes. But, as you mentioned, the indeterminism of programs' execution order makes this strategy unfeasible.

I'm considering only PCR10 because I know that PCRs 0-7 are hashed to a boot agregate, which is the first line of the measurements file. Thus, somehow, PCRs 0-7 are directly bound to PCR10.

I would add here that It is still important to quote and verify the PCR 0-7 first directly from the TPM. Otherwise, how do you know that the boot_aggregate in the IMA Measurement Log is trustworthy?

I think the process should be (more or less, simplified):

1. Create Endorsement and Attestation Keys created in the TPM, and enrolled in the attestation server
2. Do a Remote Attestation to the PCR 0 to 10 using those keys, using a nonce for data qualification. The nonce is generated in the server, encrypted with TPM_MakeCredential using EK and AK of the target client. Client uses TPM_ActivateCredential for getting the nonce, and use that nonce to generate the quote
3. Send the IMA Measurement Log with the PCR Quote to the server
4. In the server, validate the Quote Signature and qualification data.
5. If 4) is correct, validate the TPM PCR 0 to 9 values (8 and 9 may be not populated in Ubuntu) with the "Golden Image Digests"
6. Reconstruct the expected boot aggregate using the TPM PCR 0 to 7, and compare that with the boot_aggregate reported on the IMA Measurement Log.
7. If 6) is correct, calculate the aggregated PCR 10 digest using the IMA Measurement Logs. Compare that to the quoted PCR 10 value.
8. If 7) is correct, validate the entries of the IMA Measurement Log with the "Golden Image Digests"
9. If all this is correct, maybe your VM is not corrupted :)

Some comments I can give you based on this list:

a. for 3), the IMA Measurement Log have all the software running in the VM, privacy should be taken into account, encryption could be the answer. If the VM is yours, maybe you can ignore that
b. for 3), you need to assure that the IMA Measurement Log is not modified on transit. Signature could be the answer here?
c. Creating and maintaining the Golden Image Digests is tricky.
d. for 7) the final digest could not match. This is because of the asynchronous nature of the OS as well. A simple explanation is: you take the TPM Quote a time t1, save the copy of the IMA Measurement Log at time t2. If some asynchronous process caused an IMA Measure between t1 and t2, you would get an additional measurement in the log that is not extended in the already created quote. Something worst can happens if you take the snapshot of the log and then do the quote (it will be impossible to reconstruct the PCR 10 value with that log). The "solution" is to check if the resulting aggregated digest from the log matches the quote, and if that fails, check if the quote PCR 10 value is present in some of the last files in the log.

Hope this table helps:

PCR 10 VALUE: 5

FILE DIGEST AGGREGATED DIGEST
boot_aggregate 0 0

A                         1                 1
B                         2                 2
C                         3                 5 <- Quoted Value
D                         4                 6
E                         5                 7

Files D and E were measured after the Quote was taken. The aggregated digest will not match the quote
But C, which is more or less at the end of the log, matches the aggregated digest, so the quote is good, and D + E will be tpm quoted in the next attestation

Quoted 4 lines

As you said, reducing the IMA Measurement policy to measure less files reduces the security surface. I won't follow this path.

Quoted 8 lines

So, I think your idea would be sending the IMA Measurement Log along with the quote. If the quote is can be verified and matches with IMA digest, then, the second step would be to check the hashes of each file separately. If all files have the expected hash, then I have a healthy state...

Did I get it right?

Thanks, Nicolas, for your comments.

Did you already looked at Keylime? :)

#5 lore raw

Thank you, Nicolas, for such a detailed response.

Passing through the attestation process by myself helps me to understand it better. However, I'll definitively take a look on keylime!

Regards

#6 lore raw
In reply to nicolasoliver03 at gmail.com

Hi Nicolas.

Has been a while since I followed the steps you mentioned, and everything worked perfectly. Thanks for your hints.

There is just one point I'm still missing the comprehension.
How is the binding between AK and EK performed?
How can this attestation process avert an attacker with an authentic TPM from creating a credential for an AK that is not TPM authentic?

It seems that the AK name has something to do with this, but I can't figure it out how...

Best regards

#7 lore raw

Hi Eduardo!

In one scenario, where you are the owner of the device is trusted, and the key provisioning process is done in a trusted environment, the binding is done by the user creating the key. So, you create the keys effectively in the TPM, and provide the public parts to the attestation server. Then the server uses something like TPM_MakeCredential to encrypt the nonce that will be used in the attestation process, and guarantees that only the TPM enrolled in the provisioning process can decrypt the nonce and sign the attestation request. I would say the binding of EK and AK is done by a trusted party (the user, in this case)

If we go to a second scenario, where you are the owner of the attestation server, but other person (which may be untrusted) is the owner of the device, then you have to rely on certificates provided by the TPM manufacturer. Looking at https://lists.01.org/hyperkitty/list/tpm2(a)lists.01.org/message/BIJRJGFCTFMQICMUWSVTYHFCH2OEEID6/, it more or less have a process to make this happen based on the EK Certificate. This is great if every TPM followed the https://trustedcomputinggroup.org/wp-content/uploads/TCG-TPM-v2.0-Provisioning-Guidance-Published-v1r1.pdf document for provisioning of keys. So, having the Endorsement Key Certificate in the target TPM, you could enforce the association of the AK to the EK in that specific TPM, trusting the TPM Manufacturer.

But, not every device I saw have the EKCert provisioned :(. I saw this happening in devices with Platform Trust Technology for example. Using the https://github.com/tpm2-software/tpm2-tools/blob/master/man/tpm2_getekcertificate.1.md tool yields this error https://github.com/tpm2-software/tpm2-tools/blob/master/tools/tpm2_getekcertificate.c#L358. This scenario may be more challenging.

Summary:

1. If the parts generating and providing the keys are trusted, and the environment where this key is shared is trusted, maybe you can trust that the EK and AK belongs to the same TPM.
2. You could use the EK Cert with the process described before. I don't have sample code for this, so if somebody has it, please share!
3. For TPMs that do not have an EK Cert, apparently you are out of luck if (1) is not possible

Please somebody correct me if I am wrong!

#8 lore raw
Quoted 37 lines

-----Original Message-----
From: nicolasoliver03(a)gmail.com <nicolasoliver03(a)gmail.com>
Sent: Thursday, July 16, 2020 2:13 PM
To: tpm2(a)lists.01.org
Subject: [tpm2] Re: IMA determinism

Hi Eduardo!

In one scenario, where you are the owner of the device is trusted, and the key provisioning process is done in a trusted environment, the binding is done by the user creating the key. So, you create the keys effectively in the TPM, and provide the public parts to the attestation server. Then the server uses something like TPM_MakeCredential to encrypt the nonce that will be used in the attestation process, and guarantees that only the TPM enrolled in the provisioning process can decrypt the nonce and sign the attestation request. I would say the binding of EK and AK is done by a trusted party (the user, in this case)

If we go to a second scenario, where you are the owner of the attestation server, but other person (which may be untrusted) is the owner of the device, then you have to rely on certificates provided by the TPM manufacturer. Looking at
https://lists.01.org/hyperkitty/list/tpm2(a)lists.01.org/message/BIJRJGFCTFMQIC
MUWSVTYHFCH2OEEID6/, it more or less have a process to make this happen based on the EK Certificate. This is great if every TPM followed the
https://trustedcomputinggroup.org/wp-content/uploads/TCG-TPM-v2.0-
Provisioning-Guidance-Published-v1r1.pdf document for provisioning of keys. So, having the Endorsement Key Certificate in the target TPM, you could enforce the association of the AK to the EK in that specific TPM, trusting the TPM Manufacturer.

But, not every device I saw have the EKCert provisioned :(. I saw this happening in devices with Platform Trust Technology for example. Using the
https://github.com/tpm2-software/tpm2-
tools/blob/master/man/tpm2_getekcertificate.1.md tool yields this error
https://github.com/tpm2-software/tpm2-
tools/blob/master/tools/tpm2_getekcertificate.c#L358. This scenario may be more challenging.

Quoted 7 lines

Summary:

1. If the parts generating and providing the keys are trusted, and the environment where this key is shared is trusted, maybe you can trust that the EK and AK belongs to the same TPM.
2. You could use the EK Cert with the process described before. I don't have sample code for this, so if somebody has it, please share!

Imran has a full writeup on this:
https://tpm2-software.github.io/2020/06/12/Remote-Attestation-With-tpm2-tools.html

If you don't need the privacy portion the service provider and privacy CA can be the same.

You could also probably use TPM2_Certify to verify the AIK is loaded in that TPM using the EK if you wanted to avoid the credential secret portion. Imran, correct me if I am wrong here.

Quoted 2 lines

3. For TPMs that do not have an EK Cert, apparently you are out of luck if (1) is not possible

The PTT case you mention above, if you go through the recovery process you should have A valid EK.

Quoted 6 lines

Please somebody correct me if I am wrong!
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

#9 lore raw

Thanks, Roberts and Nicolas.

Other doubt that arose here is about privacy...

In the attestation process, the machine being attested sends the public portion of its EK to the Attestor, and thus the Attestor could identify the machine by this key (if it requests attestation multiple times).
Some considerations are pointed here (https://tpm2-software.github.io/2020/06/12/Remote-Attestation-With-tpm2-tools.html#privacy-considerations), where different AIK, for instance, could be generated for each user, but they apply only for scenarios where the machine being attested has multiple users. If the machine itself doesn't have any user, then using multiple AIK will not make any difference.

Do you have any alternative or thoughts for this situation?

Best regards

#10 lore raw

Section three is the relevant bit:

"Every user generates and uses a new key (ephemeral key) every time an attestation blob has to be signed. There are some unique challenges with this. If every attestation blob is signed with a brand-new key, how to infer the anonymous identity at the minimum to determine the genuineness of the platform and hence the attestation. It then follows that we need an anonymous identity that is cryptographically bound to a unique trusted identity and that the unique identity is never revealed to any entity other than the Privacy-CA."

You generate a new AIK every-time.

You would follow the flow as illustrated by:
"Service request Part 1 (Platform Anonymous Identity Validation)"

The takeaway here, is that the privacy-ca always knows who it is, but the service provider does not. So you trust the privacy CA with your privacy in that model.

Bill

Quoted 27 lines

-----Original Message-----
From: Eduardo Falcão <eduardolfalcao(a)gmail.com>
Sent: Wednesday, September 2, 2020 10:35 AM
To: tpm2(a)lists.01.org
Subject: [tpm2] Re: IMA determinism

Thanks, Roberts and Nicolas.

Other doubt that arose here is about privacy...

In the attestation process, the machine being attested sends the public portion of its EK to the Attestor, and thus the Attestor could identify the machine by this key (if it requests attestation multiple times).
Some considerations are pointed here (https://tpm2-
software.github.io/2020/06/12/Remote-Attestation-With-tpm2- tools.html#privacy-considerations), where different AIK, for instance, could be generated for each user, but they apply only for scenarios where the machine being attested has multiple users. If the machine itself doesn't have any user, then using multiple AIK will not make any difference.

Do you have any alternative or thoughts for this situation?

Best regards
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s