Skip to content

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

fix(sidepanel): keep sensitive values out of activity labels

Emre Sokullud5edd91485e7
diff --git a/src/chrome/src/ui/sidepanel.js b/src/chrome/src/ui/sidepanel.js
index c7e2fdc8e..1a68eb182 100644
--- a/src/chrome/src/ui/sidepanel.js
+++ b/src/chrome/src/ui/sidepanel.js
@@ -2990,40 +2990,6 @@ const TOOL_KEYS = {
carousel_navigate: 'tool.navigate',
};
-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 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 '…';
- return String(url || '')
- .trim()
- .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 {
- decoded = decodeURIComponent(param);
- } catch {}
- const norm = String(decoded || '').replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
- if (SENSITIVE_PARAM_WORDS_RE.test(norm)) {
- return `${prefix}${param}=…`;
- }
- if (val && /[%@=?:/]|%40|%2f|%3d|%3f/i.test(val)) {
- try {
- const decodedVal = decodeURIComponent(val);
- const redactedVal = redactUrlForLabel(decodedVal, depth + 1);
- if (redactedVal !== decodedVal) {
- return `${prefix}${param}=${encodeURIComponent(redactedVal)}`;
- }
- } catch {}
- }
- return match;
- });
-}
-
function isTerminalDoneTool(name) {
return name === 'done' || name === 'done_json';
}
@@ -3045,15 +3011,6 @@ function friendlyToolLabel(name, args) {
if (name === 'type_text' && args?.text) {
return t('tool.type_text.text', { text: truncate(args.text, 25) });
}
- if (name === 'navigate' && args?.url) return t('tool.navigate.url', { url: truncate(redactUrlForLabel(args.url), 35) });
- if (name === 'promote_iframe' && args?.urlFilter) return t('tool.navigate.url', { url: truncate(redactUrlForLabel(args.urlFilter), 35) });
- if (name === 'fetch_url' && args?.url) {
- return t('tool.fetch_url.url', { url: truncate(redactUrlForLabel(args.url), 35) });
- }
- if (name === 'research_url' && args?.url) {
- return t('tool.research_url.url', { url: truncate(redactUrlForLabel(args.url), 35) });
- }
- if (name === 'find_text' && args?.text) return t('tool.find_text.text', { text: truncate(args.text, 25) });
if (name === 'press_keys' && (args?.key || args?.keys)) return t('tool.press_keys.keys', { keys: truncate(args.key || args.keys, 25) });
if (name === 'scroll') return t('tool.scroll.direction', { direction: args?.direction || 'down' });
if (name === 'extract_data') return t('tool.extract_data.type', { type: args?.type || 'data' });
@@ -3068,7 +3025,7 @@ function friendlyToolLabel(name, args) {
return name || '';
}
-const LABEL_ARG_KEYS = ['selector', 'index', 'text', 'url', 'urlFilter', 'key', 'keys', 'direction', 'type'];
+const LABEL_ARG_KEYS = ['selector', 'index', 'key', 'keys', 'direction', 'type'];
// Persisted step labels are plain textContent, so a later locale change would
// otherwise leave old steps in the previous language (applyDOMTranslations only
diff --git a/src/firefox/src/ui/sidepanel.js b/src/firefox/src/ui/sidepanel.js
index 4d088e19a..ff5a6c303 100644
--- a/src/firefox/src/ui/sidepanel.js
+++ b/src/firefox/src/ui/sidepanel.js
@@ -2851,40 +2851,6 @@ const TOOL_KEYS = {
carousel_navigate: 'tool.navigate',
};
-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 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 '…';
- return String(url || '')
- .trim()
- .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 {
- decoded = decodeURIComponent(param);
- } catch {}
- const norm = String(decoded || '').replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
- if (SENSITIVE_PARAM_WORDS_RE.test(norm)) {
- return `${prefix}${param}=…`;
- }
- if (val && /[%@=?:/]|%40|%2f|%3d|%3f/i.test(val)) {
- try {
- const decodedVal = decodeURIComponent(val);
- const redactedVal = redactUrlForLabel(decodedVal, depth + 1);
- if (redactedVal !== decodedVal) {
- return `${prefix}${param}=${encodeURIComponent(redactedVal)}`;
- }
- } catch {}
- }
- return match;
- });
-}
-
function isTerminalDoneTool(name) {
return name === 'done' || name === 'done_json';
}
@@ -2906,15 +2872,6 @@ function friendlyToolLabel(name, args) {
if (name === 'type_text' && args?.text) {
return t('tool.type_text.text', { text: truncate(args.text, 25) });
}
- if (name === 'navigate' && args?.url) return t('tool.navigate.url', { url: truncate(redactUrlForLabel(args.url), 35) });
- if (name === 'promote_iframe' && args?.urlFilter) return t('tool.navigate.url', { url: truncate(redactUrlForLabel(args.urlFilter), 35) });
- if (name === 'fetch_url' && args?.url) {
- return t('tool.fetch_url.url', { url: truncate(redactUrlForLabel(args.url), 35) });
- }
- if (name === 'research_url' && args?.url) {
- return t('tool.research_url.url', { url: truncate(redactUrlForLabel(args.url), 35) });
- }
- if (name === 'find_text' && args?.text) return t('tool.find_text.text', { text: truncate(args.text, 25) });
if (name === 'press_keys' && (args?.key || args?.keys)) return t('tool.press_keys.keys', { keys: truncate(args.key || args.keys, 25) });
if (name === 'scroll') return t('tool.scroll.direction', { direction: args?.direction || 'down' });
if (name === 'extract_data') return t('tool.extract_data.type', { type: args?.type || 'data' });
@@ -2929,7 +2886,7 @@ function friendlyToolLabel(name, args) {
return name || '';
}
-const LABEL_ARG_KEYS = ['selector', 'index', 'text', 'url', 'urlFilter', 'key', 'keys', 'direction', 'type'];
+const LABEL_ARG_KEYS = ['selector', 'index', 'key', 'keys', 'direction', 'type'];
// Persisted step labels are plain textContent, so a later locale change would
// otherwise leave old steps in the previous language (applyDOMTranslations only
diff --git a/test/run.js b/test/run.js
index 7bbee334e..4348a2aee 100644
--- a/test/run.js
+++ b/test/run.js
@@ -45063,19 +45063,11 @@ 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, /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, /\(\?:\[a-z\]\[a-z0-9\+\.-\]\*:\)\?\\\/\\\//, `${label}: URL userinfo redaction must cover protocol-relative URLs`);
- 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`);
- assert.match(panel, /signature\|sig/, `${label}: URL credential redaction must cover signatures`);
- assert.match(panel, /authorization\|code/, `${label}: URL credential redaction must cover auth code`);
- assert.match(panel, /ticket\|jwt\|bearer\|credential/, `${label}: URL credential redaction must cover tickets, tokens, and credentials`);
- assert.match(panel, /if \(depth > 3\) return '…';/, `${label}: URL credential redaction must fail closed at depth limit`);
- assert.match(panel, /redactUrlForLabel\(args\.url\)/, `${label}: fetch/research labels must redact URL credentials`);
- assert.match(panel, /redactUrlForLabel\(decodedVal, depth \+ 1\)/, `${label}: URL credential redaction must redact nested URLs`);
+ assert.doesNotMatch(panel, /tool\.(?:navigate|fetch_url|research_url)\.url/, `${label}: activity labels must not disclose URLs`);
+ assert.doesNotMatch(panel, /name === 'find_text' && args\?\.text/, `${label}: find_text must not preview arbitrary search terms`);
assert.match(panel, /const LABEL_ARG_KEYS =/, `${label}: step metadata must filter arguments to label-relevant keys`);
+ assert.doesNotMatch(panel, /'url'/, `${label}: step metadata must not persist URLs`);
+ assert.doesNotMatch(panel, /'text'/, `${label}: step metadata must not persist typed or searched text`);
assert.match(panel, /function isTerminalDoneTool\(name\)/, `${label}: done_json must share terminal completion handling`);
assert.match(panel, /function restoreStepFriendlyLabel\(step\)/, `${label}: completed/failed steps must restore friendly label and clear progress marker`);
assert.match(panel, /failed \? 'sp\.tool\.done\.failed' : 'sp\.tool\.done\.completed'/, `${label}: restoreStepFriendlyLabel must set terminal failure outcome for interrupted done steps`);