feat: implement SGX attestation verification#31
Merged
yingyangxu2026 merged 2 commits intomainfrom Apr 9, 2026
Merged
Conversation
Parse SGX DCAP Quote v3 binary to extract and verify MRENCLAVE, MRSIGNER, and ISV SVN against user-provided configuration. attestation.ts: - parseSgxQuote(): extract fields from raw SGX quote binary - verifyAttestation(): check extracted fields against AttestationConfig - Offsets verified against SGXValidationHook.sol in piplabs/story observer.ts: - getValidatorAttestations(): new method to fetch enclaveReport bytes from DKG Registered events, keyed by validator address - Includes 7-day lookback with fallback to block 0 Note: This is client-side field verification only. Cryptographic signature chain (Intel QE → PCK → root CA) is verified on-chain by SGXValidationHook via Automata DCAP contracts.
5d544e7 to
8c285a7
Compare
|
Overall the implementation is clean and well-structured. A few correctness/security findings worth addressing:
Review iteration 2 · Commit 3fe2c60 · 2026-04-09T07:31:07Z |
- attestation.ts: add SGX quote version guard (bytes 0-1 must be 3 for DCAP v3). Rejects Quote v4/TDX quotes that have different report-body offsets and would produce incorrect MRENCLAVE/MRSIGNER. - observer.ts: getValidatorAttestations no longer silently falls back to block 0 when caller explicitly provides fromBlock. Only auto-fallback when using the default lookback window.
Collaborator
Author
|
Both addressed in 3fe2c60:
|
lucas2brh
approved these changes
Apr 9, 2026
barry-peng-story
approved these changes
Apr 9, 2026
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
Implements client-side SGX attestation verification for CDR SDK, replacing the placeholder that threw
Error("not yet implemented").Closes #30
Changes
attestation.tsparseSgxQuote(report): Parse SGX DCAP Quote v3 binary to extract MRENCLAVE, MRSIGNER, ISV SVNverifyAttestation(report, config): Verify extracted fields against user-providedAttestationConfigSGXValidationHook.solin piplabs/storySGX DCAP Quote v3 layout:
observer.tsgetValidatorAttestations(params?): New method to fetchenclaveReportbytes from DKGRegisteredevents, keyed by validator addressUsage
Note
This is client-side field verification only. The cryptographic signature chain (Intel QE → PCK → root CA) is verified on-chain by
SGXValidationHookvia Automata DCAP contracts. This provides defense-in-depth for SDK consumers.Test Plan
parseSgxQuotewith known quote bytes — SEC-08a (mock 432-byte quote, verify exact MRENCLAVE/MRSIGNER/SVN extraction)verifyAttestationwith matching/mismatching config — SEC-08bf (positive), SEC-08gm (negative: empty, too-short, MRENCLAVE/MRSIGNER/SVN mismatch, short-circuit)getValidatorAttestationsreturns non-empty map on devnet — SEC-08n (3 validators, 4734-byte real SGX quotes), SEC-08o (all share MRENCLAVE0x032821cf1c...), SEC-08p (wrong config rejected)CI run: piplabs/story-cdr-e2e#84 — 24/24 passed (16 SEC-08 sub-tests + 8 other security tests)