Repository navigation
support validation of key responses - #9
Conversation
| @@ -0,0 +1,5 @@ | |||
| { | |||
| "pcr_sets": [ | |||
There was a problem hiding this comment.
This will be populated each time a new enclave is deployed to production - at first manually, later via an automatic process. This will start to be populated after the validation library is finalized for both key and auction attestations.
| @@ -0,0 +1,50 @@ | |||
| package parsing | |||
There was a problem hiding this comment.
This file can be moved to the validation package once we stop sending JSON representation of the attestation document in key/auction responses.
peterldowns
left a comment
There was a problem hiding this comment.
Makes sense overall. To note what we discussed IRL — basically, the auction response includes data that come as a result of parsing the CBOR signature. What this PR does is also add the actual signature to the auction response, and the scripts necessary to validate that signature.
Two small notes on the verification cli logging format but up to you to decide if that happens now or as a followup.
Actual signature verification code looks reasonable and I trust your testing.
| os.Exit(0) | ||
| } | ||
|
|
||
| func showUsage() { |
There was a problem hiding this comment.
This actually may be a place where directly using fmt.Printf is more appropriate than using structured logging. I see the trick with the plaintext handler above, but I doubt anyone would ever want to see the usage information using json-formatted logs — most CLIs always print usage as plaintext regardless of other log format settings.
| logger.Info(fmt.Sprintf(" PCRs Valid: %v", result.PCRsValid)) | ||
| logger.Info(fmt.Sprintf(" Certificate Valid: %v", result.CertificateValid)) | ||
| logger.Info(fmt.Sprintf(" Signature Valid: %v", result.SignatureValid)) | ||
| logger.Info(fmt.Sprintf(" Public Key Match: %v", result.PublicKeyMatch)) |
There was a problem hiding this comment.
I'd say probably just drop the json-formatted logging concept entirely, not really being used by the code anywhere?
This reverts commit 95c6dd6.
## Summary - Remove `validation.ExtractCOSEPayload`, which has no callers. Commit b8df5fe (#14) removed its last two callers, in `validateCommonAttestation` and `parseKeyAttestationFromCOSE`, when parsing moved to `AttestationCOSE.ParseAttestationDoc`. Its message describes this as "removing redundant `ExtractCOSEPayload()` step", but the function itself stayed. - `VerifyCOSESignature` parses the COSE_Sign1 array itself, so `validation/cose.go` keeps all of its imports. No test exercised the function. ## Notes for reviewers `validation` is the client-facing verification package added in #9, and this change removes an exported symbol from it. The function is not in the package's documented usage, it existed only to serve the two callers that #14 removed, and the module has no tagged releases. GitHub code search finds no Go references outside this file. ## Pre-merge checklist - [x] No callers: on `main`, `git grep -w ExtractCOSEPayload` finds only the definition in this repository and nothing in cloudx-io/openarbiter. On this branch it finds nothing, and `deadcode -test ./...` no longer reports the function. - [x] Build and vet pass: `go build ./...` and `go vet ./...`. - [x] Lint passes: `mise run lint`. - [x] Tests pass: `go test ./...`. - [x] The enclave binary does not change: `go list -deps ./enclave/...` is identical before and after and does not include `validation`. The enclave binary, built as in `docker.yml` with `-buildvcs=false`, has the same SHA-256 on `main` and on this branch for both arm64 and amd64. - [x] The diff contains only the function deletion, and `git diff --check` passes. - [x] GitHub Actions checks pass on this branch: test, lint and Ratchet Lint. ## Post-deploy/apply verification - [ ] The Go, Docker Build and Build EIF runs on `main` for the merge commit pass, including `update-pcrs`. That run records new PCRs, as for every commit on `main`. This change does not alter the enclave's compiled code.
## Summary - Delete the `enclaveapi/parsing` package. Its three exported functions (`FormatPCR`, `EncodeCertificateBundle` and `ExtractPCRs`) have no importers in this repository, in cloudx-io/openarbiter or in the private CloudX repositories that consume this module. `AttestationCOSE.ParseAttestationDoc()` in `enclaveapi/types.go` already does the same PCR formatting (through its own unexported `formatPCR`) and certificate-bundle encoding. - The enclave binary does not import the package. `go list -deps ./enclave/...` (with and without `-test`) is identical before and after the deletion. With the CI build flags and `-buildvcs=false`, the enclave binary is byte-identical before and after for linux/amd64 and linux/arm64. The CI build embeds the commit SHA, so the PCRs recorded for the merge commit differ from the previous entry, as they do for every commit. ## Notes for reviewers - #9 added the package as shared parsing utilities to remove duplicated code. #14 moved that parsing into `AttestationCOSE.ParseAttestationDoc()` and removed every import of the package, so that reason no longer applies. - The module has no release tags, so consumers pin pseudo-versions. An external importer of `enclaveapi/parsing` would fail to build when it upgrades past this commit. GitHub code search for `enclaveapi/parsing` returns no results. #77 removed unused exported API on the same basis. ## Pre-merge checklist - [x] No importers: an unfiltered `git grep -n 'enclaveapi/parsing'` on a fresh `origin/main` of this repository, cloudx-io/openarbiter and the consuming private repositories returns nothing, and `deadcode -test ./...` reports all three functions as unreachable. - [x] Enclave dependency graph unchanged: `go list -deps ./enclave/...` and `go list -deps -test ./enclave/...` are identical before and after, and the `-buildvcs=false` enclave binaries are byte-identical for linux/amd64 and linux/arm64. - [x] Build passes: `go build ./...` and `go vet ./...`. - [x] Lint passes: `mise run //:lint` (0 issues) and `mise run //:tidy`. - [x] Tests pass: `go test ./...`. - [x] GitHub Actions checks pass on this branch: Go (test, lint), Ratchet Lint and [Docker Build](https://github.com/cloudx-io/openauction/actions/runs/36876325009). - [x] Diff contains only the deletion of `enclaveapi/parsing/nitro.go`. ## Post-deploy/apply verification - [ ] The next Go, Docker Build and Build EIF runs on main pass for the merge commit, including the `update-pcrs` job.
Support Validation of Key Responses
Summary
Adds a validation library that enables clients to cryptographically verify TEE key attestations.
This PR introduces:
validation/)attestation_cose_base64field inKeyResponseenclaveapi/parsing/to eliminate code duplicationThe validation library cryptographically proves that:
API Changes
New Field in KeyResponse
{ "type": "key_response", "public_key": "-----BEGIN PUBLIC KEY-----\n...", "attestation_cose_base64": "hEShATgi...", // NEW: Base64-encoded COSE_Sign1 "key_attestation": {...}, // DEPRECATED "tee_instance_ip": "10.10.1.199" }Backward Compatibility:
key_attestationfield still present (marked deprecated)attestation_cose_base64Validation Library Usage
KeyValidationResult Fields:
PCRsValid- Code integrity verifiedCertificateValid- Certificate chain verifiedSignatureValid- COSE signature verifiedPublicKeyMatch- Public key matches attestationValidationDetails- Human-readable validation logIsValid()- Method that ANDs all checks togetherTesting
I've built an enclave from this branch and ran it in our internal systems. When the PCR measurements are added to
pcrs.json, I'm able to successfully validate the key response returned by the enclave.Planning on adding unit tests for CBOR handling once we've validated the approach in this PR.
Future work
pcrs.json.