Skip to content

OpenSecret: move from our tinfoil-rs fork to upstream 0.3 - #1648

Draft
AnthonyRonning wants to merge 1 commit into
masterfrom
opensecret/tinfoil-upstream-v3
Draft

AnthonyRonning wants to merge 1 commit into
masterfrom
opensecret/tinfoil-upstream-v3

Conversation

@AnthonyRonning

@AnthonyRonning AnthonyRonning commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Why

OpenSecret pins our fork of tinfoil-rs because upstream could not verify V3 attestation for a named enclave. Upstream now can (their rewritten 0.3 line), and our upstream PR was closed as superseded. This moves us onto upstream so we stop maintaining a security-critical fork.

Draft until upstream tags a final v0.3.0. This pins the release candidate v0.3.0-rc.2. Before merge: bump the tag, the two outputHashes in flake.nix, and re-run the live tests below.

What changes

  • Dependency. tinfoil now comes from tinfoilsh/tinfoil-rs at v0.3.0-rc.2, without its OpenAI feature (we only use the attested HTTP client). The lockfile loses about 20 crates and gains 4.
  • New module provider_client/attested.rs. Every SDK type lives here. The transport above it sees a verified client, finite failure labels and a send outcome.
  • Release policy (maple_inference.rs). The SDK pins a dedicated guest to one repository. Tag, digest and launch measurement are checked by our own MaplePolicy, which the SDK calls on every verification of that client, including the ones it runs by itself after a key rotation. Current and staged release lists per guest work as before.
  • Recovery. The background initialization, single-flight refresh and retry-once-when-provably-unsent logic are kept. The SDK now also re-verifies and replays once by itself when the enclave's key changes; our layer still runs after it.
  • Failure labels. The SDK's error is now a kind plus a source, not seventeen variants. Logged labels become configuration / network / attestation, with the verifier layer (envelope, provenance, quote, policy) or release_not_approved as the reason.

Behaviour changes to review

  1. TDX registers are no longer pinned. The fork compared all three registers of the multi-platform release measurement. Upstream projects the signed release measurement onto the platform the enclave runs on, so only the SEV-SNP launch measurement is compared. Both guests are AMD, and the policy rejects any TDX guest outright.
  2. The shared Tinfoil router now has a freshness deadline. Under 0.2 its verification never expired. To keep an expiry from taking a healthy route out of service, a verification is renewed an hour before its deadline with no request in hand (new, applies to the dedicated guests too). A client that still expires is dropped and replaced by background initialization, as the dedicated guests already did.
  3. Prompt-cache secret on the shared router. Per-user scoping is unchanged: every chat completion sent to Tinfoil (the shared executor and System One) gets OpenSecret's per-user user_cache_secret in the body, and the SDK never overwrites a non-empty one. The only Tinfoil request on an eligible path without one is System One's token-table probe (/v1/completions, fixed prompts, no user data); the SDK's router client now adds a per-process random secret to it instead of sending none. The dedicated guests use an enclave client, which adds nothing; their per-user cache_salt is unchanged.
  4. No new outbound hosts. The SDK contacts only atc.tinfoil.sh (router list), the routers it lists (today router-0.tinfoil.sh and inference.tinfoil.sh), the inference.tinfoil.sh fallback, and each enclave's own host for its attestation document. All are already in the enclave's host map and forwarders. Verification is offline, so the GitHub, Sigstore TUF and KDS hosts are no longer contacted; their forwarders are left in place, and removing them is a separate deploy change.
  5. A request can wait on a verification in one narrow case: the SDK re-verifies inline if a key rotation or an expiry races a request that already passed our freshness check. That wait is inside the caller's response-start timeout.

Tests

  • cargo fmt --check, cargo clippy --all-targets --all-features -D warnings, cargo test --all-features: 1217 passed, 107 ignored.
  • cargo deny check advisories bans: ok. Both existing ignores still apply and their notes are updated.
  • Nix vendoring (.#default.cargoDeps) builds with the new hashes. The EIF itself was not built locally.
  • Live, through the real ProviderClient, Nov 18:
    • live_maple_guests_attest_and_complete_through_the_direct_transport (new): both guests verify against the compiled policy, then serve models, one completion and one stream.
    • live_tinfoil_models_and_completions_match_the_legacy_api_contract: passes. Two stale assertions fixed: it hard-coded Tinfoil's model list, and gave a reasoning model 32 tokens.
  • Not covered: the renewal loop and the SDK's own re-verification on key rotation are not exercised by a test here, because a verified client cannot be built without a live enclave. Only the renewal timing function is unit-tested.

Not verified

Nothing here has run inside an enclave. EIF build, PCR approval and a Dev rollout are separate steps.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Upstream tinfoil-rs now verifies V3 attestation for a named enclave, so
the fork that added it is no longer needed. Pin v0.3.0-rc.2.

The SDK pins a dedicated guest to one repository. The approved tag,
digest and launch measurement move into a policy check that runs on
every verification of that client. Only the SEV-SNP launch measurement
is pinned now; a TDX guest is never approved.

Every verification has a freshness deadline, the shared router's too.
A verification is renewed an hour ahead of it without a request in
hand, and a client that still expires is replaced as before.

Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant