Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate the SNP/TDX Machine State field with the verified SNP/TDX attestation data + use a stable COS image version #463

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

yawangwang
Copy link
Collaborator

@yawangwang yawangwang commented Jun 25, 2024

This PR includes changes to populate the machinState proto with the verified SNP/TDX attestation data. The attestation verifier service will leverage the verified machineState to make claims around.

Breaking changes:

  • Unexport verifyGceTechnology because GCETechnology event log is closely related to TPM, this function is directly called after the event log is parsed.
  • Use a stable COS image version cos-dev-117-18374-0-0 rather than the latest COS image version to avoid CS image build issues.

@yawangwang yawangwang force-pushed the populate-ms-with-snp branch 3 times, most recently from 71bfc80 to 482a46c Compare June 26, 2024 00:40
@yawangwang yawangwang changed the title Populate the snpAttestation Machine State field with the SNP measurement Populate the SNP/TDX Machine State field with the verified SNP/TDX attestation data Jun 26, 2024
@yawangwang yawangwang requested a review from alexmwu June 26, 2024 16:14
@yawangwang yawangwang marked this pull request as ready for review June 26, 2024 16:14
@yawangwang yawangwang requested a review from JoshuaKrstic June 26, 2024 16:14
@yawangwang yawangwang force-pushed the populate-ms-with-snp branch from 482a46c to 1b95570 Compare June 28, 2024 01:33
@yawangwang yawangwang requested a review from alexmwu June 28, 2024 01:36
server/verify.go Outdated
// parseTCGEventLog is a wrapper function around `parsePCClientEventLog` method to:
// 1. parse partial machine state from TPM TCG event logs.
// 2. verify GceTechnology since the GCE Technology event is directly related to the TPM.
func parseTCGEventLog(attestation *pb.Attestation, pcrs *tpmpb.PCRs, opts VerifyOpts) (*pb.MachineState, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked your suggestion of parseMachineStateFromTPM better than parseTCGEventLog. Since it is also doing event log replay and event parsing. The term "parse" is a bit overloaded unfortunately.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

server/verify.go Outdated
@@ -176,6 +179,7 @@ func VerifyAttestation(attestation *pb.Attestation, opts VerifyOpts) (*pb.Machin

proto.Merge(machineState, celState)
proto.Merge(machineState, state)
proto.Merge(machineState, teeState)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid proto.Merge where possible as it can override existing values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return ms, nil
}

// parseTEEAttestation parses a machineState from TeeAttestation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of the wrapper func for parsePCClientEventlog is to avoid proto.Merge. proto.Merge is less readable since it implicitly copies every field from src to dst. This requires our implementation to be mutually exclusive, or we risk overwriting. We originally used proto.Merge to merge the state from two separate event logs, but we could just populate the TeeAttestation field directly in the wrapper.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IOW, this can be inline in parseTCGEventLog.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My take from "inline" is call parseTEEAttestation from parseMachineStateFromTPM after verifyGceTechnolgy is done. LMK if this is not what you want.

@@ -318,10 +322,10 @@ func makePool(certs []*x509.Certificate) *x509.CertPool {
return pool
}

// VerifyGceTechnology checks the GCE-specific GceNonHost event's Trusted Execution Technology (TEE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we unexport this, it's a backwards incompatible change. Please add a breaking comment to the PR description.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -1068,10 +1068,14 @@ func TestVerifyAttestationWithSevSnp(t *testing.T) {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for the failure cases

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new test TestParseTEEAttestation to cover both successful and failure cases.

@yawangwang yawangwang force-pushed the populate-ms-with-snp branch from 1b95570 to 5e327b4 Compare June 28, 2024 23:34
@yawangwang yawangwang requested a review from alexmwu June 28, 2024 23:45
@yawangwang
Copy link
Collaborator Author

/gcbrun

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…ents
@yawangwang yawangwang force-pushed the populate-ms-with-snp branch from 5e327b4 to afce07b Compare July 2, 2024 23:16
@yawangwang yawangwang changed the title Populate the SNP/TDX Machine State field with the verified SNP/TDX attestation data Populate the SNP/TDX Machine State field with the verified SNP/TDX attestation data + use a stable COS image version Jul 2, 2024
@yawangwang
Copy link
Collaborator Author

/gcbrun

@@ -1,7 +1,7 @@
substitutions:
# using this base image for now, because there is an issue causing the newest COS dev
# image not booting with cs.
'_BASE_IMAGE': '' # left empty means using the latest image in the family
'_BASE_IMAGE': 'cos-dev-117-18374-0-0' # Use a stable COS version to avoid CS image build issues
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not submit until you get approval from @jkl73 for this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, this is the same base image on the last dev build.

// In long term, it should parse a full machineState from TeeAttestation.
func parseTEEAttestation(attestation *pb.Attestation, tech pb.GCEConfidentialTechnology) (*pb.MachineState, error) {
switch tech {
case pb.GCEConfidentialTechnology_AMD_SEV_SNP:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing something: don't we already do these checks in verifyGceTechnology?? Can we have that return pb.MachineState or just remove the call to parseTEEAttestation and do
ms.TeeAttestation = attestation.TeeAttestation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ms.TeeAttestation = attestation.TeeAttestation will not work because they're two different proto types.
parseTEEAttestation doesn't do any checks on attestation. This function, in short term, just populates the TeeAttestation field using a deep copy of the verified attestation data, but in long run, we'll want to get a full machineState from TDX/SNP attestation. The intent of having this function is for future-proof purpose.

@yawangwang yawangwang requested a review from jkl73 July 3, 2024 23:26
@yawangwang yawangwang merged commit c6271f8 into google:main Jul 8, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants