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

[launcher] Support TDX RTMR based attestation in launcher #478

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

jkl73
Copy link
Contributor

@jkl73 jkl73 commented Aug 20, 2024

Allow a TDX machine to create a TD quote and request a hardware rooted attestation from the attestation verifier.

./launcher ci will now only run in linux. (because launcher now depends on *tg.LinuxConfigFsQuoteProvider which only presents in linux)

@jkl73 jkl73 changed the base branch from tdx_rtmr to main August 20, 2024 01:02
@jkl73 jkl73 force-pushed the tdxrmtr branch 4 times, most recently from c75591b to b9c1240 Compare August 20, 2024 02:30
@jkl73
Copy link
Contributor Author

jkl73 commented Aug 20, 2024

/gcbrun

@jkl73
Copy link
Contributor Author

jkl73 commented Aug 20, 2024

/gcbrun

@jkl73
Copy link
Contributor Author

jkl73 commented Aug 20, 2024

/gcbrun

@jkl73
Copy link
Contributor Author

jkl73 commented Oct 8, 2024

/gcbrun

@jkl73 jkl73 force-pushed the tdxrmtr branch 3 times, most recently from 9df421f to 7244331 Compare October 9, 2024 08:22
@jkl73
Copy link
Contributor Author

jkl73 commented Oct 9, 2024

/gcbrun

@jkl73 jkl73 force-pushed the tdxrmtr branch 6 times, most recently from 6307fc9 to 952db42 Compare October 9, 2024 18:51
@jkl73
Copy link
Contributor Author

jkl73 commented Oct 9, 2024

/gcbrun

@jkl73 jkl73 changed the title [launcher] support TDX RTMR measurements [launcher] Support TDX RTMR based attestation in launcher Oct 9, 2024
client/attest.go Outdated Show resolved Hide resolved
client/attest.go Outdated Show resolved Hide resolved
@jkl73 jkl73 changed the base branch from main to tdx_rtmr October 9, 2024 21:03
@jkl73
Copy link
Contributor Author

jkl73 commented Oct 9, 2024

/gcbrun

Copy link
Contributor

@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.

The verifier build is failing

// If an error is encountered in the process, return what has been constructed so far.
func (k *Key) getCertificateChain(client *http.Client) ([][]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

don't export this. put this in internal somewhere and take a key.

func getCertificateChain(cert *x509.Certificate, client *http.Client) ([][]byte, error)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to internal/cert.go

client/attest.go Outdated Show resolved Hide resolved
@@ -7,7 +7,7 @@ require (
github.com/google/go-attestation v0.5.1
github.com/google/go-cmp v0.6.0
github.com/google/go-configfs-tsm v0.3.3-0.20240910040719-1cc7e25d9272
github.com/google/go-sev-guest v0.11.1
github.com/google/go-sev-guest v0.11.2-0.20241009005433-de2ac900e958
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we updating this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

launcher/agent/agent.go Outdated Show resolved Hide resolved
launcher/agent/agent.go Outdated Show resolved Hide resolved
launcher/agent/agent.go Outdated Show resolved Hide resolved
launcher/agent/agent.go Outdated Show resolved Hide resolved
launcher/agent/agent.go Outdated Show resolved Hide resolved
launcher/agent/agent.go Outdated Show resolved Hide resolved
launcher/agent/agent.go Outdated Show resolved Hide resolved
launcher/agent/agent.go Outdated Show resolved Hide resolved
launcher/agent/agent.go Outdated Show resolved Hide resolved
launcher/agent/agent.go Outdated Show resolved Hide resolved
launcher/agent/agent.go Outdated Show resolved Hide resolved
launcher/agent/agent.go Outdated Show resolved Hide resolved
@@ -1,7 +1,7 @@
substitutions:
'_BASE_IMAGE': '' # an empty base image means the build will use the latest image in '_BASE_IMAGE_FAMILY'
'_BASE_IMAGE_FAMILY': 'cos-113-lts' # base image family
'_OUTPUT_IMAGE_PREFIX': 'confidential-space'
'_BASE_IMAGE_FAMILY': 'cos-tdx-113-lts' # base image family
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: so I'm assuming cos-tdx-113-lts family will also work for SEV-based CS image?

Copy link
Contributor Author

@jkl73 jkl73 Oct 10, 2024

Choose a reason for hiding this comment

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

yes, it's SEV_CAPABLE as well

@jkl73
Copy link
Contributor Author

jkl73 commented Oct 10, 2024

/gcbrun

verifier/client.go Outdated Show resolved Hide resolved
Comment on lines +213 to +268
type tpmAttestRoot struct {
tpmMu sync.Mutex
fetchedAK *client.Key
tpm io.ReadWriteCloser
}

func (t *tpmAttestRoot) Extend(c cel.Content, l *cel.CEL) error {
return l.AppendEventPCR(t.tpm, cel.CosEventPCR, defaultCELHashAlgo, c)
}

func (t *tpmAttestRoot) Attest(nonce []byte) (any, error) {
t.tpmMu.Lock()
defer t.tpmMu.Unlock()

return t.fetchedAK.Attest(client.AttestOpts{
Nonce: nonce,
CertChainFetcher: http.DefaultClient,
})
}

type tdxAttestRoot struct {
tdxMu sync.Mutex
qp *tg.LinuxConfigFsQuoteProvider
tsmClient configfsi.Client
}

func (t *tdxAttestRoot) Extend(c cel.Content, l *cel.CEL) error {
return l.AppendEventRTMR(t.tsmClient, cel.CosRTMR, c)
}

func (t *tdxAttestRoot) Attest(nonce []byte) (any, error) {
t.tdxMu.Lock()
defer t.tdxMu.Unlock()

var tdxNonce [tlabi.TdReportDataSize]byte
copy(tdxNonce[:], nonce)

rawQuote, err := tg.GetRawQuote(t.qp, tdxNonce)
if err != nil {
return nil, err
}

ccelData, err := os.ReadFile("/sys/firmware/acpi/tables/data/CCEL")
if err != nil {
return nil, err
}
ccelTable, err := os.ReadFile("/sys/firmware/acpi/tables/CCEL")
if err != nil {
return nil, err
}

return &verifier.TDCCELAttestation{
CcelAcpiTable: ccelTable,
CcelData: ccelData,
TdQuote: rawQuote,
}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these live in attest.go instead of here?

Copy link
Contributor

Choose a reason for hiding this comment

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

No. Really most of this should belong in go-tdx-guest, but it's okay to be here for now.

Comment on lines -82 to -84
if: (runner.os == 'Linux' || runner.os == 'macOS') && matrix.architecture == 'x64'
- name: Test all modules
run: go test -v ./... ./cmd/... ./launcher/... ./verifier/... -skip='TestCacheConcurrentSetGet|TestHwAttestationPass|TestHardwareAttestationPass'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

launcher now depends on LinuxConfigFsQuoteProvider (which is in tdxAttestRoot). Which can be only complied on Linux. So trying to compile launcher on mac will fail

Comment on lines +213 to +268
type tpmAttestRoot struct {
tpmMu sync.Mutex
fetchedAK *client.Key
tpm io.ReadWriteCloser
}

func (t *tpmAttestRoot) Extend(c cel.Content, l *cel.CEL) error {
return l.AppendEventPCR(t.tpm, cel.CosEventPCR, defaultCELHashAlgo, c)
}

func (t *tpmAttestRoot) Attest(nonce []byte) (any, error) {
t.tpmMu.Lock()
defer t.tpmMu.Unlock()

return t.fetchedAK.Attest(client.AttestOpts{
Nonce: nonce,
CertChainFetcher: http.DefaultClient,
})
}

type tdxAttestRoot struct {
tdxMu sync.Mutex
qp *tg.LinuxConfigFsQuoteProvider
tsmClient configfsi.Client
}

func (t *tdxAttestRoot) Extend(c cel.Content, l *cel.CEL) error {
return l.AppendEventRTMR(t.tsmClient, cel.CosRTMR, c)
}

func (t *tdxAttestRoot) Attest(nonce []byte) (any, error) {
t.tdxMu.Lock()
defer t.tdxMu.Unlock()

var tdxNonce [tlabi.TdReportDataSize]byte
copy(tdxNonce[:], nonce)

rawQuote, err := tg.GetRawQuote(t.qp, tdxNonce)
if err != nil {
return nil, err
}

ccelData, err := os.ReadFile("/sys/firmware/acpi/tables/data/CCEL")
if err != nil {
return nil, err
}
ccelTable, err := os.ReadFile("/sys/firmware/acpi/tables/CCEL")
if err != nil {
return nil, err
}

return &verifier.TDCCELAttestation{
CcelAcpiTable: ccelTable,
CcelData: ccelData,
TdQuote: rawQuote,
}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

No. Really most of this should belong in go-tdx-guest, but it's okay to be here for now.

Comment on lines +255 to +259
ccelData, err := os.ReadFile("/sys/firmware/acpi/tables/data/CCEL")
if err != nil {
return nil, err
}
ccelTable, err := os.ReadFile("/sys/firmware/acpi/tables/CCEL")
Copy link
Contributor

Choose a reason for hiding this comment

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

I am surprised there's no utilities for this in go-tdx-guest. There should be.

Copy link
Contributor Author

@jkl73 jkl73 Oct 10, 2024

Choose a reason for hiding this comment

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

@@ -21,7 +21,7 @@ steps:
if [ -z ${base_image} ]
then
echo "getting the latest COS image"
base_image=$(gcloud compute images describe-from-family ${BASE_IMAGE_FAMILY} --project cos-cloud | grep name | cut -d ' ' -f 2)
base_image=$(gcloud compute images describe-from-family ${BASE_IMAGE_FAMILY} --project confidential-vm-images | grep name | cut -d ' ' -f 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we changing the project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

COS TDX_capable images are not released in regular cos-cloud project

verifier/client.go Outdated Show resolved Hide resolved
verifier/client.go Outdated Show resolved Hide resolved
verifier/rest/rest.go Outdated Show resolved Hide resolved
@google google deleted a comment from jkl73 Oct 10, 2024
@google google deleted a comment from jkl73 Oct 10, 2024
Allow a TDX machine to create a TD quote and request a hardware
rooted attestation from the attestation verifier.

./launcher ci will now only run in linux.

Upgrade go-sev-guest.

Signed-off-by: Jiankun Lu <jiankun@google.com>
@jkl73
Copy link
Contributor Author

jkl73 commented Oct 10, 2024

/gcbrun

@jkl73 jkl73 merged commit c38b622 into google:tdx_rtmr Oct 11, 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.

5 participants