← Back to Pull requests

dogfood: fix(cloudflare): refuse a call whose `dpop` differs from the Durable Object's #1202

Open
unknown opened this pull request with 373 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 29, 2026 04:43 UTC
Author

Fixed Sessions.durableObject to throw Accounts.RequestError with invalid_dpop_proof when the instance's dpop differs from the dpop of the config of DurableObject.sessions, or when config holds none.

Problem

The object signs each token request with the DPoP key of its own config, since no CryptoKey crosses RPC (DataCloneError). A Worker that set dpop only on Accounts.create, as Bind DPoP keys shows, thus received Bearer tokens without an error. With another key in each place, the tokens were bound to the key of the object.

export const SESSIONS = DurableObject.sessions(() => ({ clientSecret })) // no `dpop`

const accounts = Accounts.create({
  clientId,
  dpop,
  plugins: [backend({ sessions: Sessions.durableObject(env.SESSIONS) })],
})
await accounts.backend.start() // Before: a sign-in that issues Bearer tokens. After: invalid_dpop_proof.

Each call now names the thumbprint of the instance's DPoP key as jkt, and the object compares it with the thumbprint of its config. A Worker without dpop, and a Worker of an earlier release, send no jkt, so the object keeps its behavior for them. The object checks only the calls that issue or use tokens (start, complete, get, headers, issue, save, take). end, discard, endSid, and the index calls sign no proof, so a misconfigured Worker still revokes and deletes the sessions that it holds.

API changes

backend({ sessions: (app) => adapter({ dpop: app.dpop }) })

backend.Sessions.Adapter.Options holds the instance's dpop, so an adapter that signs in another process can check it.

export const SESSIONS = DurableObject.sessions(async (env: Env) => ({
  clientSecret: env.CLIENT_SECRET,
  dpop: await importDpopKey(env.DPOP_KEY),
}))

const accounts = Accounts.create({
  clientId: env.CLIENT_ID,
  dpop: await importDpopKey(env.DPOP_KEY),
  plugins: [backend({ sessions: Sessions.durableObject(env.SESSIONS) })],
})

How to test

pnpm test src/cloudflare/Sessions.test.ts runs the instance's start in Miniflare with four pairs of keys. On main, all four returned /oauth2/authorize. With the fix, the first two (no key in config, another key in config) throw invalid_dpop_proof, and the same key, or a key only in config, still starts the sign-in. A second test ends a session from an instance with another key: it threw invalid_dpop_proof before this revision, and ends now.

Validation: pnpm check:types, pnpm check, pnpm test (1720 passed), and the test/client/cloudflare/DurableObject.test.ts and test/client/plugins/backend.test.ts suites of Tempo ID against this branch (40 passed).

Numbers: no added request, RPC call, or round. Each call carries one thumbprint of 43 characters, and the object computes its own once.

curious-dog-key: durable-object-sessions-ignore-instance-dpop

Diff: 373 lines (+279 / -94) across 4 files Reviewer: claude[bot] Review duration: 16m
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.43) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 373 lines diff across 4 files
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
42%
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.354
Shallow Review Depth shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1202"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 43.0% 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: 42.8% (MEDIUM) · Higher = larger blast radius
42.8%
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: 43.0% · Lower = rushed or shallow review
43.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: 24.4% · Safe to merge
24.4%