Re: [RFC] IMA Log Snapshotting Design Proposal

James Bottomley
2023-08-10T11:43:38Z

On Wed, 2023-08-09 at 21:43 -0700, Tushar Sugandhi wrote:
> On 8/8/23 14:41, James Bottomley wrote:
> > On Tue, 2023-08-08 at 16:09 -0400, Stefan Berger wrote:
[...]
> > >   at this point doesn't seem necessary since one presumably can
> > > verify the log and PCR states at the end with the 'regular'
> > > quote.
> >
> > I don't understand this.  A regular quote is a signature over PCR
> > state by an AK.  The point about saving the AK in the log for the
> > original is that if the *kernel* truncates the log and saves it to
> > a file, it needs to generate both the AK and the quote for the top
> > of the file shard. That means the AK/EK binding is unverified, but
> > can be verified by loading the AK and running the usual tests,
> > which can only be done if you have the loadable AK, which is why
> > you need it as part of the log saving proposal.
>
> I had this question about the usability of AK/EK in this
> context. Although AK/EK + PCR quote is needed to verify the snapshot
> shards / IMA logs are not tampered with, I am still not sure why
> AK/EK needs to be part of the shard/IMA log. The client sending AK/EK
> to attestation service separately would still serve the purpose,
> right?

Well, the EK doesn't need to be part of the log: it's just a permanent
part of the TPM identity. To verify the log, you need access to the
TPM that was used to create it, so that's the point at which you get
the EK.

An AK is simply a TPM generated signing key (meaning the private part
of the key is secured by the TPM and known to no-one else). In the
literature a TPM generated signing key doesn't become an Attestation
Key until it's been verified using an EK property (either a certify for
a signing EK or a make/activate credential round trip for the more
usual encryption EK.

So the proposal is for each quote that's used to verify a log shard is
that the TPM simply generate a random signing key and use that to sign
the quote. You need to save the TPM form of the generated key so it
can be loaded later and the reason for that is you can do the EK
verification at any time after the quote was given by loading the saved
key and running the verification protocol. In the normal attestation
you do the EK verification of the AK *before* the quote, but there's no
property of the quote that depends on this precedence provided you do
the quote with a TPM generated signing key.

The underlying point is that the usual way an EK verifies an AK
requires a remote observer, which the kernel won't have, so the kernel
must do all its stuff locally (generate key, get quote) and then at
some point later the system can become remote connected and prove to
whatever external entity that the log shard is valid. So we have to
have all the components necessary for that proof: the log shard, the
quote and the TPM form of the AK.

> For instance, PCR quotes will be signed by AK. So as long as the
> verifier trusts the AK/EK,

Right, but if you're sharding a log, the kernel doesn't know if a
verifier has been in contact yet. The point of the protocol above is
to make that not matter. The verifier can contact the system after the
log has been saved and the verification will still work.

> it can verify the quotes are not tampered with.
> Replaying IMA log/snapshot can produce the PCR quotes which can be
> matched with signed PCR quotes. If they match, then the verifier can
> conclude that the IMA log is not tampered with. So AK doesn't need to
> be part of the log/snapshot.

Only if the system is currently in contact with the verifier and the
verifier has created the AK. That may not have happened.

> BTW, in this proposal, kernel is truncating the log and passing the
> truncated buffer to UM.  UM client need to save it to the disk
> location of it's choice.

Yes, but I was assuming tampering with or discarding the log file would
be treated in exactly the same way as an in-kernel IMA log tamper.

James