-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attestation: validate GCP machine state instead of PCR 0
- Loading branch information
Showing
14 changed files
with
58 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,11 @@ SPDX-License-Identifier: AGPL-3.0-only | |
package gcp | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"crypto" | ||
"crypto/x509" | ||
"encoding/json" | ||
"encoding/pem" | ||
"errors" | ||
"fmt" | ||
"time" | ||
|
||
|
@@ -23,11 +21,12 @@ import ( | |
"github.com/edgelesssys/constellation/v2/internal/attestation/vtpm" | ||
"github.com/edgelesssys/constellation/v2/internal/oid" | ||
"github.com/google/go-tpm-tools/proto/attest" | ||
"github.com/google/go-tpm-tools/server" | ||
"github.com/googleapis/gax-go/v2" | ||
"google.golang.org/api/option" | ||
) | ||
|
||
const minimumGceVersion = 1 | ||
|
||
// Validator for GCP confidential VM attestation. | ||
type Validator struct { | ||
oid.GCPSEVES | ||
|
@@ -40,7 +39,7 @@ func NewValidator(pcrs measurements.M, log vtpm.AttestationLogger) *Validator { | |
Validator: vtpm.NewValidator( | ||
pcrs, | ||
trustedKeyFromGCEAPI(newInstanceClient), | ||
gceNonHostInfoEvent, | ||
validateCVM, | ||
log, | ||
), | ||
} | ||
|
@@ -102,22 +101,18 @@ func trustedKeyFromGCEAPI(getClient func(ctx context.Context, opts ...option.Cli | |
} | ||
} | ||
|
||
// gceNonHostInfoEvent looks for the GCE Non-Host info event in an event log. | ||
// Returns an error if the event is not found, or if the event is missing the required flag to mark the VM confidential. | ||
func gceNonHostInfoEvent(attDoc vtpm.AttestationDocument) error { | ||
if attDoc.Attestation == nil { | ||
return errors.New("missing attestation in attestation document") | ||
} | ||
// The event log of a GCE VM contains the GCE Non-Host info event | ||
// This event is 32-bytes, followed by one byte 0x01 if it is confidential, 0x00 otherwise, | ||
// followed by 15 reserved bytes. | ||
// See https://pkg.go.dev/github.com/google/[email protected]/server#pkg-variables | ||
idx := bytes.Index(attDoc.Attestation.EventLog, server.GCENonHostInfoSignature) | ||
if idx <= 0 { | ||
return fmt.Errorf("event log is missing GCE Non-Host info event") | ||
// validateCVM checks that the machine state represents a GCE AMD-SEV VM. | ||
func validateCVM(attDoc vtpm.AttestationDocument, state *attest.MachineState) error { | ||
gceVersion := state.Platform.GetGceVersion() | ||
if gceVersion < minimumGceVersion { | ||
return fmt.Errorf("outdated GCE version: %v (require >= %v)", gceVersion, minimumGceVersion) | ||
} | ||
if attDoc.Attestation.EventLog[idx+len(server.GCENonHostInfoSignature)] != 0x01 { | ||
return fmt.Errorf("GCE Non-Host info is missing confidential bit") | ||
|
||
tech := state.Platform.Technology | ||
wantTech := attest.GCEConfidentialTechnology_AMD_SEV | ||
if tech != wantTech { | ||
return fmt.Errorf("unexpected confidential technology: %v (expected: %v)", tech, wantTech) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters