14a4c8e5706e

bind passkeys to browser-attested origin (v5.3.16)

time
2026-11-15 05:41 UTC · 1 week ago
machine
Junes-MacBook-Pro.local
agent
gpt-6
session
remediate interim audit findings
parent
ff11901fb9f8
18 files manifest.firefox.json+1 −1manifest.json+1 −1package.json+1 −1src/background/messages.test.ts+40 −0src/background/messages.ts+6 −3src/background/passkey-chrome-ceremony.test.ts+115 −20src/background/passkey-crypto.test.ts+9 −0src/background/passkey-crypto.ts+3 −2src/background/passkey.ts+47 −62src/content/passkey-toast/PasskeyToast.tsx+6 −1src/content/passkey-toast/inject.tsx+1 −0src/content/passkey-toast/passkey-toast.css+5 −0src/content/passkey-toast/passkey-toast.test.ts+5 −1src/popup/App.tsx+2 −0src/popup/styles/popup.css+5 −0src/popup/views/PasskeyApproval.tsx+9 −0src/popup/views/contracts.test.tsx+18 −0src/shared/types.ts+1 −0
manifest.firefox.json+1 −1
@@ -1,7 +1,7 @@11 {22   "manifest_version": 3,33   "name": "Peach Password Manager",4-  "version": "5.3.15",4+  "version": "5.3.16",55   "description": "Zero-knowledge password manager",66   "browser_specific_settings": {77     "gecko": {

view file

manifest.json+1 −1
@@ -2,7 +2,7 @@22   "manifest_version": 3,33   "minimum_chrome_version": "116",44   "name": "Peach Password Manager",5-  "version": "5.3.15",5+  "version": "5.3.16",66   "description": "Zero-knowledge password manager",77   "action": {88     "default_popup": "src/popup/index.html",

view file

package.json+1 −1
@@ -1,6 +1,6 @@11 {22   "name": "peach",3-  "version": "5.3.15",3+  "version": "5.3.16",44   "description": "Zero-knowledge password manager",55   "license": "GPL-3.0-only",66   "type": "module",

view file

src/background/messages.test.ts+40 −0
@@ -726,6 +726,46 @@726726     ).resolves.toMatchObject({ ok: false, error: "invalid_passkey_approval_sender" });727727   });728728 729+  it("requires trusted popup approval for embedded passkey requests", async () => {730+    sessionStorage.passkey_pending_302 = {731+      requestId: 302, type: "get", rpId: "login.example", rpName: "Login",732+      userName: "june", origin: "https://login.example", crossOrigin: true,733+    };734+    for (const origin of ["https://top.example", "https://login.example"]) {735+      await expect(dispatch(736+        { type: "PASSKEY_AUTH_RESPONSE", payload: { requestId: 302, approved: true } },737+        { id: "peach-extension", tab: { id: 7 }, origin, url: `${origin}/login` } as chrome.runtime.MessageSender,738+      )).resolves.toMatchObject({ ok: false, error: "invalid_passkey_approval_sender" });739+      expect(sessionStorage.passkey_pending_302).toBeDefined();740+    }741+    await expect(dispatch({ type: "APPROVE_PASSKEY", payload: { requestId: 302 } })).resolves.toMatchObject({ ok: true });742+    expect(sessionStorage.passkey_pending_302).toBeUndefined();743+  });744+745+  it.each([false, true])("rejects content approval without a bound toast (missing pending: %s)", async (missing) => {746+    if (!missing) sessionStorage.passkey_pending_303 = {747+      requestId: 303, type: "get", rpId: "example.com", rpName: "Example",748+      userName: "june", origin: "https://example.com", crossOrigin: false,749+    };750+    await expect(dispatch(751+      { type: "PASSKEY_AUTH_RESPONSE", payload: { requestId: 303, approved: true } },752+      { id: "peach-extension", tab: { id: 7 }, url: "https://example.com/login" } as chrome.runtime.MessageSender,753+    )).resolves.toMatchObject({ ok: false, error: "invalid_passkey_approval_sender" });754+    if (!missing) expect(sessionStorage.passkey_pending_303).toBeDefined();755+  });756+757+  it.each([true, false])("accepts bound same-origin toast consent: %s", async (approved) => {758+    sessionStorage.passkey_pending_304 = {759+      requestId: 304, type: "get", rpId: "example.com", rpName: "Example",760+      userName: "june", tabId: 7, origin: "https://example.com", crossOrigin: false,761+    };762+    await expect(dispatch(763+      { type: "PASSKEY_AUTH_RESPONSE", payload: { requestId: 304, approved } },764+      { id: "peach-extension", tab: { id: 7 }, url: "https://example.com/login" } as chrome.runtime.MessageSender,765+    )).resolves.toMatchObject({ ok: true });766+    expect(sessionStorage.passkey_pending_304).toBeUndefined();767+  });768+729769   it("messages from foreign or URL-less senders are rejected", async () => {730770     const vault = await import("./vault");731771     await vault.createVault("correct-pass-12345");

view file

src/background/messages.ts+6 −3
@@ -1512,9 +1512,12 @@15121512         const pending = await getPendingPasskeyRequest();15131513         const senderOrigin = attestedSenderOrigin(sender);15141514         if (1515-          (pending && pending.requestId !== Number(requestId)) ||1516-          (pending?.tabId !== undefined && sender.tab?.id !== pending.tabId) ||1517-          (pending?.origin !== undefined && senderOrigin !== pending.origin)1515+          !pending ||1516+          pending.tabId === undefined ||1517+          pending.crossOrigin === true ||1518+          pending.requestId !== Number(requestId) ||1519+          sender.tab?.id !== pending.tabId ||1520+          senderOrigin !== pending.origin15181521         ) {15191522           return { ok: false, error: "invalid_passkey_approval_sender" };15201523         }

view file

src/background/passkey-chrome-ceremony.test.ts+115 −20
@@ -13,8 +13,8 @@1313  *   3. clientDataJSON.origin was built from `https://${rpId}` regardless of1414  *      the page hostname — so registering at https://myaccount.google.com1515  *      with rpId=google.com signed origin=https://google.com, which the RP16- *      then rejected. resolvePageOrigin() must use the active tab origin17- *      when it is a registrable-suffix match, otherwise fall back safely.16+ *      then rejected. the browser-attested request context must supply the origin independently17+ *      of tab focus.1818  *1919  * The Chrome path also applies to every Chromium derivative — Brave, Edge,2020  * Vivaldi, Opera, Arc — because chrome.webAuthenticationProxy is provided@@ -60,6 +60,7 @@6060   let activeTabs: Array<{ id?: number; url?: string }>;6161   let broadcastTabs: Array<{ id?: number }>;6262   let openPopup: ReturnType<typeof vi.fn>;63+  let browserContext: unknown;6364 6465   beforeEach(async () => {6566     vi.resetModules();@@ -72,6 +73,7 @@7273     activeTabs = [{ id: 1, url: "https://myaccount.google.com/security/passkeys" }];7374     broadcastTabs = [{ id: 1 }, { id: 2 }];7475     openPopup = vi.fn(async () => {});76+    browserContext = { origin: "https://myaccount.google.com", sameOriginWithAncestors: true };7577 7678     const chromeMock = {7779       runtime: {@@ -169,14 +171,14 @@169171   function fireCreate(options: object, requestId = 100): void {170172     proxyListeners.create!({171173       requestId,172-      requestDetailsJson: JSON.stringify(options),174+      requestDetailsJson: JSON.stringify({ ...options, extensions: { remoteDesktopClientOverride: browserContext } }),173175     });174176   }175177 176178   function fireGet(options: object, requestId = 200): void {177179     proxyListeners.get!({178180       requestId,179-      requestDetailsJson: JSON.stringify(options),181+      requestDetailsJson: JSON.stringify({ ...options, extensions: { remoteDesktopClientOverride: browserContext } }),180182     });181183   }182184 @@ -201,12 +203,13 @@201203   }202204 203205   // Auto-approve any pending Peach popup approval as it appears.204-  function autoApprove() {206+  function autoApprove(onPending?: () => void) {205207     void (async () => {206208       const passkey = await import("./passkey");207209       for (let i = 0; i < 200; i += 1) {208210         const pending = await passkey.getPendingPasskeyRequest();209211         if (pending) {212+          onPending?.();210213           await passkey.resolvePendingPasskeyRequest(pending.requestId, true);211214           return;212215         }@@ -332,11 +335,10 @@332335   });333336 334337   // ─────────────────────────────────────────────────────────────────────335-  // clientDataJSON.origin — page origin via active tab, not synthesized336-  // from rpId. (bug #1)338+  // clientDataJSON.origin follows the browser-attested request context. (bug #1)337339   // ─────────────────────────────────────────────────────────────────────338340 339-  it("create encodes the active tab origin into clientDataJSON when hostname is a subdomain of the rpId", async () => {341+  it("create encodes the attested subdomain origin into clientDataJSON", async () => {340342     const vault = await import("./vault");341343     await vault.createVault("correct-pass-12345");342344 @@ -350,13 +352,15 @@350352     const clientData = decodeClientData(response.response.clientDataJSON);351353     expect(clientData.origin).toBe("https://myaccount.google.com");352354     expect(clientData.type).toBe("webauthn.create");355+    expect(clientData.crossOrigin).toBe(false);353356   });354357 355-  it("create encodes the active tab origin when hostname equals the rpId exactly", async () => {358+  it("create encodes the attested origin when hostname equals the rpId exactly", async () => {356359     const vault = await import("./vault");357360     await vault.createVault("correct-pass-12345");358361 359362     activeTabs = [{ id: 1, url: "https://github.com/settings/security" }];363+    browserContext = { origin: "https://github.com", sameOriginWithAncestors: true };360364 361365     autoApprove();362366     fireCreate(buildCreateOptions({ rpId: "github.com", rpName: "GitHub" }), 111);@@ -367,13 +371,10 @@367371     expect(clientData.origin).toBe("https://github.com");368372   });369373 370-  it("create falls back to https://<rpId> when the active tab is not a registrable-suffix match (safety)", async () => {374+  it("create preserves the attested origin when an unrelated tab is focused", async () => {371375     const vault = await import("./vault");372376     await vault.createVault("correct-pass-12345");373377 374-    // User switched tabs to evil.example before we resolved — refuse to375-    // sign for that origin and fall back instead of leaking a signature376-    // for a hostile origin.377378     activeTabs = [{ id: 1, url: "https://evil.example/passkey" }];378379 379380     autoApprove();@@ -382,10 +383,10 @@382383 383384     const response = JSON.parse(done.responseJson!);384385     const clientData = decodeClientData(response.response.clientDataJSON);385-    expect(clientData.origin).toBe("https://google.com");386+    expect(clientData.origin).toBe("https://myaccount.google.com");386387   });387388 388-  it("create falls back to https://<rpId> when the active tab has no URL", async () => {389+  it("create preserves the attested origin when the active tab has no URL", async () => {389390     const vault = await import("./vault");390391     await vault.createVault("correct-pass-12345");391392 @@ -397,9 +398,70 @@397398 398399     const response = JSON.parse(done.responseJson!);399400     const clientData = decodeClientData(response.response.clientDataJSON);400-    expect(clientData.origin).toBe("https://google.com");401+    expect(clientData.origin).toBe("https://myaccount.google.com");401402   });402403 404+  it.each([405+    undefined, null, {}, { origin: "https://google.com" },406+    { origin: "https://google.com", sameOriginWithAncestors: "true" },407+    { origin: 1, sameOriginWithAncestors: true },408+    ...["null", "not a URL", "https://google.com/", "https://google.com/path", "https://[email protected]", "https://google.com?x", "https://google.com#x", "file:///tmp", "data:text/plain,x"].map((origin) => ({ origin, sameOriginWithAncestors: true })),409+  ])("rejects malformed browser context before accessing credentials: %j", async (context) => {410+    const vault = await import("./vault");411+    const getEntries = vi.spyOn(vault, "getEntries");412+    const updateEntry = vi.spyOn(vault, "updateEntry");413+    const addEntry = vi.spyOn(vault, "addEntry");414+    browserContext = context;415+    fireCreate(buildCreateOptions(), 130);416+    fireGet({ rpId: "google.com", challenge: "Y2g" }, 230);417+    expect((await waitForCreateComplete(130)).error?.name).toBe("SecurityError");418+    expect((await waitForGetComplete(230)).error?.name).toBe("SecurityError");419+    expect(getEntries).not.toHaveBeenCalled();420+    expect(updateEntry).not.toHaveBeenCalled();421+    expect(addEntry).not.toHaveBeenCalled();422+    expect(openPopup).not.toHaveBeenCalled();423+  });424+425+  it.each([426+    ["localhost", "http://localhost:54321"],427+    ["login.google.com", "https://login.google.com:8443"],428+    ["google.com", "https://accounts.google.co.uk"],429+  ])("preserves browser-authorized RP %s with origin %s", async (rpId, origin) => {430+    const vault = await import("./vault");431+    await vault.createVault("correct-pass-12345");432+    browserContext = { origin, sameOriginWithAncestors: false };433+    autoApprove(() => { activeTabs = [{ id: 2, url: "https://unrelated.example" }]; });434+    fireCreate(buildCreateOptions({ rpId }), 131);435+    const done = await waitForCreateComplete(131);436+    expect(done.error).toBeUndefined();437+    const response = JSON.parse(done.responseJson!);438+    expect(decodeClientData(response.response.clientDataJSON)).toMatchObject({ origin, crossOrigin: true });439+    expect(vault.getEntries().find((entry) => entry.passkey)?.passkey?.rpId).toBe(rpId);440+    autoApprove();441+    fireGet({ rpId, challenge: "Y2g", allowCredentials: [] }, 231);442+    const assertion = await waitForGetComplete(231);443+    expect(assertion.error).toBeUndefined();444+    expect(decodeClientData(JSON.parse(assertion.responseJson!).response.clientDataJSON)).toMatchObject({ origin, crossOrigin: true });445+  });446+447+  it("rejects absent browser context in an unlocked vault without reading or changing credentials", async () => {448+    const vault = await import("./vault");449+    await vault.createVault("correct-pass-12345");450+    const { entry } = await seedPasskey("google.com");451+    const getEntries = vi.spyOn(vault, "getEntries");452+    const addEntry = vi.spyOn(vault, "addEntry");453+    const updateEntry = vi.spyOn(vault, "updateEntry");454+    proxyListeners.create!({ requestId: 132, requestDetailsJson: JSON.stringify(buildCreateOptions()) });455+    proxyListeners.get!({ requestId: 232, requestDetailsJson: JSON.stringify({ rpId: "google.com", challenge: "Y2g" }) });456+    expect((await waitForCreateComplete(132)).error?.name).toBe("SecurityError");457+    expect((await waitForGetComplete(232)).error?.name).toBe("SecurityError");458+    expect(getEntries).not.toHaveBeenCalled();459+    expect(addEntry).not.toHaveBeenCalled();460+    expect(updateEntry).not.toHaveBeenCalled();461+    getEntries.mockRestore();462+    expect(vault.getEntries().find((candidate) => candidate.id === entry.id)).toEqual(entry);463+  });464+403465   // ─────────────────────────────────────────────────────────────────────404466   // Core create ceremony.405467   // ─────────────────────────────────────────────────────────────────────@@ -634,23 +696,56 @@634696     expect(done.responseJson).toBeUndefined();635697   });636698 637-  it("get encodes the active tab page origin into clientDataJSON (not https://<rpId>)", async () => {699+  it("get preserves the attested origin across an approval focus change", async () => {638700     const vault = await import("./vault");639701     await vault.createVault("correct-pass-12345");640702     await seedPasskey("google.com");641703 642704     activeTabs = [{ id: 1, url: "https://accounts.google.com/login" }];705+    browserContext = { origin: "https://accounts.google.com:8443", sameOriginWithAncestors: false };643706 644-    autoApprove();707+    let capturedPending: unknown;708+    autoApprove(() => {709+      capturedPending = sessionStorage.passkey_pending_201;710+      activeTabs = [{ id: 2, url: "https://google.com" }];711+    });645712     fireGet({ rpId: "google.com", challenge: "Y2g", allowCredentials: [] }, 201);646713     const done = await waitForGetComplete(201);647714 715+    expect(capturedPending).toMatchObject({ origin: "https://accounts.google.com:8443", crossOrigin: true });716+    expect(openPopup).toHaveBeenCalled();717+    expect(tabsSendMessage.mock.calls.some(([, message]) => message.type === "SHOW_PASSKEY_TOAST")).toBe(false);648718     const response = JSON.parse(done.responseJson!);649719     const clientData = decodeClientData(response.response.clientDataJSON);650-    expect(clientData.origin).toBe("https://accounts.google.com");720+    expect(clientData.origin).toBe("https://accounts.google.com:8443");721+    expect(clientData.crossOrigin).toBe(true);651722     expect(clientData.type).toBe("webauthn.get");652723   });653724 725+  it.each(["https://other.example/login", "not a URL", undefined])("uses popup consent when active tab origin differs: %s", async (url) => {726+    const vault = await import("./vault");727+    await vault.createVault("correct-pass-12345");728+    await seedPasskey("google.com");729+    activeTabs = [{ id: 1, url }];730+    autoApprove();731+    fireGet({ rpId: "google.com", challenge: "Y2g", allowCredentials: [] }, 220);732+    expect((await waitForGetComplete(220)).error).toBeUndefined();733+    expect(openPopup).toHaveBeenCalled();734+    expect(tabsSendMessage.mock.calls.some(([, message]) => message.type === "SHOW_PASSKEY_TOAST")).toBe(false);735+  });736+737+  it("shows the attested caller origin in same-origin toast consent", async () => {738+    const vault = await import("./vault");739+    await vault.createVault("correct-pass-12345");740+    await seedPasskey("google.com");741+    autoApprove();742+    fireGet({ rpId: "google.com", challenge: "Y2g", allowCredentials: [] }, 221);743+    expect((await waitForGetComplete(221)).error).toBeUndefined();744+    expect(tabsSendMessage).toHaveBeenCalledWith(1, expect.objectContaining({745+      type: "SHOW_PASSKEY_TOAST", payload: expect.objectContaining({ origin: "https://myaccount.google.com" }),746+    }));747+  });748+654749   it("get increments signCount and updates lastUsedAt on success", async () => {655750     const vault = await import("./vault");656751     await vault.createVault("correct-pass-12345");@@ -771,7 +866,7 @@771866     let resolved = false;772867     proxyListeners.get!({773868       requestId: 999,774-      requestDetailsJson: JSON.stringify({ rpId: "unknown.example", challenge: "x", allowCredentials: [] }),869+      requestDetailsJson: JSON.stringify({ rpId: "unknown.example", challenge: "x", allowCredentials: [], extensions: { remoteDesktopClientOverride: browserContext } }),775870     });776871     // Allow the handler to finish; if it threw, the test would unhandle-reject.777872     await new Promise((r) => setTimeout(r, 30));

view file

src/background/passkey-crypto.test.ts+9 −0
@@ -32,6 +32,15 @@3232 }3333 3434 describe("passkey crypto", () => {35+  it("encodes cross-origin context while defaulting existing callers to same-origin", () => {36+    const decode = (crossOrigin?: boolean) => JSON.parse(new TextDecoder().decode(37+      buildClientDataJSON("webauthn.get", "Y2g", "https://accounts.example", crossOrigin),38+    ));39+    expect(decode().crossOrigin).toBe(false);40+    expect(decode(false).crossOrigin).toBe(false);41+    expect(decode(true).crossOrigin).toBe(true);42+  });43+3544   it("generates importable ES256 passkey material", async () => {3645     const generated = await generatePasskeyKeypair(-7);3746     const privateKey = await crypto.subtle.importKey(

view file

src/background/passkey-crypto.ts+3 −2
@@ -332,14 +332,15 @@332332 export function buildClientDataJSON(333333   type: "webauthn.create" | "webauthn.get",334334   challenge: string,335-  origin: string335+  origin: string,336+  crossOrigin = false336337 ): Uint8Array {337338   return textEncoder.encode(338339     JSON.stringify({339340       type,340341       challenge,341342       origin,342-      crossOrigin: false,343+      crossOrigin,343344     })344345   );345346 }

view file

src/background/passkey.ts+47 −62
@@ -109,45 +109,20 @@109109   return u[0] * 0x200000 + (u[1] >>> 11);110110 }111111 112-function originFromRpId(rpId: string): string {113-  return /^(localhost|127\.0\.0\.1|\[::1\])$/i.test(rpId)114-    ? `http://${rpId}`115-    : `https://${rpId}`;116-}117-118-/**119- * The clientDataJSON sent back to the RP must contain the page's actual120- * origin — not a synthesized one. `chrome.webAuthenticationProxy` does not121- * surface the requesting origin in CreateRequest/GetRequest, so we read it122- * from the active tab and validate that its hostname is a registrable123- * suffix match for the rpId. WebAuthn requires this relationship anyway, so124- * a mismatch indicates either a stale active tab or a hostile environment;125- * we fall back to https://<rpId> in that case to avoid silently signing the126- * wrong origin.127- *128- * Without this, a passkey created on https://myaccount.google.com gets129- * clientDataJSON.origin = "https://google.com", and Google's RP rejects the130- * attestation with "Something went wrong" because the origin hash doesn't131- * match what its own JS captured at create time.132- */133-async function resolvePageOrigin(rpId: string): Promise<string> {112+function chromeRequestContext(extensions: unknown): { origin: string; crossOrigin: boolean } | null {113+  if (!extensions || typeof extensions !== "object" || !("remoteDesktopClientOverride" in extensions)) return null;114+  const context = extensions.remoteDesktopClientOverride;115+  if (!context || typeof context !== "object" || !("origin" in context) || !("sameOriginWithAncestors" in context)) return null;116+  if (typeof context.origin !== "string" || typeof context.sameOriginWithAncestors !== "boolean") return null;134117   try {135-    const tabs = await new Promise<chrome.tabs.Tab[]>((resolve) =>136-      chrome.tabs.query({ active: true, lastFocusedWindow: true }, resolve)137-    );138-    const url = tabs[0]?.url;139-    if (url) {140-      const parsed = new URL(url);141-      const host = parsed.hostname.toLowerCase();142-      const rp = rpId.toLowerCase();143-      if (host === rp || host.endsWith(`.${rp}`)) {144-        return parsed.origin;145-      }146-    }118+    const origin = new URL(context.origin);119+    if ((origin.protocol !== "https:" && origin.protocol !== "http:") || origin.origin !== context.origin) return null;120+    // Chromium authorizes secure origins and RP IDs, including related origins,121+    // before dispatching the proxy request, then injects this trusted context.122+    return { origin: context.origin, crossOrigin: !context.sameOriginWithAncestors };147123   } catch {148-    // fall through to rpId-derived origin124+    return null;149125   }150-  return originFromRpId(rpId);151126 }152127 153128 async function setBadge(text: string): Promise<void> {@@ -409,24 +384,22 @@409384 async function handleCreateRequest(410385   request: chrome.webAuthenticationProxy.CreateRequest411386 ): Promise<void> {412-  const options = JSON.parse(request.requestDetailsJson) as PublicKeyCredentialCreationOptionsJSON;387+  const options = JSON.parse(request.requestDetailsJson) as PublicKeyCredentialCreationOptionsJSON & { extensions?: unknown };413388   const rpId = options.rp.id;414389   const rpName = options.rp.name ?? options.rp.id;415390   const userName = options.user.name;416391   const userDisplayName = options.user.displayName ?? options.user.name;417-  if (!rpId) {392+  if (typeof rpId !== "string" || !rpId) {418393     console.warn("[Peach passkey] reject: missing rp.id");419394     await rejectCreate(request.requestId, "NotSupportedError", "Missing RP ID");420395     return;421396   }422397 423-  // Capture the page origin NOW — before any popup opens. Once the extension424-  // action popup fires, it can steal lastFocusedWindow so the tabs query425-  // returns no results and falls back to https://<rpId>. For sites where the426-  // page origin is a subdomain of the rpId (e.g. myaccount.google.com vs427-  // rpId google.com) that fallback produces the wrong origin and the RP428-  // rejects the attestation with "Something went wrong".429-  const pageOrigin = await resolvePageOrigin(rpId);398+  const context = chromeRequestContext(options.extensions);399+  if (!context) {400+    await rejectCreate(request.requestId, "SecurityError", "Missing or invalid browser request context.");401+    return;402+  }430403 431404   if (!PASSKEY_CREATE_E2E_BYPASS && !(await isProUser())) {432405     console.warn("[Peach passkey] reject: user is not Pro");@@ -485,6 +458,8 @@485458     rpName,486459     userName,487460     userDisplayName,461+    origin: context.origin,462+    crossOrigin: context.crossOrigin,488463   });489464   if (!approved) {490465     console.warn("[Peach passkey] reject: user denied");@@ -518,7 +493,8 @@518493   const clientDataJSON = buildClientDataJSON(519494     "webauthn.create",520495     options.challenge,521-    pageOrigin496+    context.origin,497+    context.crossOrigin522498   );523499 524500   const passkey: PasskeyData = {@@ -603,17 +579,13 @@603579     await chrome.storage.session.set({ [pendingStorageKey(request.requestId)]: request });604580   }605581 606-  const tabs = await new Promise<chrome.tabs.Tab[]>((resolve) => {607-    chrome.tabs.query({ active: true, currentWindow: true }, resolve);608-  });609-  const tab = tabs[0];610-611-  if (tab?.id) {612-    chrome.tabs.sendMessage(tab.id, {582+  if (request.tabId !== undefined) {583+    chrome.tabs.sendMessage(request.tabId, {613584       type: 'SHOW_PASSKEY_TOAST',614585       payload: {615586         toastToken: crypto.randomUUID(),616587         site: request.rpId,588+        origin: request.origin,617589         displayName: request.userDisplayName ?? request.userName,618590         username: request.userName,619591         requestId: String(request.requestId),@@ -637,7 +609,12 @@637609 async function handleGetRequest(638610   request: chrome.webAuthenticationProxy.GetRequest639611 ): Promise<void> {640-  const options = JSON.parse(request.requestDetailsJson) as PublicKeyCredentialRequestOptionsJSON;612+  const options = JSON.parse(request.requestDetailsJson) as PublicKeyCredentialRequestOptionsJSON & { extensions?: unknown };613+  const context = chromeRequestContext(options.extensions);614+  if (!context || typeof options.rpId !== "string" || !options.rpId) {615+    await rejectGet(request.requestId, "SecurityError", "Missing or invalid browser request context.");616+    return;617+  }641618   if (!vault.isUnlocked()) {642619     // Summon the inline unlock prompt on the active tab so the user can unlock643620     // without leaving the page. Fall back to the popup if the content script@@ -729,19 +706,26 @@729706   const tabs = await new Promise<chrome.tabs.Tab[]>((resolve) => {730707     chrome.tabs.query({ active: true, currentWindow: true }, resolve);731708   });732-  const approvalBinding = {733-    tabId: tabs[0]?.id,734-    origin: await resolvePageOrigin(credential.rpId),735-  };736-  const approved = await promptViaToast({709+  const activeTab = tabs[0];710+  let canUseToast = false;711+  try {712+    canUseToast = !context.crossOrigin && activeTab?.id !== undefined &&713+      new URL(activeTab.url ?? "").origin === context.origin;714+  } catch {715+    // Missing or invalid tab metadata cannot authorize page-level consent.716+  }717+  const pending: PendingPasskeyRequest = {737718     requestId: request.requestId,738719     type: "get",739720     rpId: credential.rpId,740721     rpName: credential.rpName,741722     userName: credential.userName,742723     userDisplayName: credential.userDisplayName,743-    ...approvalBinding,744-  });724+    origin: context.origin,725+    crossOrigin: context.crossOrigin,726+    ...(canUseToast ? { tabId: activeTab.id } : {}),727+  };728+  const approved = await (canUseToast ? promptViaToast(pending) : promptUserApproval(pending));745729   if (!approved) {746730     await rejectGet(request.requestId, "NotAllowedError", "User denied request.");747731     return;@@ -762,7 +746,8 @@762746   const clientDataJSON = buildClientDataJSON(763747     "webauthn.get",764748     options.challenge,765-    await resolvePageOrigin(credential.rpId)749+    context.origin,750+    context.crossOrigin766751   );767752   const clientDataHash = new Uint8Array(768753     await crypto.subtle.digest("SHA-256", new Uint8Array(clientDataJSON))

view file

src/content/passkey-toast/PasskeyToast.tsx+6 −1
@@ -1,7 +1,8 @@1-import { createSignal, onMount, onCleanup } from 'solid-js';1+import { createSignal, onMount, onCleanup, Show } from 'solid-js';22 33 interface PasskeyToastProps {44   site: string;5+  origin?: string;56   displayName: string;67   username: string;78   requestId: string;@@ -57,6 +58,10 @@5758         <h2 class="peach-passkey-toast-headline">5859           sign in to {props.site}?5960         </h2>61+62+        <Show when={props.origin}>63+          <div class="peach-passkey-toast-user peach-passkey-toast-origin">Request from {props.origin}</div>64+        </Show>6065 6166         <div class="peach-passkey-toast-user">6267           {props.displayName} · {props.username}

view file

src/content/passkey-toast/inject.tsx+1 −0
@@ -44,6 +44,7 @@4444 4545 export function showPasskeyToast(payload: {4646   site: string;47+  origin?: string;4748   displayName: string;4849   username: string;4950   requestId: string;

view file

src/content/passkey-toast/passkey-toast.css+5 −0
@@ -90,6 +90,11 @@9090   padding: 3px 8px;9191 }9292 93+.peach-passkey-toast-origin {94+  color: #F0E8D8;95+  overflow-wrap: anywhere;96+}97+9398 /* Countdown bar */9499 .peach-passkey-toast-countdown {95100   width: 100%;

view file

src/content/passkey-toast/passkey-toast.test.ts+5 −1
@@ -97,6 +97,10 @@9797     vi.resetModules();9898     const mocks = installChromeMock();9999     storage = mocks.storage;100+    mocks.sessionStorage.passkey_pending_42 = {101+      requestId: 42, type: 'get', rpId: 'example.com', rpName: 'Example',102+      userName: 'june', tabId: 7, origin: 'https://example.com', crossOrigin: false,103+    };100104     listener = mocks.listener;101105     storage['peach_settings'] = { breachMonitoring: false };102106     vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, status: 200, text: async () => '' })));@@ -114,7 +118,7 @@114118 115119   async function dispatch(msg: { type: string; payload?: unknown }): Promise<Record<string, unknown>> {116120     return new Promise((resolve) => {117-      const keepOpen = listener()(msg as unknown as Parameters<MessageListener>[0], { id: 'peach-extension' }, (r) => resolve(r as Record<string, unknown>));121+      const keepOpen = listener()(msg as unknown as Parameters<MessageListener>[0], { id: 'peach-extension', tab: { id: 7 }, url: 'https://example.com/login' }, (r) => resolve(r as Record<string, unknown>));118122       expect(keepOpen).toBe(true);119123     });120124   }

view file

src/popup/App.tsx+2 −0
@@ -1405,6 +1405,8 @@14051405               type={pendingPasskey()!.type}14061406               rpName={pendingPasskey()!.rpName}14071407               rpId={pendingPasskey()!.rpId}1408+              origin={pendingPasskey()!.origin}1409+              crossOrigin={pendingPasskey()!.crossOrigin}14081410               userName={pendingPasskey()!.userName}14091411               userDisplayName={pendingPasskey()!.userDisplayName}14101412               onApprove={handleApprovePendingPasskey}

view file

src/popup/styles/popup.css+5 −0
@@ -1992,6 +1992,11 @@19921992   max-width: 220px;19931993 }19941994 1995+.peach-passkey-approval-origin {1996+  color: var(--peach-t0);1997+  overflow-wrap: anywhere;1998+}1999+19952000 .peach-passkey-approval-actions {19962001   display: flex;19972002   gap: 8px;

view file

src/popup/views/PasskeyApproval.tsx+9 −0
@@ -4,6 +4,8 @@44   type: "create" | "get";55   rpName: string;66   rpId: string;7+  origin?: string;8+  crossOrigin?: boolean;79   userName: string;810   userDisplayName?: string;911   onApprove: () => void | Promise<void>;@@ -23,6 +25,13 @@2325           </div>2426 2527           <div class="peach-passkey-approval-rp">{props.rpId}</div>28+29+          <Show when={props.origin}>30+            <div class="peach-passkey-approval-notice peach-passkey-approval-origin">Request from {props.origin}</div>31+          </Show>32+          <Show when={props.crossOrigin}>33+            <div class="peach-passkey-approval-notice peach-passkey-approval-origin">This request is embedded in another site.</div>34+          </Show>2635 2736           <h2 class="peach-passkey-approval-action">2837             {props.type === "create" ? "save a passkey?" : "sign in with passkey?"}

view file

src/popup/views/contracts.test.tsx+18 −0
@@ -6,6 +6,8 @@66 import type { ImportParseResult } from "../../shared/import";77 import type { VaultEntry } from "../../shared/types";88 import { WORD_LIST } from "../../shared/recovery-word-list";9+import { PasskeyToast } from "../../content/passkey-toast/PasskeyToast";10+import { PasskeyApprovalView } from "./PasskeyApproval";911 import { LockView } from "./Lock";1012 import { ExportView } from "./Export";1113 import { SettingsView } from "./Settings";@@ -224,6 +226,22 @@224226       (candidate) => candidate.textContent?.trim() === text225227     ) as HTMLButtonElement;226228   }229+230+  it("Passkey toast shows the caller origin separately from the RP", async () => {231+    const container = mount(() => <PasskeyToast site="example.com" origin="https://login.other.example:8443"232+      displayName="June" username="june" requestId="1" onSignIn={() => {}} onDeny={() => {}} />);233+    await flushView();234+    expect(container.textContent).toContain("sign in to example.com?");235+    expect(container.textContent).toContain("Request from https://login.other.example:8443");236+  });237+238+  it("Passkey approval identifies the caller origin and embedded request", async () => {239+    const container = mount(() => <PasskeyApprovalView type="get" rpId="example.com" rpName="Example"240+      userName="june" origin="https://login.other.example:8443" crossOrigin={true} onApprove={() => {}} onDeny={() => {}} />);241+    await flushView();242+    expect(container.textContent).toContain("https://login.other.example:8443");243+    expect(container.textContent).toContain("embedded in another site");244+  });227245 228246   it("Lock sends UNLOCK with the entered passphrase", async () => {229247     sendMessageMock.mockResolvedValue({ ok: true });

view file

src/shared/types.ts+1 −0
@@ -149,6 +149,7 @@149149   /** Originating tab and frame binding for content-script approval responses. */150150   tabId?: number;151151   origin?: string;152+  crossOrigin?: boolean;152153   /**153154    * Firefox path: when present, the popup performs the navigator.credentials154155    * call itself rather than completing a chrome.webAuthenticationProxy

view file