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 <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-01 10:12:09 -05:00
1 parent 114ff6ebdd
commit 85b30d8981
3 files changed
+26 -5

No files matched your search

+8
View File
@@ -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);
+6 -5
View File
@@ -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(),
});
+12
View File
@@ -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();