Skip to content

support validation of key responses - #9

Merged
nickpell merged 11 commits into
mainfrom
nick/key-validation
Dec 8, 2025
Merged

nickpell merged 11 commits into
mainfrom
nick/key-validation

Conversation

@nickpell

@nickpell nickpell commented Dec 4, 2025 •

Copy link
Copy Markdown
Member

Support Validation of Key Responses

Summary

Adds a validation library that enables clients to cryptographically verify TEE key attestations.

This PR introduces:

  1. A customer-facing validation library (validation/)
  2. COSE_Sign1 attestation parsing and signature verification
  3. Support for the new attestation_cose_base64 field in KeyResponse
  4. Shared parsing utilities in enclaveapi/parsing/ to eliminate code duplication

The validation library cryptographically proves that:

  • The public key was generated inside a genuine AWS Nitro Enclave
  • The enclave is running known, audited code (PCR verification)
  • The attestation is signed by AWS Nitro hardware and hasn't been tampered with
  • The public key matches what's in the signed attestation

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_attestation field still present (marked deprecated)
  • Existing clients continue to work
  • New clients should use attestation_cose_base64

Validation Library Usage

import "github.com/cloudx-io/openauction/validation"

// Fetch key from TEE
keyResponse := ...

// Validate attestation
result, err := validation.ValidateKeyAttestation(
    keyResponse.AttestationCOSEBase64,
    keyResponse.PublicKey,
)

if err != nil {
    return fmt.Errorf("validation error: %w", err)
}

if !result.IsValid() {
    return errors.New("attestation validation failed")
}

// Safe to use keyResponse.PublicKey for encryption

KeyValidationResult Fields:

  • PCRsValid - Code integrity verified
  • CertificateValid - Certificate chain verified
  • SignatureValid - COSE signature verified
  • PublicKeyMatch - Public key matches attestation
  • ValidationDetails - Human-readable validation log
  • IsValid() - Method that ANDs all checks together

Testing

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

  1. Add auction attestation validation. The application validation is more complicated, so let's get this working with the simple key attestation validation first.
  2. After (1) add a README documenting all this.
  3. Unit tests for CBOR handling
  4. Add a process that third-parties can use to checkout a specific commit, build the docker container image and the EIF, then confirm that the PCRs match what we've listed in pcrs.json.

Comment thread validation/pcrs.json
@@ -0,0 +1,5 @@
{
"pcr_sets": [

@nickpell nickpell Dec 4, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@nickpell
nickpell requested a review from peterldowns December 4, 2025 22:58
Comment thread .golangci.yml Resolved
@@ -0,0 +1,50 @@
package parsing

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This file can be moved to the validation package once we stop sending JSON representation of the attestation document in key/auction responses.

@peterldowns peterldowns left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reverted to fmt.Printf: e0e1605

Comment thread validation/cmd/key-validator/main.go Outdated
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))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd say probably just drop the json-formatted logging concept entirely, not really being used by the code anywhere?

This reverts commit 95c6dd6.
@nickpell
nickpell merged commit 4215a1b into main Dec 8, 2025
@nickpell
nickpell deleted the nick/key-validation branch December 8, 2025 22:16
nickpell added a commit that referenced this pull request Oct 1, 2026
## 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.
nickpell added a commit that referenced this pull request Oct 1, 2026
## 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.
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.

2 participants