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

Add SEV-SNP policy for signed UEFI measurements #446

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

deeglaze
Copy link
Collaborator

@deeglaze deeglaze commented May 3, 2024

Depends on PR#445

This adds an extra validation check beyond well-formedness that the verification step checks. If the reference values are available within the SEV-SNP attestation certificate chain, then verify the signature and check the report measurement against the golden values.

@deeglaze
Copy link
Collaborator Author

deeglaze commented Jun 3, 2024

/gcbrun

@deeglaze deeglaze requested a review from jkl73 June 4, 2024 00:51
@deeglaze
Copy link
Collaborator Author

deeglaze commented Jun 4, 2024

@jkl73 not sure what to make of the CS presubmit failure.

@jkl73
Copy link
Contributor

jkl73 commented Jun 4, 2024

@jkl73 not sure what to make of the CS presubmit failure.

just ignore the error now.. I'm still trying to fix the the build

@jkl73
Copy link
Contributor

jkl73 commented Jun 5, 2024

@jkl73 not sure what to make of the CS presubmit failure.

just ignore the error now.. I'm still trying to fix the the build

@deeglaze could you rebase this PR and run the CS presubmit again, I think I fixed it (hopefully..)

@jkl73
Copy link
Contributor

jkl73 commented Jun 5, 2024

/gcbrun

@deeglaze deeglaze requested a review from alexmwu June 6, 2024 01:24
// digest, or otherwise presented as cached collateral with the attestation
// itself. The method of delivery is vendor-specific.
message RIMPolicy {
// If true, the signed measurement must be available and the target
Copy link
Contributor

Choose a reason for hiding this comment

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

available where? IIUC, this is the attestation certificate table, but we state it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It can be in the certificate table, a UEFI variable, a local file, downloadable given a URI, or any other means that could be specified by a vendor. I've updated the wording a little.

// measurement must be among the listed signed measurements.
// If false, then only error if there is a problem verifying the signed
// measurements when they are available.
bool require = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

How about cert_entry_required`?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

SGTM

server/policy.go Outdated
Validate: gceverify.SNPValidateFunc(&gceverify.Options{
RootsOfTrust: uefirot,
Now: time.Now(),
// TODO: No getter? Network fallback can be helpful.
Copy link
Contributor

Choose a reason for hiding this comment

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

What specifically do we need to do here? Is it to introduce a Getter/an option for a Getter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How do you feel about EvaluatePolicyOpt with a new *PolicyOptions argument? The EvaluatePolicy can use default options like Getter: trust.DefaultHTTPSGetter() and Now: time.Now() (Now moved to options to make evaluateSevSnpPolicy more deterministic and testable).

server/policy_test.go Show resolved Hide resolved
Comment on lines 211 to 214
dents2, err := os.ReadDir(outdir2)
if err != nil {
t.Fatal(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be missing something, but I don't see where we use outdir2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removing..

@@ -18,10 +19,17 @@ require (
github.com/google/go-configfs-tsm v0.2.2 // indirect
github.com/google/go-tspi v0.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a really bizarre dependency to see

@@ -13,7 +19,69 @@ import (
// will describe in what way the state failed. See the Policy documentation for
// more information about the specifics of different policies.
func EvaluatePolicy(state *pb.MachineState, policy *pb.Policy) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Me want rego policy

Not related to your change, but would you be open to this being completely moved to a rego policy in the near future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would certainly. The issue is primarily populating the Rego context to know that the signed values are even available and their verification status.

server/policy.go Outdated

// the SEV-SNP attestation signature is already verified by this point.
func evaluateSevSnpPolicy(state *spb.Attestation, policy *pb.SevSnpPolicy) error {
if policy == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like a scary way to represent any "everything" policy to me. I feel like this is really easily done accidentally.
I don't know enough about protocol buffers to have a suggestion here, so perhaps when we have a different sort of policy language this concern will no longer be relevant.
WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

policy == nil should be understood as &pb.SevSnpPolicy{}. I've removed this check. The real concern is the policy.GetUefi() == nil check, since if I treat nil as &policy.RIMPolicy{}, then the behavior is different.

I can change the behavior to be like the evaluatePlatformPolicy, where at least one root has to be present to care about any signers. No signers means any value is okay. That would make the nil check and empty message the same.

I wouldn't want to start failing all policies because there are no signed measurements deployed yet. Do you want to depend on signed reference values right now? I suppose you could but then have failing tests internally until the signed firmware package finally rolls out.

Comment on lines 179 to 180
outdir := t.TempDir()
outdir2 := t.TempDir()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you define these closer to where they are used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed outdir2.

},
},
}
if err := EvaluatePolicy(ms, pol); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding tests cases for nil policy + nil UEFI policy

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, found a bug.

Copy link
Contributor

@JoshuaKrstic JoshuaKrstic left a comment

Choose a reason for hiding this comment

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

Overall LGTM. I have a small concern about the nil policy check

// add for policy reasons.
message SevSnpPolicy {
// The policy for checking the signed reference values for the UEFI at launch.
RIMPolicy uefi = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to make this policy not just specific to snp?

I wonder later if tdx can have a similar firmware policy check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The technologies will have signatures deployed at different dates. We can have them separate for now and then deprecate for an overarching one, later?

@deeglaze deeglaze force-pushed the gcetcb branch 2 times, most recently from c60a680 to c7614bc Compare June 10, 2024 20:22
@deeglaze
Copy link
Collaborator Author

/gcbrun

@deeglaze
Copy link
Collaborator Author

/gcbrun

@deeglaze deeglaze merged commit 6a70865 into google:main Jun 10, 2024
11 checks passed
@deeglaze deeglaze deleted the gcetcb branch June 10, 2024 23:13
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