fix(browser): fingerprint cookies at the selected page URL (#763)

Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This commit is contained in:
Rudy Mizrahi Celekli
2026-10-07 10:11:57 +08:00
committed by GitHub
parent 472b72a530
commit 78014e3d14
7 changed files with 58 additions and 7 deletions
+4 -2
View File
@@ -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,
+8 -3
View File
@@ -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) {
+1 -1
View File
@@ -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)