Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
fix(sidepanel): redact bare and camel-case credential parameters in URLs
Emre Sokullu93829a059aba
diff --git a/src/chrome/src/ui/sidepanel.js b/src/chrome/src/ui/sidepanel.jsindex 9894ee512..82b316857 100644--- a/src/chrome/src/ui/sidepanel.js+++ b/src/chrome/src/ui/sidepanel.js@@ -2990,15 +2990,19 @@ const TOOL_KEYS = {carousel_navigate: 'tool.navigate',};-const SENSITIVE_URL_PARAM_RE = /([#?&](?:[^#&?=]*?[_.-])?(?:token|auth|api[_-]?key|secret|password|passwd|pwd|session|otp|signature|sig)(?:[_.-][^#&?=]*)?=)[^#&\s]*/gi;+const SENSITIVE_PARAM_WORDS_RE = /(?:^|[_-])(?:key|api[_-]?key|token|secret|password|passwd|pwd|session|otp|signature|sig|auth|authorization)(?:[_-]|$)/i;// Strip credentials (userinfo, sensitive query/fragment values) before a URL// is shown in the always-visible step label. The full value stays behind the-// expandable details panel.+// expandable details panel. Handles bare (key), snake_case (api_key, auth_token),+// kebab-case (x-amz-signature), and camelCase (authToken, sessionToken) names.function redactUrlForLabel(url) {return String(url || '').replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/\s@]+@/i, '$1')- .replace(SENSITIVE_URL_PARAM_RE, '$1…');+ .replace(/([?&#])([^=&#\s]+)=([^&#\s]*)/g, (match, prefix, param) => {+ const norm = String(param || '').replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();+ return SENSITIVE_PARAM_WORDS_RE.test(norm) ? `${prefix}${param}=…` : match;+ });}function isTerminalDoneTool(name) {diff --git a/src/firefox/src/ui/sidepanel.js b/src/firefox/src/ui/sidepanel.jsindex 29af453e4..2cb0539d2 100644--- a/src/firefox/src/ui/sidepanel.js+++ b/src/firefox/src/ui/sidepanel.js@@ -2851,15 +2851,19 @@ const TOOL_KEYS = {carousel_navigate: 'tool.navigate',};-const SENSITIVE_URL_PARAM_RE = /([#?&](?:[^#&?=]*?[_.-])?(?:token|auth|api[_-]?key|secret|password|passwd|pwd|session|otp|signature|sig)(?:[_.-][^#&?=]*)?=)[^#&\s]*/gi;+const SENSITIVE_PARAM_WORDS_RE = /(?:^|[_-])(?:key|api[_-]?key|token|secret|password|passwd|pwd|session|otp|signature|sig|auth|authorization)(?:[_-]|$)/i;// Strip credentials (userinfo, sensitive query/fragment values) before a URL// is shown in the always-visible step label. The full value stays behind the-// expandable details panel.+// expandable details panel. Handles bare (key), snake_case (api_key, auth_token),+// kebab-case (x-amz-signature), and camelCase (authToken, sessionToken) names.function redactUrlForLabel(url) {return String(url || '').replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/\s@]+@/i, '$1')- .replace(SENSITIVE_URL_PARAM_RE, '$1…');+ .replace(/([?&#])([^=&#\s]+)=([^&#\s]*)/g, (match, prefix, param) => {+ const norm = String(param || '').replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();+ return SENSITIVE_PARAM_WORDS_RE.test(norm) ? `${prefix}${param}=…` : match;+ });}function isTerminalDoneTool(name) {diff --git a/test/run.js b/test/run.jsindex 47c06dc45..693e8c034 100644--- a/test/run.js+++ b/test/run.js@@ -45064,6 +45064,7 @@ test('sidepanel friendlyToolLabel localizes get_accessibility_tree and actions aassert.match(panel, /refreshRenderedStepLabels\(\);/, `${label}: locale-change handler must refresh rendered step labels`);assert.ok((panel.match(/refreshRenderedStepLabels\(\);/g) || []).length >= 4, `${label}: restored transcripts must refresh step labels on every restore path`);assert.match(panel, /function redactUrlForLabel\(url\)/, `${label}: URL step labels must redact credentials`);+ assert.match(panel, /SENSITIVE_PARAM_WORDS_RE/, `${label}: URL credential redaction must inspect sensitive parameter names`);assert.match(panel, /signature\|sig/, `${label}: URL credential redaction must cover signatures`);assert.match(panel, /redactUrlForLabel\(args\.url\)/, `${label}: fetch/research labels must redact URL credentials`);assert.match(panel, /function isTerminalDoneTool\(name\)/, `${label}: done_json must share terminal completion handling`);