← Back to Pull requests

fix(crypto): zeroize hpke's X25519 keys on drop #244

Closed
unknown closed this pull request without merging on Nov 15, 2026 10:53 UTC
View on GitHub
unknown unknown commented on Nov 14, 2026 09:07 UTC
Author

What and why

Fixes #245.

hpke 0.12 depends on x25519-dalek 2 with default-features = false, features = ["static_secrets"]. Nothing in the workspace or in backend/fuzz turned on its zeroize feature: cargo tree --workspace -e features -i x25519-dalek --locked listed only static_secrets. Without that feature, StaticSecret and SharedSecret are plain [u8; 32] newtypes with no drop glue, so hpke's X25519 private key had no Drop at all. That left the following freed without being wiped:

  • every tenant keypair: the key-release stand-in's per-query ReleasedKeySession, DevKeyProvider, MultiTenantDevKeyProvider and EnclaveIdentity's HPKE key;

  • every seal's ephemeral key;

  • every DH result.
  • This applies in the enclave and in the browser's wasm envelope module. README ("Status"), docs/ARCHITECTURE.md and key_release.rs already say these keys zeroize on drop.

    Changes:

  • platform-crypto gains a direct x25519-dalek 2 dependency. Its only job is to turn on zeroize, which Cargo unifies into hpke's copy. It lives in the crate, next to hpke's only user, rather than in the workspace dependencies.

  • TenantKeypair implements ZeroizeOnDrop. Its hand-written Drop is removed: it assigned a zero key with a plain move, which the optimizer may remove as a dead store, and StaticSecret now wipes itself with volatile writes.

  • backend/Cargo.lock and backend/fuzz/Cargo.lock change by two lines each. No package is added or moved.
  • This completes the key-material part of P52's zeroization item (#242). Since TenantKeypair is now ZeroizeOnDrop, P52's PR (#243, stacked on p45) can assert that at the type level for the key sessions.

    #228 (X-Wing HPK2) upgrades to hpke 0.14.1, which turns on zeroize for x25519-dalek 3, x-wing and ml-kem itself, so its keys wipe on drop without this dependency. Whichever of the two lands second reconciles platform-crypto/Cargo.toml and both lockfiles. Once #228 is in, the direct x25519-dalek 2 line should go, because otherwise a second, unused x25519-dalek stays in the tree. The test should then point at hpke 0.14's key types.

    How it was tested

  • New crate unit test x25519_secrets_zeroize_on_drop. x25519-dalek 2.0.1 derives #[zeroize(drop)], which adds a zeroizing Drop but no ZeroizeOnDrop marker. So the test asserts:

  • - Zeroize on StaticSecret and SharedSecret;
    - at compile time, needs_drop for both and for hpke's own private key type. That last check fails if hpke ever links an x25519-dalek without the feature.
  • Red first: on main, needs_drop is false for hpke's X25519 private key, so the check fails to compile. With the feature removed again, the test fails to compile.

  • cargo tree -e features -i x25519-dalek --locked lists static_secrets and zeroize for the workspace, for backend/fuzz, and for envelope-wasm on wasm32-unknown-unknown.
  • Checklist

  • scripts/check.sh passes locally. gitleaks is not installed here, so the secret scan was skipped; CI runs it.

  • Every new refusal has a negative test (no new refusals)

  • Every new security decision emits a SECURITY_AUDIT_EVENT covered by audit_coverage.rs (no new runtime decisions)

  • Fails closed on missing configuration, key material, or attestation (unchanged)

  • 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 (CHANGELOG.md under Security; the docs already describe this behaviour)

  • Architectural decision recorded in docs/adr/ if one was made (none made)
  • Diff: 456 lines (+342 / -114) across 5 files Reviewer: abendrothj Review duration: 1546m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.69) × (1 − Review Confidence (0.58)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.69 · 456 lines diff across 5 files
    0.69
    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%
    57%
    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.366
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.069
    Real PR Conversation Timeline
    1 comments
    "Review active on #244"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 58.0% reviewed sensitive_module
    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: 68.7% (HIGH) · Higher = larger blast radius
    68.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: 58.0% · Lower = rushed or shallow review
    58.0%
    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: 28.8% · Safe to merge
    28.8%