From 85b30d89819661207841b92e8b075913c5adb253 Mon Sep 17 00:00:00 2001 From: Dotta Date: Thu, 1 Oct 2026 10:03:01 -0500 Subject: [PATCH] Keep OAuth callback credentials out of browser eval diagnostics Project diagnostic URLs to origin and path before collection. Keep the fail-closed raw credential gate and add a calibration for callback codes, user info, fragments, and unsafe API payloads. All 880 eval support tests and eval typecheck pass. Co-Authored-By: Paperclip --- tests/runner-e2e/redaction.ts | 8 ++++++++ tests/runner-e2e/runner.spec.ts | 11 ++++++----- tests/runner-e2e/support.test.ts | 12 ++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/tests/runner-e2e/redaction.ts b/tests/runner-e2e/redaction.ts index af18974b8cd..550a210676d 100644 --- a/tests/runner-e2e/redaction.ts +++ b/tests/runner-e2e/redaction.ts @@ -57,6 +57,14 @@ export function isEphemeralCodexRuntimeAuthFile( ); } +/** Browser navigation diagnostics need a route, never OAuth query credentials. */ +export function browserDiagnosticUrl(value: string): string { + try { + const url = new URL(value); + return ["http:", "https:"].includes(url.protocol) ? url.origin + url.pathname : "[non-HTTP URL]"; + } catch { return "[invalid URL]"; } +} + export function redactText(value: string, secrets: readonly string[]) { let redacted = redactDiagnosticText(value, "[REDACTED]"); return redactKnownSecretsAndShapes(redacted, secrets); diff --git a/tests/runner-e2e/runner.spec.ts b/tests/runner-e2e/runner.spec.ts index d3e26c388bb..c04a4cc8c2a 100644 --- a/tests/runner-e2e/runner.spec.ts +++ b/tests/runner-e2e/runner.spec.ts @@ -56,6 +56,7 @@ import { findSecretLeakInJsonValues, normalizedSecrets, sanitizeJson, + browserDiagnosticUrl, } from "./redaction.js"; import { CREDENTIAL_NAMES, @@ -779,7 +780,7 @@ for (const execution of executions) { consoleDiagnostics.push({ type: message.type(), text: message.text(), - location: message.location(), + location: { ...message.location(), url: browserDiagnosticUrl(message.location().url) }, }); } }); @@ -788,21 +789,21 @@ for (const execution of executions) { type: "pageerror", message: error.message, stack: error.stack ?? null, - url: page.url(), + url: browserDiagnosticUrl(page.url()), }); }); page.on("framenavigated", (frame) => { if (frame === page.mainFrame()) pageLifecycleDiagnostics.push({ type: "navigation", - url: frame.url(), + url: browserDiagnosticUrl(frame.url()), at: new Date().toISOString(), }); }); page.on("requestfailed", (requestEvent) => { networkDiagnostics.push({ method: requestEvent.method(), - url: requestEvent.url(), + url: browserDiagnosticUrl(requestEvent.url()), failure: requestEvent.failure()?.errorText ?? null, }); }); @@ -810,7 +811,7 @@ for (const execution of executions) { if (response.status() >= 400) { networkDiagnostics.push({ method: response.request().method(), - url: response.url(), + url: browserDiagnosticUrl(response.url()), status: response.status(), statusText: response.statusText(), }); diff --git a/tests/runner-e2e/support.test.ts b/tests/runner-e2e/support.test.ts index f9250a78d3c..4edd3a3cac0 100644 --- a/tests/runner-e2e/support.test.ts +++ b/tests/runner-e2e/support.test.ts @@ -29,6 +29,7 @@ import { isEphemeralPostgresScanFile, redactText, sanitizeJson, + browserDiagnosticUrl, } from "./redaction.js"; import { parseDarwinSharedMemory } from "./shared-memory.js"; import { @@ -1064,6 +1065,17 @@ describe("runner E2E evidence redaction", () => { ); }); + it("drops OAuth callback credentials before collecting browser diagnostics", () => { + const code = "pcmcp_code_fixture_private_code"; + const route = browserDiagnosticUrl(`https://name:password@assistant.example/callback?code=${code}&state=private-state#token`); + expect(route).toBe("https://assistant.example/callback"); + expect(() => assertSecretFree(JSON.stringify({ url: route }), [code, "password", "private-state"], "browser-diagnostics")).not.toThrow(); + expect(browserDiagnosticUrl(`data:text/plain,${code}`)).toBe("[non-HTTP URL]"); + expect(browserDiagnosticUrl(code)).toBe("[invalid URL]"); + // The pre-publication credential gate must still fail for leaked API data. + expect(() => assertSecretFree(JSON.stringify({ body: code }), [code], "api-state")).toThrow("Secret leak"); + }); + it("detects leaks and accepts sanitized evidence", () => { expect(findSecretLeak(Buffer.from(secret), [secret])).toBeTruthy(); expect(() => assertSecretFree("safe", [secret], "fixture")).not.toThrow();