d3e8fc2f131b
narrow content fill replies to an allowlist (v5.3.30)
- time
- 2026-11-22 23:14 UTC · 5 days ago
- machine
- Junes-MacBook-Pro.local
- agent
- gpt-5.6-sol
- session
- remediate interim audit findings
- parent
- 09f15de8221f
↓ peach-browser-d3e8fc2f.tar.gzatlas at this save
files changed6 files
manifest.firefox.json+1 −1manifest.json+1 −1package.json+1 −1src/background/messages.test.ts+119 −0src/background/messages.ts+25 −20src/content/content.field-interaction.test.ts+163 −2manifest.firefox.json+1 −1
@@ -1,7 +1,7 @@11 {22 "manifest_version": 3,33 "name": "Peach Password Manager",4- "version": "5.3.29",4+ "version": "5.3.30",55 "description": "Zero-knowledge password manager",66 "browser_specific_settings": {77 "gecko": {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.29",5+ "version": "5.3.30",66 "description": "Zero-knowledge password manager",77 "action": {88 "default_popup": "src/popup/index.html",package.json+1 −1
@@ -1,6 +1,6 @@11 {22 "name": "peach",3- "version": "5.3.29",3+ "version": "5.3.30",44 "description": "Zero-knowledge password manager",55 "license": "GPL-3.0-only",66 "type": "module",src/background/messages.test.ts+119 −0
@@ -1491,6 +1491,125 @@14911491 expect(editHist.map((h) => h.password)).toEqual(["old-pw"]);14921492 });14931493 1494+ it("PB-26-949: GET_ENTRY_FOR_FILL replies with only the fields a fill consumes", async () => {1495+ const vault = await import("./vault");1496+ await vault.createVault("correct-pass-12345");1497+ const generated = await generatePasskeyKeypair(-7);1498+ const entry = await vault.addEntry({1499+ type: "login",1500+ title: "Everything",1501+ username: "june",1502+ email: "[email protected]",1503+ password: "before-rotation",1504+ url: "https://everything.test",1505+ additionalUrls: ["https://login.everything.test"],1506+ totp: "JBSWY3DPEHPK3PXP",1507+ notes: "recovery codes live here",1508+ tags: ["work", "admin"],1509+ canary: { webhookUrl: "https://example.com/hook" },1510+ });1511+ await vault.updateEntry(entry.id, {1512+ password: "current-password",1513+ breach: 7,1514+ passkey: {1515+ rpId: "everything.test",1516+ rpName: "Everything",1517+ credentialId: base64urlEncode(crypto.getRandomValues(new Uint8Array(32))),1518+ publicKeyCose: base64urlEncode(generated.publicKeyCose),1519+ privateKeyJwk: generated.privateKeyJwk,1520+ userHandle: base64urlEncode(crypto.getRandomValues(new Uint8Array(32))),1521+ userName: "june",1522+ userDisplayName: "June",1523+ algorithm: -7,1524+ signCount: 0,1525+ aaguid: "AAAAAAAAAAAAAAAAAAAAAA",1526+ backupEligible: true,1527+ backupState: false,1528+ createdAt: Date.now(),1529+ },1530+ });1531+1532+ const response = await dispatch(1533+ { type: "GET_ENTRY_FOR_FILL", payload: { id: entry.id } },1534+ { id: "peach-extension", url: "https://everything.test/login", tab: { id: 7 }, frameId: 0 } as chrome.runtime.MessageSender,1535+ );1536+1537+ expect(response.ok).toBe(true);1538+ const data = (response as { data: Record<string, unknown> }).data;1539+ // The reply is an allowlist, not the stored entry minus a few exclusions.1540+ // Chrome drops undefined values on the wire; Firefox delivers them as1541+ // undefined. Either way only defined keys count as delivered.1542+ const delivered = Object.fromEntries(Object.entries(data).filter(([, value]) => value !== undefined));1543+ expect(Object.keys(delivered).sort()).toEqual([1544+ "additionalUrls",1545+ "email",1546+ "id",1547+ "password",1548+ "title",1549+ "totpCode",1550+ "totpRemaining",1551+ "url",1552+ "username",1553+ ]);1554+ expect(delivered).toMatchObject({1555+ id: entry.id,1556+ title: "Everything",1557+ username: "june",1558+ email: "[email protected]",1559+ password: "current-password",1560+ url: "https://everything.test",1561+ additionalUrls: ["https://login.everything.test"],1562+ });1563+ const serialized = JSON.stringify(response);1564+ expect(serialized).not.toContain("JBSWY3DPEHPK3PXP");1565+ expect(serialized).not.toContain("before-rotation");1566+ expect(serialized).not.toContain("recovery codes live here");1567+ });1568+1569+ it("PB-26-949: a card fill still receives the card fields it fills", async () => {1570+ const vault = await import("./vault");1571+ await vault.createVault("correct-pass-12345");1572+ const card = await vault.addEntry({1573+ type: "card",1574+ title: "Personal Visa",1575+ cardholderName: "June Peach",1576+ cardNumber: "4111111111111111",1577+ cvc: "123",1578+ expMonth: "12",1579+ expYear: "2030",1580+ });1581+1582+ const messages = await import("./messages");1583+ const sender = tabSender("https://shop.test/checkout");1584+ const token = messages.createSummonCapability(1, "https://shop.test");1585+ // A fill capability is promoted from an inventory use, as the card selector does.1586+ await dispatch({ type: "AUTOFILL_QUERY", payload: { domain: "shop.test", kind: "card", capability: token } }, sender);1587+ const response = await dispatch(1588+ { type: "GET_ENTRY_FOR_FILL", payload: { id: card.id, capability: token } },1589+ sender,1590+ );1591+1592+ expect(response.ok).toBe(true);1593+ const data = (response.data ?? {}) as Record<string, unknown>;1594+ const delivered = Object.fromEntries(Object.entries(data).filter(([, value]) => value !== undefined));1595+ expect(Object.keys(delivered).sort()).toEqual([1596+ "cardNumber",1597+ "cardholderName",1598+ "cvc",1599+ "expMonth",1600+ "expYear",1601+ "id",1602+ "title",1603+ ]);1604+ expect(delivered).toMatchObject({1605+ cardholderName: "June Peach",1606+ cardNumber: "4111111111111111",1607+ cvc: "123",1608+ expMonth: "12",1609+ expYear: "2030",1610+ });1611+ });1612+14941613 it("GET_ENTRY_FOR_EDIT returns the raw TOTP seed for the trusted edit form", async () => {14951614 const vault = await import("./vault");14961615 await vault.createVault("correct-pass-12345");src/background/messages.ts+25 −20
@@ -1159,32 +1159,37 @@11591159 }11601160 if (isPasskeyOnly(entry)) return { ok: false, error: "passkey_not_fillable" };11611161 }1162- // Strip the passkey credential AND the raw base32 TOTP seed from the1163- // response. Content scripts never need either: the private key is the1164- // authenticator's, and handing over the TOTP seed would let a1165- // compromised content script mint valid codes indefinitely (SEV-3-C).1166- // Generate the *current* 6-digit code here in the background and send1162+ // PB-26-949: this reply is an allowlist, not the stored entry minus a1163+ // few exclusions. Content scripts run in the page's world, so a field1164+ // this projection never names cannot leak when VaultEntry grows one.1165+ // Every key below is read by a fill or selector path; add a key only1166+ // together with the consumer that needs it.1167+ const fillProjection = {1168+ id: entry.id,1169+ title: entry.title, // inject.ts inline edit form1170+ username: entry.username, // index.ts handleAutofill, inline edit1171+ email: entry.email, // index.ts handleAutofill, inline edit1172+ password: entry.password, // fill + copy paths1173+ url: entry.url, // inject.ts inline edit, remember-site check1174+ additionalUrls: entry.additionalUrls, // remember-site check1175+ cardholderName: entry.cardholderName, // card fill1176+ cardNumber: entry.cardNumber, // card fill, copy number1177+ expMonth: entry.expMonth, // card fill1178+ expYear: entry.expYear, // card fill1179+ cvc: entry.cvc, // card fill, copy CVC1180+ };1181+ // The raw base32 TOTP seed never leaves the background (SEV-3-C):1182+ // handing it over would let a compromised content script mint valid1183+ // codes indefinitely. Generate the *current* 6-digit code here and send11671184 // only that, plus the seconds left so the UI can render a countdown.1168- // Also drop passwordHistory: filling needs only the *current* password.1169- // Handing every past password to a content script during passive1170- // autofill on an arbitrary page would widen the blast radius of a1171- // compromised page far beyond the one credential being filled.1172- const {1173- passkey: _strippedPasskey,1174- totp: seed,1175- totpAlgorithm,1176- totpDigits,1177- totpPeriod,1178- passwordHistory: _ph,1179- ...safeEntry1180- } = entry;1185+ const seed = entry.totp;11811186 let totpCode: string | undefined;11821187 let totpRemaining: number | undefined;11831188 if (seed) {11841189 try {11851190 // PCH-01-019: honour stored algorithm/digits/period (defaults apply11861191 // when these are undefined, i.e. RFC-default bare-seed entries).1187- const generated = generateTOTP(seed, totpAlgorithm, totpDigits, totpPeriod);1192+ const generated = generateTOTP(seed, entry.totpAlgorithm, entry.totpDigits, entry.totpPeriod);11881193 totpCode = generated.code;11891194 totpRemaining = generated.remaining;11901195 } catch {@@ -1192,7 +1197,7 @@11921197 }11931198 }11941199 if (isPageSender(sender) && vault.isUnlocked()) touchAutoLock();1195- return { ok: true, data: { ...safeEntry, totpCode, totpRemaining } };1200+ return { ok: true, data: { ...fillProjection, totpCode, totpRemaining } };11961201 }11971202 // Trusted full-entry fetch for extension-owned edit surfaces. Content11981203 // scripts route editing to the popup and cannot call this message.src/content/content.field-interaction.test.ts+163 −2
@@ -36,12 +36,13 @@3636 3737 import { afterEach, beforeEach, describe, expect, it } from "vitest";3838 import "./_setup";39-import { setMessageResponder, resetChromeMock, sentMessages, makeInput, createLoginForm, createEmailFirstForm } from "./_setup";39+import { setMessageResponder, resetChromeMock, sentMessages, messageListeners, makeInput, createLoginForm, createEmailFirstForm } from "./_setup";4040 import { handleFieldInteraction } from "./index";41-import { showAutofillSelector, showTOTPSelector } from "./inject";41+import { showAutofillSelector, showRememberSiteToast, showTOTPSelector } from "./inject";4242 4343 const showSelector = showAutofillSelector as unknown as ReturnType<typeof vi.fn>;4444 const showTOTP = showTOTPSelector as unknown as ReturnType<typeof vi.fn>;45+const showRememberToast = showRememberSiteToast as unknown as ReturnType<typeof vi.fn>;4546 4647 // Reset module-private suppression state between tests by exercising the public4748 // surface: a fresh DOM + cleared mocks. handleFieldInteraction reads live DOM@@ -239,5 +240,165 @@239240 expect(sentMessages.find((msg) => msg.type === "GET_ENTRY_FOR_FILL")).toMatchObject({240241 payload: { id: "totp-entry", capability: "totp-capability" },241242 });243+ });244+});245+246+// PB-26-949: the background reply is now an explicit field allowlist. These247+// assertions are the content half of that contract — the selector's fill path248+// must land the credentials using only the allowlisted keys, so the background249+// test's key set stays sufficient.250+describe("PB-26-949: selector fill consumes only the allowlisted reply", () => {251+ it("fills username, password and TOTP from an allowlist-only reply", async () => {252+ const { form, username, password } = createLoginForm();253+ // Same-origin https action: jsdom's location is http://localhost, and the254+ // form-action gate refuses any non-https form.255+ form.action = "https://localhost/login";256+ const totp = makeInput({ type: "text", autocomplete: "one-time-code", name: "otp" }, form);257+ setMessageResponder((msg) => {258+ if (msg.type === "AUTOFILL_QUERY") {259+ return { ok: true, data: [{ id: "acme", title: "Acme", username: "alice" }] };260+ }261+ if (msg.type === "GET_ENTRY_FOR_FILL") {262+ return {263+ ok: true,264+ data: {265+ id: "acme",266+ title: "Acme",267+ username: "alice",268+ email: "[email protected]",269+ password: "s3cret",270+ url: "https://acme.test",271+ additionalUrls: ["https://login.acme.test"],272+ totpCode: "123456",273+ totpRemaining: 24,274+ },275+ };276+ }277+ return { ok: true, data: null };278+ });279+280+ // Real manual-summon path: the background's browser command clears every281+ // suppression layer (including a page-wide fill grace window left by an282+ // earlier test in this file) and opens the selector.283+ for (const listener of messageListeners) {284+ listener({ type: "SUMMON_AUTOFILL", source: "shortcut" }, { id: chrome.runtime.id }, () => {});285+ }286+ await vi.waitFor(() => expect(showSelector).toHaveBeenCalled());287+ const onSelect = showSelector.mock.calls.at(-1)![2] as (id: string) => Promise<void>;288+ await onSelect("acme");289+290+ expect(username.value).toBe("alice");291+ expect(password.value).toBe("s3cret");292+ expect(totp.value).toBe("123456");293+ });294+295+ it("offers to save the same-domain login after a fill", async () => {296+ const { form, username, password } = createLoginForm();297+ // jsdom's location is http://localhost, and the form-action gate only298+ // permits https or same-origin actions.299+ form.action = "https://localhost/login";300+ showRememberToast.mockClear();301+ setMessageResponder((msg) => {302+ if (msg.type === "AUTOFILL_QUERY") {303+ return { ok: true, data: [{ id: "acme", title: "Acme", username: "alice" }] };304+ }305+ if (msg.type === "GET_ENTRY_FOR_FILL") {306+ return {307+ ok: true,308+ data: {309+ id: "acme",310+ title: "Acme",311+ username: "alice",312+ password: "s3cret",313+ url: "http://localhost",314+ },315+ };316+ }317+ return { ok: true, data: null };318+ });319+320+ for (const listener of messageListeners) {321+ listener({ type: "SUMMON_AUTOFILL", source: "shortcut" }, { id: chrome.runtime.id }, () => {});322+ }323+ await vi.waitFor(() => expect(showSelector).toHaveBeenCalled());324+ const onSelect = showSelector.mock.calls.at(-1)![2] as (id: string) => Promise<void>;325+ await onSelect("acme");326+327+ expect(username.value).toBe("alice");328+ expect(password.value).toBe("s3cret");329+ // `url` is in the fill allowlist only for this consumer: a saved login that330+ // already covers the page must not prompt to save again.331+ expect(showRememberToast).not.toHaveBeenCalled();332+ });333+334+ it("stays quiet when an additional URL covers the page", async () => {335+ const { form, username } = createLoginForm();336+ form.action = "https://localhost/login";337+ showRememberToast.mockClear();338+ setMessageResponder((msg) => {339+ if (msg.type === "AUTOFILL_QUERY") {340+ return { ok: true, data: [{ id: "acme", title: "Acme", username: "alice" }] };341+ }342+ if (msg.type === "GET_ENTRY_FOR_FILL") {343+ return {344+ ok: true,345+ data: {346+ id: "acme",347+ title: "Acme",348+ username: "alice",349+ password: "s3cret",350+ url: "https://elsewhere.test",351+ additionalUrls: ["http://localhost:3000/login"],352+ },353+ };354+ }355+ return { ok: true, data: null };356+ });357+358+ for (const listener of messageListeners) {359+ listener({ type: "SUMMON_AUTOFILL", source: "shortcut" }, { id: chrome.runtime.id }, () => {});360+ }361+ await vi.waitFor(() => expect(showSelector).toHaveBeenCalled());362+ const onSelect = showSelector.mock.calls.at(-1)![2] as (id: string) => Promise<void>;363+ await onSelect("acme");364+365+ expect(username.value).toBe("alice");366+ // `additionalUrls` is in the fill allowlist only for this consumer.367+ expect(showRememberToast).not.toHaveBeenCalled();368+ });369+370+ it("offers to save a login that covers neither URL nor additional URLs", async () => {371+ const { form, username } = createLoginForm();372+ form.action = "https://localhost/login";373+ showRememberToast.mockClear();374+ setMessageResponder((msg) => {375+ if (msg.type === "AUTOFILL_QUERY") {376+ return { ok: true, data: [{ id: "acme", title: "Acme", username: "alice" }] };377+ }378+ if (msg.type === "GET_ENTRY_FOR_FILL") {379+ return {380+ ok: true,381+ data: {382+ id: "acme",383+ title: "Acme",384+ username: "alice",385+ password: "s3cret",386+ url: "https://elsewhere.test",387+ additionalUrls: ["https://login.elsewhere.test"],388+ },389+ };390+ }391+ return { ok: true, data: null };392+ });393+394+ for (const listener of messageListeners) {395+ listener({ type: "SUMMON_AUTOFILL", source: "shortcut" }, { id: chrome.runtime.id }, () => {});396+ }397+ await vi.waitFor(() => expect(showSelector).toHaveBeenCalled());398+ const onSelect = showSelector.mock.calls.at(-1)![2] as (id: string) => Promise<void>;399+ await onSelect("acme");400+401+ expect(username.value).toBe("alice");402+ expect(showRememberToast).toHaveBeenCalledWith("http://localhost:3000", "acme");242403 });243404 });