-
Notifications
You must be signed in to change notification settings - Fork 74
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
Conversation
71bfc80
to
482a46c
Compare
482a46c
to
1b95570
Compare
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
server/verify_test.go
Outdated
@@ -1068,10 +1068,14 @@ func TestVerifyAttestationWithSevSnp(t *testing.T) { | |||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
1b95570
to
5e327b4
Compare
/gcbrun |
…ents
5e327b4
to
afce07b
Compare
/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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
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:
verifyGceTechnology
because GCETechnology event log is closely related to TPM, this function is directly called after the event log is parsed.cos-dev-117-18374-0-0
rather than the latest COS image version to avoid CS image build issues.