feat(attest): envelope verifier CLI — AMD cert chain, TCB, measurement, report_data#9251
Merged
Conversation
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
❌ 17 Tests Failed:
View the top 3 failed test(s) by shortest run time
View the full list of 5 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #9212 (epic #8534): a CLI that lets anyone — no LoopOver contact, no hardware, no trust beyond AMD's own published root keys — answer "did this exact code run on this exact corpus inside genuine AMD SEV-SNP hardware?" for a published attestation envelope.
Why this took real research, not just implementation
Every byte offset, the ECDSA signature's exact on-the-wire encoding, and the AMD KDS certificate extension OIDs are security-critical facts I could not respectably guess from training data alone. Before writing any verification code I:
ATTESTATION_REPORTbyte layout, the packedTCB_VERSIONbyte-to-SVN mapping, and the ECDSA-P384-SHA384 signature's little-endian R||S encoding from google/go-sev-guest (Google's maintained, production attestation-verification library) — via GitHub code search against the actual repo, not memory.kdsintf.amd.com) and cryptographically verified them withopenssl verify(ARK self-signed, ASK signed by ARK) before vendoring them.openssl asn1parse's rendering) before trusting it for anything security-relevant.X509Certificate.verify()calls — never a mock that returns a cannedtrue.report_dataafter signing is caught assignature_invalid, notreport_data_mismatch— sincereport_datais itself inside the signed byte range, a forged value there fails the signature check first, exactly as it must for the tool to be trustworthy rather than just structurally plausible.What's in this PR
scripts/verify-attested-run-der.ts— a minimal, narrowly-scoped DER/BER reader (find an X.509 extension by OID, read a small DER INTEGER). Deliberately not a dependency on a general ASN.1 library: a tool whose whole purpose is "verify without trusting anyone" shouldn't itself require trusting an unaudited third-party parser.scripts/verify-attested-run-report.ts— pure SNP report parsing: all documented byte offsets,TCB_VERSIONdecomposition, and the AMD-little-endian-to-IEEE-P1363 signature conversion (crypto.verify(..., { dsaEncoding: "ieee-p1363" })).scripts/verify-attested-run-core.ts— the orchestration: sample-attester rejection → envelope structural validation (reusing calibration: attestation-evidence envelope — schema, pure structural validator, and report-data binding helper #8541'svalidateAttestationEnvelope) → report parsing → certificate chain of trust (pinned-root byte match + real ARK/ASK/VCEK signature verification) → report signature verification → TCB status → measurement →report_datare-derivation (reusing orb(attest): attested-run harness with pluggable attester — sample now, SNP by config #9211'sbuildAttestationReportData). Nothing about the report's own content is trusted until the chain AND the signature both pass.scripts/verify-attested-run.ts— the CLI:--envelope/--expected(required),--vcek-certor--fetch-vcek(opt-in AMD KDS network fetch — off by default),--ask-cert/--ark-cert(default to the vendored chain),--product milan|genoa,--allow-sample. Exit-code contract: 0 verified, 1-8 one per failure class, 9 usage/IO error.scripts/verify-attested-run/certs/{milan,genoa}-{ark,ask}.pem— the real ARK/ASK certificate chains, fetched live from AMD's KDS and cryptographically verified before vendoring.scripts/verify-attested-run/README.md— usage, the exit-code table, where every byte layout/OID came from, and an explicit "what this does NOT verify" section (the live decision path per Research: the attested-evaluation epic covers offline backtests only — decide whether the LIVE decision path needs attestation, and in what order #9141's deferral, image-provenance correlation which is orb(attest): reproducible pinned replay-runner image + digest manifest enforced in CI #9214's job, and CRL/revocation checking — a real, named, open gap, not silently glossed over).A note on the committed test fixtures
test/fixtures/verify-attested-run/synthetic-vcek-key.pemis a private key — but it is a purpose-generated, wholly synthetic test key with no relationship to any real credential, exactly the standard pattern crypto libraries use for reproducible signature-verification test fixtures (Node core's own test suite does the same). It cannot sign anything AMD's real chain would ever trust.Validation
npm run typecheck— clean.npm run import-specifiers:check— clean.npx vitest runon all three new core test files — 50/50 pass, 100% statement/branch/function/line coverage onverify-attested-run-der.ts,verify-attested-run-report.ts, andverify-attested-run-core.tscombined.measurement_mismatch(exit 7),sample_attestation(exit 1), missing-args usage error (exit 9), and a real (opt-in) network call to AMD's live KDS with graceful 404 handling (exit 9) for a fake chip ID.Safety
--fetch-vcekis opt-in; no network access happens by default, matching the issue's own requirement.