← Back to Pull requests

feat(enclave): add the attestation foundation for sealed queries and results #249

Closed
unknown closed this pull request without merging on Nov 21, 2026 18:31 UTC
View on GitHub
unknown unknown commented on Nov 15, 2026 03:11 UTC
Author

What and why

Part of #176 (P85) and #177 (P55): the base both build on, so they can go ahead in parallel (#183). ADR 0010 decides the design; this PR builds the parts that don't yet change behaviour.

Closes #39.

  • Result signatures (platform-crypto): Ed25519 and ML-DSA-65 together, both required (ADR 0007), over ADR 0010's domain-separated message. ML-DSA signs deterministically with an empty context. Keys come from zeroized seeds; Debug prints neither.

  • research_query info string and query binding (the query field of research_result), in Rust, the wasm module and the TS wrapper, pinned in fixtures/envelope/hpk1.json.

  • Binding v2 (platform-enclave): EnclaveKeyBinding replaces ReportDataBinding's fixed 32-byte fields with ADR 0010's labelled, length-prefixed values.

  • Enclave key set (EnclaveIdentity): an HPK2 request key, with its private half now in every build, and a result-signing key, with a key_id. GET /api/v1/attestation takes the caller's nonce as ?nonce= (32 bytes, base64url; 400 when it is missing or malformed) and returns ADR 0010's evidence bundle (v1's platform and config_digest fields go; the browser recomputes the config digest from the token). The dev key-release stand-in checks binding v2 and refuses a request key that is not HPK2, audited as crypto.suite_refused. The bundle's token carries the browser audience (urn:platform:browser-attestation), which key release refuses.

  • Sealed-query wire types, not routed yet. The opened request's SQL is redacted from Debug and wiped on drop (best-effort; see ADR 0010), also when a later field fails to parse. parse() refuses more than 64 KiB before decoding.

  • ADR 0005 and ADR 0010 are accepted.
  • Left for P85: exact nonce matching in TokenVerifier, the config digest from the environment (until then, with ENCLAVE_CONFIG_DIGEST_HEX set, a client can't recompute key_id), the replay store, the command-line checker and the threat-model rows. Left for P55: sealing and the signed response.

    GET /api/v1/attestation's 400 is input validation on an unauthenticated route, so it emits no audit event (ARCHITECTURE, Security telemetry, rule 2).

    Stacked on #228; #233 is stacked on this.

    New dependency: ml-dsa 0.1.2 (RustCrypto, Apache-2.0 OR MIT, named in ADR 0007; passes cargo deny). ed25519-dalek 2.2 was already in the tree through jsonwebtoken and is now a direct dependency. platform-api turns on zeroize's serde feature for the SQL field.

    For reviewers: the request key is now HPK2, while the browser module seals HPK1 until P36 (#186), so P85's browser half (#239) waits on P36 or widens the module.

    How it was tested

  • Byte layouts pinned by values computed independently from ADR 0010: the binding digest and key_id, both query bindings, and the signature message.

  • Signatures: a forged Ed25519 signature, a forged ML-DSA signature, and a valid ML-DSA signature over another message are each refused; so are a byte moved between info and frame, another key, and wrong lengths.

  • Key release: swapping either signing key is refused with 403 and a crypto.key_release denial; a token correctly bound to an HPK1 request key is refused with 403 and both crypto.key_release and crypto.suite_refused (the test fails under the development suite policy and passes under production).

  • The public evidence token presented to key release is refused with 403 and a crypto.key_release denial; a browser token minted over HTTP passes only the browser verifier; a sealed query plaintext over 64 KiB is refused before decoding.

  • Sealed types: unknown fields refused, the nonce must be 32 bytes, the SQL is not in Debug output.

  • scripts/check.sh passes, and backend/fuzz builds with --locked. CI runs scripts/test-simulated-tee.sh.
  • Checklist

  • scripts/check.sh passes locally

  • Every new refusal has a negative test

  • Every new security decision emits a SECURITY_AUDIT_EVENT covered by audit_coverage.rs (the stand-in's refusals use its crypto.key_release denials, and the HPK2 check also emits crypto.suite_refused)

  • Fails closed on missing configuration, key material, or attestation

  • No new cryptographic primitives; suites stay behind their type aliases

  • Synthetic or public data only (docs/DATA_POLICY.md)

  • Docs and CHANGELOG.md updated for user-visible changes

  • Architectural decision recorded in docs/adr/ if one was made (ADR 0005 and ADR 0010 accepted)
  • Diff: 565 lines (+423 / -142) across 7 files Reviewer: abendrothj Review duration: 9559m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.50) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 565 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.379
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #249"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.7% (MEDIUM) · Higher = larger blast radius
    49.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.5% · Safe to merge
    21.5%