From d81229f9f2509f38a5fd33c051ece7faa8b4d32b Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 13 Apr 2026 09:34:13 -0700 Subject: [PATCH] fix(security): redact form fields with sensitive names, not just type=password Form redaction only applied to type="password" fields. Hidden and text fields named csrf_token, api_key, session_id, etc. were exposed unredacted in LLM context, leaking secrets. Extend redaction to check field name and id against sensitive patterns: token, secret, key, password, credential, auth, jwt, session, csrf, sid, api_key. Uses the same pattern style as SENSITIVE_COOKIE_NAME. Closes #860 Co-Authored-By: Gus --- browse/src/read-commands.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/browse/src/read-commands.ts b/browse/src/read-commands.ts index 746b0959..ffb15c09 100644 --- a/browse/src/read-commands.ts +++ b/browse/src/read-commands.ts @@ -116,7 +116,10 @@ export async function handleReadCommand( id: input.id || undefined, placeholder: input.placeholder || undefined, required: input.required || undefined, - value: input.type === 'password' ? '[redacted]' : (input.value || undefined), + value: input.type === 'password' + || (input.name && /(^|[_.-])(token|secret|key|password|credential|auth|jwt|session|csrf|sid)($|[_.-])|api.?key/i.test(input.name)) + || (input.id && /(^|[_.-])(token|secret|key|password|credential|auth|jwt|session|csrf|sid)($|[_.-])|api.?key/i.test(input.id)) + ? '[redacted]' : (input.value || undefined), options: el.tagName === 'SELECT' ? [...(el as HTMLSelectElement).options].map(o => ({ value: o.value, text: o.text })) : undefined,