Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

fix(sidepanel): redact sensitive path tokens and update redactor test assertion

Emre Sokulluf08ecc1ad6fd
diff --git a/src/chrome/src/ui/sidepanel.js b/src/chrome/src/ui/sidepanel.js
index b6f478d1c..22a34abc5 100644
--- a/src/chrome/src/ui/sidepanel.js
+++ b/src/chrome/src/ui/sidepanel.js
@@ -2991,15 +2991,16 @@ const TOOL_KEYS = {
};
const SENSITIVE_PARAM_WORDS_RE = /(?:^|[^a-z0-9])(?:key|api[_-]?key|token|secret|password|passwd|pwd|session|otp|signature|sig|auth|authorization|code|ticket|jwt|bearer|credential|credentials)(?:[^a-z0-9]|$)/i;
+const SENSITIVE_PATH_SEGMENT_RE = /(\/(?:reset|verify|verification|confirm|confirmation|magic|auth|invite|invitation|password|passwd)\/)[^/?#\s]+/gi;
-// 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. Handles bare (key), snake_case (api_key, auth_token),
-// kebab-case (x-amz-signature), and camelCase (authToken, sessionToken) names.
+// Strip credentials (userinfo, sensitive path tokens, sensitive query/fragment
+// values, and nested redirect URLs) before a URL is shown in the always-visible
+// step label. The full value stays behind the expandable details panel.
function redactUrlForLabel(url, depth = 0) {
if (depth > 3) return String(url || '');
return String(url || '')
.replace(/^([a-z][a-z0-9+.-]*:\/\/)(?:[^/?#\s]*@)+/i, '$1')
+ .replace(SENSITIVE_PATH_SEGMENT_RE, '$1…')
.replace(/([?&#])([^=&#\s]+)=([^&#\s]*)/g, (match, prefix, param, val) => {
let decoded = param;
try {
diff --git a/src/firefox/src/ui/sidepanel.js b/src/firefox/src/ui/sidepanel.js
index 4c0fa233c..c1e54bb89 100644
--- a/src/firefox/src/ui/sidepanel.js
+++ b/src/firefox/src/ui/sidepanel.js
@@ -2852,15 +2852,16 @@ const TOOL_KEYS = {
};
const SENSITIVE_PARAM_WORDS_RE = /(?:^|[^a-z0-9])(?:key|api[_-]?key|token|secret|password|passwd|pwd|session|otp|signature|sig|auth|authorization|code|ticket|jwt|bearer|credential|credentials)(?:[^a-z0-9]|$)/i;
+const SENSITIVE_PATH_SEGMENT_RE = /(\/(?:reset|verify|verification|confirm|confirmation|magic|auth|invite|invitation|password|passwd)\/)[^/?#\s]+/gi;
-// 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. Handles bare (key), snake_case (api_key, auth_token),
-// kebab-case (x-amz-signature), and camelCase (authToken, sessionToken) names.
+// Strip credentials (userinfo, sensitive path tokens, sensitive query/fragment
+// values, and nested redirect URLs) before a URL is shown in the always-visible
+// step label. The full value stays behind the expandable details panel.
function redactUrlForLabel(url, depth = 0) {
if (depth > 3) return String(url || '');
return String(url || '')
.replace(/^([a-z][a-z0-9+.-]*:\/\/)(?:[^/?#\s]*@)+/i, '$1')
+ .replace(SENSITIVE_PATH_SEGMENT_RE, '$1…')
.replace(/([?&#])([^=&#\s]+)=([^&#\s]*)/g, (match, prefix, param, val) => {
let decoded = param;
try {
diff --git a/test/run.js b/test/run.js
index 7d201d144..c5f66bc08 100644
--- a/test/run.js
+++ b/test/run.js
@@ -45063,7 +45063,8 @@ test('sidepanel friendlyToolLabel localizes get_accessibility_tree and actions a
assert.match(panel, /step\.dataset\.args = safeLabelArgs\(args\)/, `${label}: steps must persist label args for locale refresh`);
assert.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, /function redactUrlForLabel\(url/, `${label}: URL step labels must redact credentials`);
+ assert.match(panel, /SENSITIVE_PATH_SEGMENT_RE/, `${label}: URL credential redaction must sanitize sensitive path tokens`);
assert.match(panel, /\(\?:\[\^\/\?#\\s\]\*@\)\+/, `${label}: URL userinfo redaction must strip through final authority delimiter`);
assert.match(panel, /decodeURIComponent/, `${label}: URL credential redaction must decode parameter names`);
assert.match(panel, /SENSITIVE_PARAM_WORDS_RE/, `${label}: URL credential redaction must inspect sensitive parameter names`);