Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions packages/extension/src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions packages/extension/src/bridge-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion packages/extension/src/offscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion packages/extension/src/options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ export function AdvancedPane() {
<small style={{ color: "var(--w-muted)", marginTop: 4 }}>
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.
</small>

<label style={labelStyle}>Push gateway URL (optional — Web Push test)</label>
Expand Down
27 changes: 27 additions & 0 deletions packages/extension/src/page-task-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
29 changes: 26 additions & 3 deletions packages/extension/tests/page-rp-binding.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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]);
});