8000 Add Policy object for server-side remote attestation by alexmwu · Pull Request #103 · google/go-tpm-tools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add Policy object for server-side remote attestation #103

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

Merged
merged 30 commits into from
Oct 27, 2021

Conversation

alexmwu
Copy link
Contributor
@alexmwu alexmwu commented May 19, 2021

Users with an attestation server may want to apply a policy against a validated event log. A common use case might be validating secure configuration against expected values. For example, a server may want to check that a machine has updated its dbx and is not vulnerable to Boothole.

The policy object includes a firmware and secure boot related subpolicies. The firmware policy is mostly GCE instance related.

@josephlr josephlr mentioned this pull request Jun 18, 2021
@alexmwu alexmwu force-pushed the policy branch 2 times, most recently from 0a065da to 788ac80 Compare June 22, 2021 23:27
@josephlr
Copy link
Member

@alexmwu I didn't have time to make any changes to this yesterday. But I opened #113

It should have all the necessary embedded data for this PR. So can you:

I didn't include the dbx binary files as they are unused (and shouldn't be in this PR).

@google-cla
Copy link
google-cla bot commented Jul 1, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@josephlr
Copy link
Member
josephlr commented Jul 1, 2021

@googlebot I consent.

@josephlr
Copy link
Member
josephlr commented Sep 1, 2021

@alexmwu this is all of the MachineState changes expect for extracting the PlatformState stuff. PTAL

The big changes are in server/verify.go where we actually do the attesation verification. We also have the ParseAndReplayEventLog function which will be expanded to hold whatever future state we want to add to MachineStae.

Copy link
Contributor Author
@alexmwu alexmwu left a comment

Choose a reason for hiding this comment

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

I don't see PlatformPolicy evaluation logic. Did you intentionally remove this?

For everything else: mostly nits, but I have a few documentation questions.

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
This makes the meaning clearer. We also split out some functionality
into a helper function to make future methods easier to implement.

This method now returns a `pb.MachineState`, making it easier to add
functionality going forward.

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
This is for consistancy with VerifyOpts/SealOpts/UnsealOpts

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
Instead of hard-coding sha256, we now allow aribitary hash algorithms to
be use for verification. We will iteratate through a defined list of
supported hash algorithms, taking the first algorithm that produces a
valid MachineState.

We also now explictly check if the signing hash and the pcr hash are
supported by the library.

Signed-off-by: Joe Richey <joerichey@google.com>
Copy link
Contributor Author
@alexmwu alexmwu left a comment

Choose a reason for hiding this comment

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

looks good for the event stuff. mostly nits


if (event.GetUntrustedType() == Separator) || bytes.Equal(event.GetDigest(), separatorDigest) {
// Make sure we have a valid separator event
if !(event.GetUntrustedType() == Separator) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if you're just checking on the digest, why not remove the first statement in the or.
So something like:

if bytes.Equal(event.GetDigest(), separatorDigest) {
   if event.GetUntrustedType() != Separator {
      return nil, fmt.Errorf(...)
   }

Copy link
Member

Choose a reason for hiding this comment

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

We want to make sure that if we see a event with a type of Separator but having the wrong data, we raise an error.

I added some more comments, PTAL.

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
@josephlr josephlr requested review from iKevinY and josephlr and removed request for josephlr and twitchy-jsonp October 15, 2021 09:14
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
@josephlr
Copy link
Member

@alexmwu @iKevinY I've added the policy evaluation logic and some basic tests. Could you two add more tests and merge this when it looks good to you?

Note: This PR should be Merged not squashed. Also when adding commits, be sure to not mess up the tag: v0.3.0-beta1 tag. I.E. feel free to rewrite the history of your own commits, but not mine, and don't rebase this PR.

@@ -46,7 +46,7 @@

#include <openssl/evp.h>
#include <openssl/ec.h>
#if OPENSSL_VERSION_NUMBER >= 0x10200000L
#if 0 // OPENSSL_VERSION_NUMBER >= 0x10200000L
Copy link

Choose a reason for hiding this comment

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

Is this change intentional / documented anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here's the failing test: https://github.com/google/go-tpm-tools/runs/3903970801?check_suite_focus=true.

The comment tells us to

    // Check the bignum_st definition in crypto/bn/bn_lcl.h and either update the
    // version check or provide the new definition for this version.

seeing as this version works for all builds, I think we can consider the version definition "updated"

This only tests PlatformPolicy at the moment, including
GCE confidential technology, GCE firmware version, and SCRTM.
The collected gLinux workstation event log has issues where the firmware
extends a separator event (four 0x00 bytes) into PCR0, using
EV_S_CRTM_CONTENTS.
This conflicts with the logic that checks for separator events using
only the event data (and ignoring the untrustworthy event type).
The TPM PFP spec says that separator values must be four 00 bytes
or four ff bytes. This commit extends support for the ff bytes.
Also, fix linter issues
Copy link
Contributor Author
@alexmwu alexmwu left a comment

Choose a reason for hiding this comment

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

LGTM for Joe's commits, with perhaps a follow up of exposing partial failures/multiple errors

@alexmwu alexmwu requested a review from jkl73 October 20, 2021 00:49
Return an error on bad platform state parsing. Not returning an error
masks problems with parsing the MachineState; we will eventually need to
support multiple parsing errors anyway.
Change separator parsing error message to convey the concern about
separator events getting changed to different event types.
Remove unsupported gLinux event log from the tests.
Copy link
@iKevinY iKevinY left a comment

Choose a reason for hiding this comment

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

Other than my open comments, LGTM.

Copy link
Contributor
@jkl73 jkl73 left a comment

Choose a reason for hiding this comment

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

LGTM

@alexmwu alexmwu merged commit 83ded98 into google:master Oct 27, 2021
@alexmwu alexmwu deleted the policy branch October 27, 2021 00:40
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.

5 participants
0