Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(browser): fingerprint cookies at the selected page URL (#763)
Rudy Mizrahi Celekli78014e3d149f
diff --git a/docs/browser-observation.md b/docs/browser-observation.mdindex dd69b5af5..1baac522f 100644--- a/docs/browser-observation.md+++ b/docs/browser-observation.md@@ -124,7 +124,7 @@ REA retains local observation data and removes only URL userinfo credentials, ex- Request/response bodies are not requested or parsed by default. When selected, only allowed-origin JSON media types are read, converted immediately to complete value-free property paths/types, and discarded. `Network.getResponseBody` is never sent unless JSON body shape capture is selected.- Console observations with a stack source retain call type, argument types, timestamp, and source location. When console text capture is selected, already-delivered primitive values are retained verbatim; objects, getters, and remote properties are never expanded.- WebSocket observations retain direction, opcode, and payload byte length. When shape capture is selected, text frames are classified as text or complete value-free JSON shape; binary bytes, hashes, prefixes, and raw frames are never retained.-- Storage observations always redact values. Key names, IndexedDB names, and cache names require `include_storage_keys`; stable content fingerprints require the additional `include_storage_fingerprints` selection. Cache bodies above 64 KiB and partial IndexedDB remote objects make fingerprint coverage incomplete, so identical observations remain `unknown`.+- Storage observations always redact values. Key names, IndexedDB names, and cache names require `include_storage_keys`; stable content fingerprints require the additional `include_storage_fingerprints` selection. Cookie fingerprints cover cookies applicable to the current main-frame URL, including its path, rather than every cookie path on that origin. Other storage remains scoped to the origin. Cache bodies above 64 KiB and partial IndexedDB remote objects make fingerprint coverage incomplete, so identical observations remain `unknown`.- Script metadata is included only when CDP supplies a URL on an allowed origin. Stable keys exclude transient CDP script IDs, and exact transient raw URLs are used only during script/resource reconciliation. URL-less scripts are excluded because their origin cannot be established. When CDP supplies an execution-context association, the accepted script retains its authorized frame ID for later attribution. Source content is omitted unless explicitly requested and is returned inline as a self-verifying artifact with its SHA-256 digest.Frames, resources, scripts, events, and workers outside the selected origin scope are excluded. An explicit `allowed_origins` list can include additional origins; excluded target details are counted without being exposed.diff --git a/scripts/fixtures/browser-verifier-site.mjs b/scripts/fixtures/browser-verifier-site.mjsindex 95fded929..65bfb8bc0 100644--- a/scripts/fixtures/browser-verifier-site.mjs+++ b/scripts/fixtures/browser-verifier-site.mjs@@ -52,6 +52,10 @@ export async function startBrowserVerifierSite() {return;}response.setHeader("content-type", "text/html");+ response.setHeader("set-cookie", [+ "rea-root-cookie=root-fixture; Path=/; SameSite=Lax",+ "rea-app-cookie=app-fixture; Path=/app; SameSite=Lax",+ ]);response.end('<!doctype html><html><head><title>REA browser verifier</title></head><body><main><h1>Browser evidence</h1><button aria-label="ax-private-label-value">Verify</button></main><script type="module" src="/app.js?token=script-query-secret"></script></body></html>',);diff --git a/scripts/lib/browser-verifier-assertions.mjs b/scripts/lib/browser-verifier-assertions.mjsindex 664a20963..568100d71 100644--- a/scripts/lib/browser-verifier-assertions.mjs+++ b/scripts/lib/browser-verifier-assertions.mjs@@ -89,6 +89,14 @@ function assertObservationPrivacy(result) {function assertObservationMetadata(result) {if (!result.storage.local_storage_keys.includes("rea-storage-key"))throw new Error("Real Chrome local-storage key inventory was missing");+ if (+ result.storage.content_fingerprints.filter(+ ({ scope }) => scope === "cookie",+ ).length !== 2+ )+ throw new Error(+ "Real Chrome root and current-page cookie fingerprints were missing",+ );if (!result.storage.indexed_db_names.includes("rea-browser-db"))throw new Error("Real Chrome IndexedDB name inventory was missing");if (!result.storage.cache_names.includes("rea-browser-cache"))diff --git a/src/browser/CdpCaptureStorage.ts b/src/browser/CdpCaptureStorage.tsindex 89cccb4cc..141082a66 100644--- a/src/browser/CdpCaptureStorage.ts+++ b/src/browser/CdpCaptureStorage.ts@@ -16,7 +16,7 @@ import {stringValue,} from "./CdpCaptureValues.js";-/** Capture redacted storage metadata for one authorized origin. */+/** Capture redacted storage metadata for an authorized page and its origin. */export const captureStorage = async (context: {readonly connection: CdpConnection;@@ -24,11 +24,12 @@ export const captureStorage = async (readonly input: InspectWebPageInput;readonly signal?: AbortSignal;},- origin: string,+ pageUrl: string,limitations: string[],): Promise<{readonly value: WebPageInspection["storage"];}> => {+ const origin = new URL(pageUrl).origin;const quota = recordValue(await optionalCdpCommand(context,@@ -67,6 +68,7 @@ export const captureStorage = async (? await captureStorageFingerprints({context,origin,+ cookieUrl: pageUrl,local,session,indexedDbNames: indexed,diff --git a/src/browser/CdpCaptureStorageFingerprints.ts b/src/browser/CdpCaptureStorageFingerprints.tsindex 80f81c974..0d90eff11 100644--- a/src/browser/CdpCaptureStorageFingerprints.ts+++ b/src/browser/CdpCaptureStorageFingerprints.ts@@ -48,6 +48,7 @@ interface FingerprintRun {interface CaptureStorageFingerprintInput {readonly context: StorageFingerprintContext;readonly origin: string;+ readonly cookieUrl: string;readonly local: CapturedStorageItems;readonly session: CapturedStorageItems;readonly indexedDbNames: readonly string[];@@ -64,6 +65,7 @@ type StorageFingerprintCapture = {export const captureStorageFingerprints = async ({context,origin,+ cookieUrl,local,session,indexedDbNames,@@ -77,7 +79,7 @@ export const captureStorageFingerprints = async ({const run = { context, limitations, state };addStorageItems(state, "local_storage", local.items);addStorageItems(state, "session_storage", session.items);- await addCookies(run, origin);+ await addCookies(run, cookieUrl);await addIndexedDb(run, origin, indexedDbNames);await addCaches(run, caches);state.items.sort((left, right) =>@@ -107,12 +109,15 @@ const addStorageItems = (const addCookies = async (run: FingerprintRun,- origin: string,+ pageUrl: string,): Promise<void> => {+ run.limitations.push(+ "Cookie fingerprints cover cookies applicable to the current main-frame URL, not every path on its origin.",+ );const raw = await optionalCdpCommand(run.context,"Network.getCookies",- { urls: [origin] },+ { urls: [pageUrl] },run.limitations,);if (raw === undefined) {diff --git a/src/browser/CdpPageCapture.ts b/src/browser/CdpPageCapture.tsindex e1914b55a..a45782102 100644--- a/src/browser/CdpPageCapture.ts+++ b/src/browser/CdpPageCapture.ts@@ -144,7 +144,7 @@ const captureAuthorizedPage = async ();const storageCapture = await captureStorage(context,- frames[0]?.origin ?? new URL(attachedUrl).origin,+ attachedUrl,limitations,);if (!input.include_storage_keys)diff --git a/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts b/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.tsindex e05d92b7f..20bcabaac 100644--- a/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts+++ b/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts@@ -158,6 +158,38 @@ describeBrowser("CdpBrowserProvider: sensitive data 1", () => {});});+describeBrowser("CdpBrowserProvider: page cookie scope", () => {+ it("uses the attached page URL for cookies and its origin for DOM storage", async () => {+ const browser = await startFakeCdpBrowser();+ trackBrowser(browser);+ const result = await new CdpBrowserProvider().inspectPage(+ inspectWebPageInputSchema.parse({+ cdp_endpoint: browser.endpoint,+ allowed_origins: [browser.allowedOrigin],+ target_id: "allowed-page",+ observation_ms: 0,+ include_storage_keys: true,+ include_storage_fingerprints: true,+ }),+ );+ if (!result.ok) throw result.error;+ expect(+ browser.commands.find(({ method }) => method === "Network.getCookies")+ ?.params,+ ).toEqual({ urls: [`${browser.allowedOrigin}/app?token=frame-secret`] });+ expect(+ browser.commands.find(+ ({ method }) => method === "DOMStorage.getDOMStorageItems",+ )?.params,+ ).toEqual({+ storageId: {+ securityOrigin: browser.allowedOrigin,+ isLocalStorage: true,+ },+ });+ });+});+describeBrowser("CdpBrowserProvider: complete storage fingerprints", () => {it("fingerprints cache bodies above the former byte ceiling", async () => {const body = "x".repeat(64 * 1_024 + 1);