diff --git a/CLAUDE.md b/CLAUDE.md index 8b916c1..6c79807 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -266,6 +266,18 @@ the VTA, the VTC and the did-hosting RP sign them for. The one opt-out is the Mediator Lens (`replyProofPurpose: "any"`): a mediator is none of those, and signs its `messaging/*` replies for a purpose of its own. +**Signing in enrolls the RP for its own step-ups, and nothing else.** An RP +session step-up's approve-request must be signed by an enrolled executor; the +set for that one flow is the enrolled set plus the RP DID the page's origin is +pinned to by an approved sign-in, when it is the `rpDid` the step-up names +(`rpStepUpExecutorDids`, fed `signedInRpDid` by the background after +`pageStepUpBindingRefusal` passes). The human confirmed that RP at the login +prompt, and the approve-response only elevates that RP's own session, so +making them also list it under "Enrolled executor DIDs" protected nothing. +**What breaks it:** letting the page supply `signedInRpDid`, or widening +executor-initiated pushes (task consent, disclosure step-up) with sign-in +pins — those arrive from no origin and keep the enrolled set alone. + **What is deliberately NOT signed by a channel:** `provision/integration`, which signs its own document with an `authentication`-purpose proof in `provision/request.ts` and sends outside the channels. Routing it through one diff --git a/packages/extension/src/background.ts b/packages/extension/src/background.ts index 758cff2..11d4d39 100644 --- a/packages/extension/src/background.ts +++ b/packages/extension/src/background.ts @@ -2051,11 +2051,8 @@ async function handleApproveSessionStepUp( // Refused before anything is verified or prompted: the page may only have a // step-up approved for the RP DID its origin is pinned to by an approved // login. See `pageStepUpBindingRefusal`. - const bindingRefusal = pageStepUpBindingRefusal( - req.origin, - await readOriginPin(req.origin), - req.params?.rpDid, - ); + const pin = await readOriginPin(req.origin); + const bindingRefusal = pageStepUpBindingRefusal(req.origin, pin, req.params?.rpDid); if (bindingRefusal) return { ok: false, error: bindingRefusal }; const active = await readActiveConnection(); if (!active.ok) return { ok: false, error: active.error }; @@ -2066,6 +2063,9 @@ async function handleApproveSessionStepUp( vtaDid: active.conn.vtaDid, params: req.params, origin: req.origin, + // The sign-in that pinned this origin is what enrolls its RP as the + // step-up's executor; the binding check above has just matched it. + ...(pin ? { signedInRpDid: pin.rpDid } : {}), }; return (await chrome.runtime.sendMessage( offscreenRequest, diff --git a/packages/extension/src/bridge-protocol.ts b/packages/extension/src/bridge-protocol.ts index 1d57c83..9612c48 100644 --- a/packages/extension/src/bridge-protocol.ts +++ b/packages/extension/src/bridge-protocol.ts @@ -2133,6 +2133,11 @@ export interface OffscreenApproveSessionStepUpRequest { /** The RP page's origin — threaded through so the mid-flow consent prompt * can show it (and honour per-origin trust). Display only, never auth. */ origin: string; + /** The RP DID `origin` is pinned to by an approved sign-in, as the + * background read it when it checked `params.rpDid` against the pin. Set + * by the background, never by the page; the offscreen counts it as an + * enrolled executor for this step-up (`rpStepUpExecutorDids`). */ + signedInRpDid?: string; } /** offscreen → background: raise the step-up consent prompt for a VERIFIED diff --git a/packages/extension/src/offscreen.ts b/packages/extension/src/offscreen.ts index 005fef1..121c6fd 100644 --- a/packages/extension/src/offscreen.ts +++ b/packages/extension/src/offscreen.ts @@ -104,6 +104,7 @@ import { forgetInbox, getSettings, inboxFor, inboxToAdopt, setInbox } from "./co import { walletNetPolicy } from "./net-policy.js"; import { isReusable, isSuperseded, retireConnection, startWakeWatch } from "./warm-session-health.js"; import { loadHolder } from "./holder.js"; +import { rpStepUpExecutorDids } from "./page-task-policy.js"; import { WebAuthnPrfSecretWrap } from "./webauthn-prf-wrap.js"; import type { Transport, TransportHealth, TransportObservation } from "./transports.js"; import { @@ -4907,7 +4908,13 @@ async function doApproveSessionStepUp( approveRequest: req.params.approveRequest, signing, rpDid: req.params.rpDid, - enrolledExecutorDids: await enrolledExecutorDids(req.vtaDid), + // The enrolled set plus the RP this origin signed in to: signing in is + // what enrolls an RP for its own step-ups (`rpStepUpExecutorDids`). + enrolledExecutorDids: rpStepUpExecutorDids( + await enrolledExecutorDids(req.vtaDid), + req.signedInRpDid, + req.params.rpDid, + ), onMark: (label) => sw.mark(label), requestConsent: async (ctx) => { const ask: RuntimeStepUpConsentRequest = { diff --git a/packages/extension/src/options.tsx b/packages/extension/src/options.tsx index c19e09c..b81f197 100644 --- a/packages/extension/src/options.tsx +++ b/packages/extension/src/options.tsx @@ -346,7 +346,8 @@ export function AdvancedPane() { Executors beyond your onboarded VTA(s) whose signed approval requests (task consent, step-up) this wallet will render. Requests signed by anyone not enrolled are dropped - without prompting. + without prompting. A site you sign in to is enrolled for its own session step-ups + automatically — list a DID here only when it pushes requests to this wallet. diff --git a/packages/extension/src/page-task-policy.ts b/packages/extension/src/page-task-policy.ts index 128ce7c..1eaa356 100644 --- a/packages/extension/src/page-task-policy.ts +++ b/packages/extension/src/page-task-policy.ts @@ -350,3 +350,30 @@ export function pageStepUpBindingRefusal( } return null; } + +/** + * The executors whose approve-request a page's session step-up may be signed + * by: the wallet's `enrolled` set, plus the relying party this origin was + * pinned to by an approved sign-in — but only when that is the `rpDid` the + * step-up names. + * + * Signing in already enrolled that RP for this purpose: the login prompt is + * where the human saw and confirmed the RP DID, and the pin records it. An + * RP step-up is that same RP asking the holder to approve elevating *its own* + * session — the approve-request must be signed by `rpDid`, and the + * approve-response is addressed to it and bound to its single-use challenge — + * so requiring the operator to also list the RP under "Enrolled executor + * DIDs" added no protection, only a refusal the human could not act on. + * + * Only this flow widens. Executor-initiated pushes (task consent, disclosure + * step-up) arrive unsolicited from no origin and keep the enrolled set alone. + */ +export function rpStepUpExecutorDids( + enrolled: readonly string[], + pinnedRpDid: string | undefined, + rpDid: unknown, +): string[] { + const set = new Set(enrolled); + if (pinnedRpDid && pinnedRpDid === rpDid) set.add(pinnedRpDid); + return [...set]; +} diff --git a/packages/extension/tests/page-rp-binding.test.mts b/packages/extension/tests/page-rp-binding.test.mts index 6414b6f..c64fff4 100644 --- a/packages/extension/tests/page-rp-binding.test.mts +++ b/packages/extension/tests/page-rp-binding.test.mts @@ -33,9 +33,12 @@ Object.defineProperty(globalThis, "chrome", { }); const { checkOriginPin, pinOrigin, readOriginPin } = await import("../src/origin-pin.ts"); -const { normalizeBaseUrl, pageSignBindingRefusal, pageStepUpBindingRefusal } = await import( - "../src/page-task-policy.ts" -); +const { + normalizeBaseUrl, + pageSignBindingRefusal, + pageStepUpBindingRefusal, + rpStepUpExecutorDids, +} = await import("../src/page-task-policy.ts"); const ORIGIN = "https://rp.example"; const RP = "did:webvh:QmExampleScid:rp.example"; @@ -160,3 +163,23 @@ test("base URLs normalize to one spelling, and refuse what is not a plain base", assert.equal(normalizeBaseUrl("https://api.rp.example/#x"), null); assert.equal(normalizeBaseUrl("nope"), null); }); + +// Signing in enrolls the RP for its own step-ups: without this, a holder who +// signed in to a control plane was refused "not an executor this wallet is +// enrolled with" on the first step-up, and the fix was a settings field. + +test("the RP an origin signed in to counts as the step-up's executor", () => { + const VTA = "did:example:vta"; + assert.deepEqual(rpStepUpExecutorDids([VTA], RP, RP).sort(), [RP, VTA].sort()); +}); + +test("the signed-in RP is not added for a step-up naming another RP", () => { + const VTA = "did:example:vta"; + assert.deepEqual(rpStepUpExecutorDids([VTA], RP, OTHER_RP), [VTA]); +}); + +test("with no sign-in pin the enrolled set is unchanged", () => { + const VTA = "did:example:vta"; + assert.deepEqual(rpStepUpExecutorDids([VTA], undefined, RP), [VTA]); + assert.deepEqual(rpStepUpExecutorDids([VTA, RP], undefined, RP), [VTA, RP]); +});