Skip to content

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

fix(permission): tighten grouped search candidate scope and gate checks

Codex release-state test50a05a8bee42
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index f82e8b38b..726fe5070 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -93,7 +93,7 @@ import {
normalizeCloudflareManagedChallengeState,
} from './cloudflare-managed-challenge.js';
import { getRecordingStateFresh as recorderStateFresh } from '../recorder/host.js';
-import { Capability, CAPABILITY_LABEL, SubmitRisk, capabilitiesFor, classifySearchNavigation, classifySubmitRisk, requiredHosts, frameHostMatches, isNetworkMutation, normalizeHost, PermissionManager, submitActionKey, UNTRUSTED_CONTENT_TOOLS } from './permission-gate.js';
+import { Capability, CAPABILITY_LABEL, SubmitRisk, capabilitiesFor, classifySearchNavigation, classifySubmitRisk, requiredHosts, frameHostMatches, isNetworkMutation, normalizeHost, registrableHost, PermissionManager, submitActionKey, UNTRUSTED_CONTENT_TOOLS } from './permission-gate.js';
import {
buildPlannerMessages,
buildPlannerIntentMessages,
@@ -11914,29 +11914,23 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
let choice = null;
if (canGroupSearch) {
const intentKey = submitActionKey(submitConfirmation, submitConfirmation.url);
- const intentVerdict = this.permissions.checkIntent(intentKey, tabId);
- if (intentVerdict.allowed) {
- choice = 'once';
- } else if (intentVerdict.needsPrompt) {
- choice = await this._promptGroupedSearchPermission(tabId, submitRisk.host, onUpdate);
- if (choice === null) {
- const value = '[Stopped by user before executing requested tool calls.]';
- this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
- success: false,
- cancelled: true,
- error: value,
- }));
- onUpdate('warning', { message: 'Stopped by user.' });
- return { action: 'abort', value };
- }
- this.permissions.recordIntent(
- intentKey,
- [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
- choice === 'once' ? 'allow' : 'deny',
- tabId,
- );
- } else {
- choice = 'deny';
+ choice = await this._authorizeGroupedSearch(
+ tabId,
+ submitRisk.host,
+ intentKey,
+ [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
+ onUpdate,
+ { actionUrl: submitRisk.action },
+ );
+ if (choice === null) {
+ const value = '[Stopped by user before executing requested tool calls.]';
+ this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
+ success: false,
+ cancelled: true,
+ error: value,
+ }));
+ onUpdate('warning', { message: 'Stopped by user.' });
+ return { action: 'abort', value };
}
if (choice === 'once') {
capabilities = capabilities.filter(capability => capability !== Capability.CLICK);
@@ -11992,41 +11986,48 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
groupedSearchForm.url,
);
if (groupedRisk.risk === SubmitRisk.LOW_RISK_SEARCH) {
- const intentKey = submitActionKey(groupedSearchForm, groupedSearchForm.url);
- const choice = await this._authorizeGroupedSearch(
- tabId,
- groupedRisk.host,
- intentKey,
- [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
- onUpdate,
- );
- if (choice === null) {
- const value = '[Stopped by user before executing requested tool calls.]';
- this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
- success: false,
- cancelled: true,
- error: value,
- }));
- onUpdate('warning', { message: 'Stopped by user.' });
- return { action: 'abort', value };
- }
- if (choice !== 'once') {
- messages.push({
- role: 'tool',
- tool_call_id: tc.id,
- content: JSON.stringify({
+ const existingGate = this.permissions.check(groupedRisk.host, Capability.TYPE, tabId);
+ if (existingGate.allowed) {
+ // Standing "always" type grant covers this; don't intercept with grouped search.
+ capabilities = capabilities.filter(capability => capability !== Capability.TYPE);
+ } else {
+ const intentKey = submitActionKey(groupedSearchForm, groupedSearchForm.url);
+ const choice = await this._authorizeGroupedSearch(
+ tabId,
+ groupedRisk.host,
+ intentKey,
+ [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
+ onUpdate,
+ { actionUrl: groupedRisk.action },
+ );
+ if (choice === null) {
+ const value = '[Stopped by user before executing requested tool calls.]';
+ this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
success: false,
- denied: true,
- permissionRequired: true,
- groupedPermission: true,
- error: `The user did not allow the grouped low-risk search actions on ${groupedRisk.host || 'this site'}. Do NOT retry this unchanged search unless the user explicitly allows it.`,
- }),
- });
- onUpdate('warning', { message: 'Low-risk search blocked until the user allows the grouped actions.' });
- if (interruptFailedBrowserAction(toolIndex, fnName)) { navNotices.length = 0; break; }
- continue;
+ cancelled: true,
+ error: value,
+ }));
+ onUpdate('warning', { message: 'Stopped by user.' });
+ return { action: 'abort', value };
+ }
+ if (choice !== 'once') {
+ messages.push({
+ role: 'tool',
+ tool_call_id: tc.id,
+ content: JSON.stringify({
+ success: false,
+ denied: true,
+ permissionRequired: true,
+ groupedPermission: true,
+ error: `The user did not allow the grouped low-risk search actions on ${groupedRisk.host || 'this site'}. Do NOT retry this unchanged search unless the user explicitly allows it.`,
+ }),
+ });
+ onUpdate('warning', { message: 'Low-risk search blocked until the user allows the grouped actions.' });
+ if (interruptFailedBrowserAction(toolIndex, fnName)) { navNotices.length = 0; break; }
+ continue;
+ }
+ capabilities = capabilities.filter(capability => capability !== Capability.TYPE);
}
- capabilities = capabilities.filter(capability => capability !== Capability.TYPE);
}
}
if (
@@ -12054,41 +12055,48 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (fnName === 'navigate' && capabilities.includes(Capability.NAVIGATE)) {
const navigationRisk = classifySearchNavigation(fnArgs?.url, curUrl);
if (navigationRisk.risk === SubmitRisk.LOW_RISK_SEARCH) {
- const choice = await this._authorizeGroupedSearch(
- tabId,
- navigationRisk.host,
- '',
- [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
- onUpdate,
- { candidateOnly: true },
- );
- if (choice === null) {
- const value = '[Stopped by user before executing requested tool calls.]';
- this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
- success: false,
- cancelled: true,
- error: value,
- }));
- onUpdate('warning', { message: 'Stopped by user.' });
- return { action: 'abort', value };
- }
- if (choice !== 'once') {
- messages.push({
- role: 'tool',
- tool_call_id: tc.id,
- content: JSON.stringify({
+ const existingGate = this.permissions.check(navigationRisk.host, Capability.NAVIGATE, tabId);
+ if (existingGate.allowed) {
+ // The user previously granted NAVIGATE (e.g. "always allow").
+ // Honor that standing grant and bypass the grouped search card.
+ capabilities = capabilities.filter(capability => capability !== Capability.NAVIGATE);
+ } else {
+ const choice = await this._authorizeGroupedSearch(
+ tabId,
+ navigationRisk.host,
+ '',
+ [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
+ onUpdate,
+ { candidateOnly: true, actionUrl: navigationRisk.action },
+ );
+ if (choice === null) {
+ const value = '[Stopped by user before executing requested tool calls.]';
+ this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
success: false,
- denied: true,
- permissionRequired: true,
- groupedPermission: true,
- error: `The user did not allow the grouped low-risk search actions on ${navigationRisk.host || 'this site'}. Do NOT retry this unchanged search unless the user explicitly allows it.`,
- }),
- });
- onUpdate('warning', { message: 'Low-risk search blocked until the user allows the grouped actions.' });
- if (interruptFailedBrowserAction(toolIndex, fnName)) { navNotices.length = 0; break; }
- continue;
+ cancelled: true,
+ error: value,
+ }));
+ onUpdate('warning', { message: 'Stopped by user.' });
+ return { action: 'abort', value };
+ }
+ if (choice !== 'once') {
+ messages.push({
+ role: 'tool',
+ tool_call_id: tc.id,
+ content: JSON.stringify({
+ success: false,
+ denied: true,
+ permissionRequired: true,
+ groupedPermission: true,
+ error: `The user did not allow the grouped low-risk search actions on ${navigationRisk.host || 'this site'}. Do NOT retry this unchanged search unless the user explicitly allows it.`,
+ }),
+ });
+ onUpdate('warning', { message: 'Low-risk search blocked until the user allows the grouped actions.' });
+ if (interruptFailedBrowserAction(toolIndex, fnName)) { navNotices.length = 0; break; }
+ continue;
+ }
+ capabilities = capabilities.filter(capability => capability !== Capability.NAVIGATE);
}
- capabilities = capabilities.filter(capability => capability !== Capability.NAVIGATE);
}
}
let blocked = null; // { capability, host }
@@ -12625,6 +12633,17 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const beforeFull = this._normalizeUrl(beforeUrl);
const afterFull = this._normalizeUrl(afterUrl);
const fullUrlChanged = beforeFull && afterFull && beforeFull !== afterFull;
+ if (fullUrlChanged) {
+ // If navigation leaves the approved candidate's registrable site,
+ // clear the candidate so it doesn't linger on an unrelated domain.
+ // Don't clear if navigating from blank/about/initial page into the target site,
+ // or between subdomains of the same registrable site.
+ const afterHost = normalizeHost(afterUrl);
+ const candidate = this.permissions.intentCandidates.find(c => c.tabId === tabId);
+ if (candidate && afterHost && registrableHost(afterHost) !== registrableHost(candidate.host)) {
+ this.permissions.clearIntentCandidates(tabId);
+ }
+ }
if (fullUrlChanged && toolResult && typeof toolResult === 'object') {
// Scroll refs/coordinates are scoped to the current route, including
// SPA views distinguished only by query/hash.
@@ -21620,14 +21639,17 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return String(response?.answer || '').trim().toLowerCase() === 'once' ? 'once' : 'deny';
}
- async _authorizeGroupedSearch(tabId, host, intentKey, capabilities, onUpdate, { candidateOnly = false } = {}) {
+ async _authorizeGroupedSearch(tabId, host, intentKey, capabilities, onUpdate, { candidateOnly = false, actionUrl = '' } = {}) {
let verdict = candidateOnly
- ? this.permissions.checkIntentCandidate(host, tabId)
+ ? this.permissions.checkIntentCandidate(host, tabId, null, actionUrl)
: this.permissions.checkIntent(intentKey, tabId);
if (!candidateOnly && !verdict.allowed && verdict.needsPrompt) {
- const candidateVerdict = this.permissions.checkIntentCandidate(host, tabId);
+ const candidateVerdict = this.permissions.checkIntentCandidate(host, tabId, null, actionUrl);
if (candidateVerdict.allowed) {
this.permissions.recordIntent(intentKey, capabilities, 'allow', tabId);
+ // Consume the single-use allow candidate so it does not auto-promote
+ // a subsequent search or different action later in the task.
+ this.permissions.consumeIntentCandidate(tabId);
return 'once';
}
if (!candidateVerdict.needsPrompt) return 'deny';
@@ -21642,6 +21664,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
capabilities,
choice === 'once' ? 'allow' : 'deny',
tabId,
+ actionUrl,
);
} else {
this.permissions.recordIntent(
@@ -23064,6 +23087,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
validationSubmitEvidence: detected.validationSubmitEvidence === 'strong' ? 'strong' : 'heuristic',
summary: String(detected.summary || '').slice(0, 1200),
fields: Array.isArray(detected.fields) ? detected.fields.slice(0, 12) : [],
+ hiddenFields: Array.isArray(detected.hiddenFields) ? detected.hiddenFields.slice(0, 20) : [],
changedFields: Array.isArray(detected.changedFields) ? detected.changedFields.slice(0, 8) : [],
method: String(detected.method || 'GET').slice(0, 20).toUpperCase(),
action: String(detected.action || '').slice(0, 300),
@@ -23095,6 +23119,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
tool: name,
summary: String(resolvedForm.summary || '').slice(0, 1200),
fields: Array.isArray(resolvedForm.fields) ? resolvedForm.fields.slice(0, 12) : [],
+ hiddenFields: Array.isArray(resolvedForm.hiddenFields) ? resolvedForm.hiddenFields.slice(0, 20) : [],
changedFields: Array.isArray(resolvedForm.changedFields) ? resolvedForm.changedFields.slice(0, 8) : [],
method: String(resolvedForm.method || 'GET').slice(0, 20).toUpperCase(),
action: String(resolvedForm.action || '').slice(0, 300),
@@ -23377,6 +23402,17 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return !['hidden', 'submit', 'button', 'reset', 'image'].includes(type);
})
.slice(0, 20);
+ // Capture hidden inputs metadata (names, IDs, labels only; NO values).
+ // This lets the risk classifier fail closed if a form contains a hidden
+ // token or credential field (csrf_token, api_key, etc.), without leaking
+ // hidden secrets into summaries or telemetry.
+ const hiddenControls = Array.from(form.querySelectorAll('input[type="hidden"]')).slice(0, 20);
+ const hiddenFields = hiddenControls.map(el => ({
+ type: 'hidden',
+ name: compact(el.getAttribute?.('name') || '', 80),
+ id: compact(el.getAttribute?.('id') || '', 80),
+ ariaLabel: compact(el.getAttribute?.('aria-label') || '', 120),
+ }));
const fields = controls.map((el) => {
const value = fieldValue(el, pendingEl, pendingValue);
const before = defaultValue(el);
@@ -23405,6 +23441,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return {
summary: `${origin} ${changedText}`,
fields: fields.slice(0, 12),
+ hiddenFields,
changedFields,
method,
action,
diff --git a/src/chrome/src/agent/permission-gate.js b/src/chrome/src/agent/permission-gate.js
index e74e05cab..452ded469 100644
--- a/src/chrome/src/agent/permission-gate.js
+++ b/src/chrome/src/agent/permission-gate.js
@@ -148,6 +148,22 @@ const MULTI_LABEL_SITE_SUFFIXES = new Set([
'github.io', 'gitlab.io', 'netlify.app', 'netlify.com', 'vercel.app',
'pages.dev', 'workers.dev', 'herokuapp.com', 'firebaseapp.com', 'web.app',
'glitch.me', 'cloudfront.net', 'azurewebsites.net', 'r2.dev', 'github.dev',
+ // Multi-tenant hosting suffixes: without these, alice.blogspot.com and
+ // victim.blogspot.com would compare equal and share a grouped approval.
+ 'blogspot.com', 'wordpress.com', 'wixsite.com', 'squarespace.com',
+ 'medium.com', 'notion.site', 'notion.so', 'webflow.io', 'shopify.com',
+ 'myshopify.com', 'tumblr.com', 'weebly.com', 'ghost.io', 'gitbook.io',
+ 'substack.com', 'storenvy.com', 'bigcartel.com', 'shopifycloud.com',
+ 'azureedge.net', 'amazonaws.com', 'elasticbeanstalk.com', 'appspot.com',
+]);
+
+// Three-label shared suffixes (e.g. alice.blogspot.co.uk, bucket.s3.amazonaws.com).
+// When the last three labels match, the registrable domain needs four labels
+// to stay tenant-specific.
+const THREE_LABEL_SITE_SUFFIXES = new Set([
+ 'blogspot.co.uk', 'blogspot.de', 'blogspot.fr', 'blogspot.jp',
+ 'wordpress.co.uk', 's3.amazonaws.com',
+ 's3-website-us-east-1.amazonaws.com', 's3-website-eu-west-1.amazonaws.com',
]);
export const SubmitRisk = {
@@ -188,12 +204,38 @@ export function registrableHost(input) {
if (host.includes(':') || /^\d+\.\d+\.\d+\.\d+$/.test(host)) return host;
const parts = host.split('.');
if (parts.length < 2) return host;
+ // Longest match first: a three-label shared suffix (e.g. blogspot.co.uk)
+ // needs four labels to stay tenant-specific.
+ if (parts.length >= 4) {
+ const suffix3 = parts.slice(-3).join('.');
+ if (THREE_LABEL_SITE_SUFFIXES.has(suffix3)) return parts.slice(-4).join('.');
+ }
const suffix = parts.slice(-2).join('.');
return parts.length >= 3 && MULTI_LABEL_SITE_SUFFIXES.has(suffix)
? parts.slice(-3).join('.')
: suffix;
}
+/**
+ * Normalized search-action identity (origin + pathname, no query/hash).
+ * Binds a grouped candidate to the approved search endpoint so a different
+ * form on the same registrable host does not auto-inherit the approval.
+ * Query terms live in changedFields (the intent key), not here.
+ */
+export function normalizeSearchActionBase(input) {
+ if (!input) return '';
+ try {
+ const parsed = new URL(String(input));
+ if (!/^https?:$/i.test(parsed.protocol)) return '';
+ const host = normalizeHost(parsed.hostname);
+ if (!host) return '';
+ const pathname = parsed.pathname || '/';
+ return `${parsed.protocol.toLowerCase()}//${host}${pathname}`;
+ } catch {
+ return '';
+ }
+}
+
function submitActionUrl(submitInfo = {}, currentUrlOrHost = '') {
const rawAction = submitInfo.actionUrl || submitInfo.action || submitInfo.url || currentUrlOrHost;
const base = submitInfo.url || currentUrlOrHost;
@@ -235,9 +277,17 @@ export function classifySubmitRisk(submitInfo = {}, currentUrlOrHost = '') {
const fields = Array.isArray(submitInfo.fields) ? submitInfo.fields.slice(0, 20) : [];
if (!fields.length) return freshSubmitRisk('form has no resolved search fields');
+ // Hidden controls are excluded from visible fields by the probe, but their
+ // names/ids can still carry secrets (csrf_token, access_token, api_key).
+ // The probe reports them as metadata-only hiddenFields (no values), so a
+ // hidden token field still disqualifies the form from grouping.
+ const hiddenFields = Array.isArray(submitInfo.hiddenFields) ? submitInfo.hiddenFields.slice(0, 20) : [];
if (fields.some(field => SENSITIVE_SUBMIT_FIELD_RE.test(submitFieldDescriptor(field)))) {
return freshSubmitRisk('form contains a credential or payment field');
}
+ if (hiddenFields.some(field => SENSITIVE_SUBMIT_FIELD_RE.test(submitFieldDescriptor(field)))) {
+ return freshSubmitRisk('form contains a hidden credential or token field');
+ }
const pathname = actionUrl.pathname || '/';
const actionParameters = [...actionUrl.searchParams.keys()].join(' ');
@@ -304,7 +354,8 @@ export function submitActionKey(submitInfo = {}, currentUrlOrHost = '') {
const host = normalizeHost(actionUrl?.hostname || submitInfo.host || currentUrlOrHost);
const method = String(submitInfo.method || 'GET').trim().toUpperCase();
const fields = Array.isArray(submitInfo.fields) ? submitInfo.fields : [];
- const sensitive = fields
+ const hiddenFields = Array.isArray(submitInfo.hiddenFields) ? submitInfo.hiddenFields : [];
+ const sensitive = [...fields, ...hiddenFields]
.filter(field => SENSITIVE_SUBMIT_FIELD_RE.test(submitFieldDescriptor(field)))
.map(field => submitFieldDescriptor(field));
const changed = (Array.isArray(submitInfo.changedFields) ? submitInfo.changedFields : fields.filter(field => field?.changed))
@@ -660,18 +711,30 @@ export class PermissionManager {
return this.intentCandidates.some(candidate => candidate.tabId === tabId);
}
- checkIntentCandidate(host, tabId, capability = null) {
+ /**
+ * Check a provisional navigation candidate. The candidate is bound to the
+ * approved search endpoint (origin + pathname via normalizeSearchActionBase)
+ * in addition to the registrable host, so approving one search form does not
+ * auto-approve a different form or a different search URL on the same site.
+ * Pass expectedAction (the new navigation target or form action) to enforce
+ * the binding; omitting it preserves the legacy host-only check.
+ */
+ checkIntentCandidate(host, tabId, capability = null, expectedAction = '') {
const targetSite = registrableHost(host);
+ const expectedBase = normalizeSearchActionBase(expectedAction);
const candidate = this.intentCandidates.find(item =>
item.tabId === tabId
&& registrableHost(item.host) === targetSite
&& (!capability || item.capabilities.includes(capability))
);
if (!candidate) return { allowed: false, needsPrompt: true };
+ if (expectedBase && candidate.actionBase && candidate.actionBase !== expectedBase) {
+ return { allowed: false, needsPrompt: true };
+ }
return { allowed: candidate.action === 'allow', needsPrompt: false, candidate };
}
- recordIntentCandidate(host, capabilities, action, tabId) {
+ recordIntentCandidate(host, capabilities, action, tabId, actionUrl = '') {
const normalizedHost = normalizeHost(host);
if (!normalizedHost) return;
this.intentCandidates = this.intentCandidates.filter(candidate => candidate.tabId !== tabId);
@@ -679,11 +742,27 @@ export class PermissionManager {
host: normalizedHost,
capabilities: [...new Set(Array.isArray(capabilities) ? capabilities : [])],
action: action === 'allow' ? 'allow' : 'deny',
+ actionBase: normalizeSearchActionBase(actionUrl || host),
+ actionUrl: String(actionUrl || '').slice(0, 300),
tabId,
ts: Date.now(),
});
}
+ /**
+ * Consume a single-use allow candidate after it promotes to a full intent
+ * grant. Without this, one approval would auto-promote every subsequent
+ * same-site search for the rest of the turn, contradicting the "only this
+ * unchanged search" consent copy. Deny candidates persist so retries fail
+ * closed without re-prompting.
+ */
+ consumeIntentCandidate(tabId) {
+ const remaining = this.intentCandidates.filter(candidate =>
+ !(candidate.tabId === tabId && candidate.action === 'allow')
+ );
+ this.intentCandidates = remaining;
+ }
+
clearIntentCandidates(tabId) {
this.intentCandidates = this.intentCandidates.filter(candidate => candidate.tabId !== tabId);
}
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index d1958ddc0..3f7d7e097 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -87,7 +87,7 @@ import {
cloudflareManagedChallengeStorageKey,
normalizeCloudflareManagedChallengeState,
} from './cloudflare-managed-challenge.js';
-import { Capability, CAPABILITY_LABEL, SubmitRisk, capabilitiesFor, classifySearchNavigation, classifySubmitRisk, requiredHosts, frameHostMatches, isNetworkMutation, normalizeHost, PermissionManager, submitActionKey, UNTRUSTED_CONTENT_TOOLS } from './permission-gate.js';
+import { Capability, CAPABILITY_LABEL, SubmitRisk, capabilitiesFor, classifySearchNavigation, classifySubmitRisk, requiredHosts, frameHostMatches, isNetworkMutation, normalizeHost, registrableHost, PermissionManager, submitActionKey, UNTRUSTED_CONTENT_TOOLS } from './permission-gate.js';
import {
buildPlannerMessages,
buildPlannerIntentMessages,
@@ -10465,29 +10465,23 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
let choice = null;
if (canGroupSearch) {
const intentKey = submitActionKey(submitConfirmation, submitConfirmation.url);
- const intentVerdict = this.permissions.checkIntent(intentKey, tabId);
- if (intentVerdict.allowed) {
- choice = 'once';
- } else if (intentVerdict.needsPrompt) {
- choice = await this._promptGroupedSearchPermission(tabId, submitRisk.host, onUpdate);
- if (choice === null) {
- const value = '[Stopped by user before executing requested tool calls.]';
- this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
- success: false,
- cancelled: true,
- error: value,
- }));
- onUpdate('warning', { message: 'Stopped by user.' });
- return { action: 'abort', value };
- }
- this.permissions.recordIntent(
- intentKey,
- [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
- choice === 'once' ? 'allow' : 'deny',
- tabId,
- );
- } else {
- choice = 'deny';
+ choice = await this._authorizeGroupedSearch(
+ tabId,
+ submitRisk.host,
+ intentKey,
+ [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
+ onUpdate,
+ { actionUrl: submitRisk.action },
+ );
+ if (choice === null) {
+ const value = '[Stopped by user before executing requested tool calls.]';
+ this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
+ success: false,
+ cancelled: true,
+ error: value,
+ }));
+ onUpdate('warning', { message: 'Stopped by user.' });
+ return { action: 'abort', value };
}
if (choice === 'once') {
capabilities = capabilities.filter(capability => capability !== Capability.CLICK);
@@ -10544,41 +10538,48 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
groupedSearchForm.url,
);
if (groupedRisk.risk === SubmitRisk.LOW_RISK_SEARCH) {
- const intentKey = submitActionKey(groupedSearchForm, groupedSearchForm.url);
- const choice = await this._authorizeGroupedSearch(
- tabId,
- groupedRisk.host,
- intentKey,
- [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
- onUpdate,
- );
- if (choice === null) {
- const value = '[Stopped by user before executing requested tool calls.]';
- this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
- success: false,
- cancelled: true,
- error: value,
- }));
- onUpdate('warning', { message: 'Stopped by user.' });
- return { action: 'abort', value };
- }
- if (choice !== 'once') {
- messages.push({
- role: 'tool',
- tool_call_id: tc.id,
- content: JSON.stringify({
+ const existingGate = this.permissions.check(groupedRisk.host, Capability.TYPE, tabId);
+ if (existingGate.allowed) {
+ // Standing "always" type grant covers this; don't intercept with grouped search.
+ capabilities = capabilities.filter(capability => capability !== Capability.TYPE);
+ } else {
+ const intentKey = submitActionKey(groupedSearchForm, groupedSearchForm.url);
+ const choice = await this._authorizeGroupedSearch(
+ tabId,
+ groupedRisk.host,
+ intentKey,
+ [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
+ onUpdate,
+ { actionUrl: groupedRisk.action },
+ );
+ if (choice === null) {
+ const value = '[Stopped by user before executing requested tool calls.]';
+ this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
success: false,
- denied: true,
- permissionRequired: true,
- groupedPermission: true,
- error: `The user did not allow the grouped low-risk search actions on ${groupedRisk.host || 'this site'}. Do NOT retry this unchanged search unless the user explicitly allows it.`,
- }),
- });
- onUpdate('warning', { message: 'Low-risk search blocked until the user allows the grouped actions.' });
- if (interruptFailedBrowserAction(toolIndex, fnName)) { navNotices.length = 0; break; }
- continue;
+ cancelled: true,
+ error: value,
+ }));
+ onUpdate('warning', { message: 'Stopped by user.' });
+ return { action: 'abort', value };
+ }
+ if (choice !== 'once') {
+ messages.push({
+ role: 'tool',
+ tool_call_id: tc.id,
+ content: JSON.stringify({
+ success: false,
+ denied: true,
+ permissionRequired: true,
+ groupedPermission: true,
+ error: `The user did not allow the grouped low-risk search actions on ${groupedRisk.host || 'this site'}. Do NOT retry this unchanged search unless the user explicitly allows it.`,
+ }),
+ });
+ onUpdate('warning', { message: 'Low-risk search blocked until the user allows the grouped actions.' });
+ if (interruptFailedBrowserAction(toolIndex, fnName)) { navNotices.length = 0; break; }
+ continue;
+ }
+ capabilities = capabilities.filter(capability => capability !== Capability.TYPE);
}
- capabilities = capabilities.filter(capability => capability !== Capability.TYPE);
}
}
if (
@@ -10606,41 +10607,48 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (fnName === 'navigate' && capabilities.includes(Capability.NAVIGATE)) {
const navigationRisk = classifySearchNavigation(fnArgs?.url, curUrl);
if (navigationRisk.risk === SubmitRisk.LOW_RISK_SEARCH) {
- const choice = await this._authorizeGroupedSearch(
- tabId,
- navigationRisk.host,
- '',
- [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
- onUpdate,
- { candidateOnly: true },
- );
- if (choice === null) {
- const value = '[Stopped by user before executing requested tool calls.]';
- this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
- success: false,
- cancelled: true,
- error: value,
- }));
- onUpdate('warning', { message: 'Stopped by user.' });
- return { action: 'abort', value };
- }
- if (choice !== 'once') {
- messages.push({
- role: 'tool',
- tool_call_id: tc.id,
- content: JSON.stringify({
+ const existingGate = this.permissions.check(navigationRisk.host, Capability.NAVIGATE, tabId);
+ if (existingGate.allowed) {
+ // The user previously granted NAVIGATE (e.g. "always allow").
+ // Honor that standing grant and bypass the grouped search card.
+ capabilities = capabilities.filter(capability => capability !== Capability.NAVIGATE);
+ } else {
+ const choice = await this._authorizeGroupedSearch(
+ tabId,
+ navigationRisk.host,
+ '',
+ [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK],
+ onUpdate,
+ { candidateOnly: true, actionUrl: navigationRisk.action },
+ );
+ if (choice === null) {
+ const value = '[Stopped by user before executing requested tool calls.]';
+ this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({
success: false,
- denied: true,
- permissionRequired: true,
- groupedPermission: true,
- error: `The user did not allow the grouped low-risk search actions on ${navigationRisk.host || 'this site'}. Do NOT retry this unchanged search unless the user explicitly allows it.`,
- }),
- });
- onUpdate('warning', { message: 'Low-risk search blocked until the user allows the grouped actions.' });
- if (interruptFailedBrowserAction(toolIndex, fnName)) { navNotices.length = 0; break; }
- continue;
+ cancelled: true,
+ error: value,
+ }));
+ onUpdate('warning', { message: 'Stopped by user.' });
+ return { action: 'abort', value };
+ }
+ if (choice !== 'once') {
+ messages.push({
+ role: 'tool',
+ tool_call_id: tc.id,
+ content: JSON.stringify({
+ success: false,
+ denied: true,
+ permissionRequired: true,
+ groupedPermission: true,
+ error: `The user did not allow the grouped low-risk search actions on ${navigationRisk.host || 'this site'}. Do NOT retry this unchanged search unless the user explicitly allows it.`,
+ }),
+ });
+ onUpdate('warning', { message: 'Low-risk search blocked until the user allows the grouped actions.' });
+ if (interruptFailedBrowserAction(toolIndex, fnName)) { navNotices.length = 0; break; }
+ continue;
+ }
+ capabilities = capabilities.filter(capability => capability !== Capability.NAVIGATE);
}
- capabilities = capabilities.filter(capability => capability !== Capability.NAVIGATE);
}
}
let blocked = null; // { capability, host }
@@ -11154,6 +11162,17 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const beforeFull = this._normalizeUrl(beforeUrl);
const afterFull = this._normalizeUrl(afterUrl);
const fullUrlChanged = beforeFull && afterFull && beforeFull !== afterFull;
+ if (fullUrlChanged) {
+ // If navigation leaves the approved candidate's registrable site,
+ // clear the candidate so it doesn't linger on an unrelated domain.
+ // Don't clear if navigating from blank/about/initial page into the target site,
+ // or between subdomains of the same registrable site.
+ const afterHost = normalizeHost(afterUrl);
+ const candidate = this.permissions.intentCandidates.find(c => c.tabId === tabId);
+ if (candidate && afterHost && registrableHost(afterHost) !== registrableHost(candidate.host)) {
+ this.permissions.clearIntentCandidates(tabId);
+ }
+ }
if (fullUrlChanged && toolResult && typeof toolResult === 'object') {
// Scroll refs/coordinates are scoped to the current route, including
// SPA views distinguished only by query/hash.
@@ -19377,14 +19396,17 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return String(response?.answer || '').trim().toLowerCase() === 'once' ? 'once' : 'deny';
}
- async _authorizeGroupedSearch(tabId, host, intentKey, capabilities, onUpdate, { candidateOnly = false } = {}) {
+ async _authorizeGroupedSearch(tabId, host, intentKey, capabilities, onUpdate, { candidateOnly = false, actionUrl = '' } = {}) {
let verdict = candidateOnly
- ? this.permissions.checkIntentCandidate(host, tabId)
+ ? this.permissions.checkIntentCandidate(host, tabId, null, actionUrl)
: this.permissions.checkIntent(intentKey, tabId);
if (!candidateOnly && !verdict.allowed && verdict.needsPrompt) {
- const candidateVerdict = this.permissions.checkIntentCandidate(host, tabId);
+ const candidateVerdict = this.permissions.checkIntentCandidate(host, tabId, null, actionUrl);
if (candidateVerdict.allowed) {
this.permissions.recordIntent(intentKey, capabilities, 'allow', tabId);
+ // Consume the single-use allow candidate so it does not auto-promote
+ // a subsequent search or different action later in the task.
+ this.permissions.consumeIntentCandidate(tabId);
return 'once';
}
if (!candidateVerdict.needsPrompt) return 'deny';
@@ -19399,6 +19421,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
capabilities,
choice === 'once' ? 'allow' : 'deny',
tabId,
+ actionUrl,
);
} else {
this.permissions.recordIntent(
@@ -20824,6 +20847,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
validationSubmitEvidence: detected.validationSubmitEvidence === 'strong' ? 'strong' : 'heuristic',
summary: String(detected.summary || '').slice(0, 1200),
fields: Array.isArray(detected.fields) ? detected.fields.slice(0, 12) : [],
+ hiddenFields: Array.isArray(detected.hiddenFields) ? detected.hiddenFields.slice(0, 20) : [],
changedFields: Array.isArray(detected.changedFields) ? detected.changedFields.slice(0, 8) : [],
method: String(detected.method || 'GET').slice(0, 20).toUpperCase(),
action: String(detected.action || '').slice(0, 300),
@@ -20855,6 +20879,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
tool: name,
summary: String(resolvedForm.summary || '').slice(0, 1200),
fields: Array.isArray(resolvedForm.fields) ? resolvedForm.fields.slice(0, 12) : [],
+ hiddenFields: Array.isArray(resolvedForm.hiddenFields) ? resolvedForm.hiddenFields.slice(0, 20) : [],
changedFields: Array.isArray(resolvedForm.changedFields) ? resolvedForm.changedFields.slice(0, 8) : [],
method: String(resolvedForm.method || 'GET').slice(0, 20).toUpperCase(),
action: String(resolvedForm.action || '').slice(0, 300),
@@ -21049,6 +21074,17 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return !['hidden', 'submit', 'button', 'reset', 'image'].includes(type);
})
.slice(0, 20);
+ // Capture hidden inputs metadata (names, IDs, labels only; NO values).
+ // This lets the risk classifier fail closed if a form contains a hidden
+ // token or credential field (csrf_token, api_key, etc.), without leaking
+ // hidden secrets into summaries or telemetry.
+ const hiddenControls = Array.from(form.querySelectorAll('input[type="hidden"]')).slice(0, 20);
+ const hiddenFields = hiddenControls.map(el => ({
+ type: 'hidden',
+ name: compact(el.getAttribute?.('name') || '', 80),
+ id: compact(el.getAttribute?.('id') || '', 80),
+ ariaLabel: compact(el.getAttribute?.('aria-label') || '', 120),
+ }));
const fields = controls.map((el) => {
const value = fieldValue(el, pendingEl, pendingValue);
const before = defaultValue(el);
@@ -21077,6 +21113,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return {
summary: `${origin} ${changedText}`,
fields: fields.slice(0, 12),
+ hiddenFields,
changedFields,
method,
action,
diff --git a/src/firefox/src/agent/permission-gate.js b/src/firefox/src/agent/permission-gate.js
index 071c350c4..ed8f50c16 100644
--- a/src/firefox/src/agent/permission-gate.js
+++ b/src/firefox/src/agent/permission-gate.js
@@ -139,6 +139,22 @@ const MULTI_LABEL_SITE_SUFFIXES = new Set([
'github.io', 'gitlab.io', 'netlify.app', 'netlify.com', 'vercel.app',
'pages.dev', 'workers.dev', 'herokuapp.com', 'firebaseapp.com', 'web.app',
'glitch.me', 'cloudfront.net', 'azurewebsites.net', 'r2.dev', 'github.dev',
+ // Multi-tenant hosting suffixes: without these, alice.blogspot.com and
+ // victim.blogspot.com would compare equal and share a grouped approval.
+ 'blogspot.com', 'wordpress.com', 'wixsite.com', 'squarespace.com',
+ 'medium.com', 'notion.site', 'notion.so', 'webflow.io', 'shopify.com',
+ 'myshopify.com', 'tumblr.com', 'weebly.com', 'ghost.io', 'gitbook.io',
+ 'substack.com', 'storenvy.com', 'bigcartel.com', 'shopifycloud.com',
+ 'azureedge.net', 'amazonaws.com', 'elasticbeanstalk.com', 'appspot.com',
+]);
+
+// Three-label shared suffixes (e.g. alice.blogspot.co.uk, bucket.s3.amazonaws.com).
+// When the last three labels match, the registrable domain needs four labels
+// to stay tenant-specific.
+const THREE_LABEL_SITE_SUFFIXES = new Set([
+ 'blogspot.co.uk', 'blogspot.de', 'blogspot.fr', 'blogspot.jp',
+ 'wordpress.co.uk', 's3.amazonaws.com',
+ 's3-website-us-east-1.amazonaws.com', 's3-website-eu-west-1.amazonaws.com',
]);
export const SubmitRisk = {
@@ -179,12 +195,38 @@ export function registrableHost(input) {
if (host.includes(':') || /^\d+\.\d+\.\d+\.\d+$/.test(host)) return host;
const parts = host.split('.');
if (parts.length < 2) return host;
+ // Longest match first: a three-label shared suffix (e.g. blogspot.co.uk)
+ // needs four labels to stay tenant-specific.
+ if (parts.length >= 4) {
+ const suffix3 = parts.slice(-3).join('.');
+ if (THREE_LABEL_SITE_SUFFIXES.has(suffix3)) return parts.slice(-4).join('.');
+ }
const suffix = parts.slice(-2).join('.');
return parts.length >= 3 && MULTI_LABEL_SITE_SUFFIXES.has(suffix)
? parts.slice(-3).join('.')
: suffix;
}
+/**
+ * Normalized search-action identity (origin + pathname, no query/hash).
+ * Binds a grouped candidate to the approved search endpoint so a different
+ * form on the same registrable host does not auto-inherit the approval.
+ * Query terms live in changedFields (the intent key), not here.
+ */
+export function normalizeSearchActionBase(input) {
+ if (!input) return '';
+ try {
+ const parsed = new URL(String(input));
+ if (!/^https?:$/i.test(parsed.protocol)) return '';
+ const host = normalizeHost(parsed.hostname);
+ if (!host) return '';
+ const pathname = parsed.pathname || '/';
+ return `${parsed.protocol.toLowerCase()}//${host}${pathname}`;
+ } catch {
+ return '';
+ }
+}
+
function submitActionUrl(submitInfo = {}, currentUrlOrHost = '') {
const rawAction = submitInfo.actionUrl || submitInfo.action || submitInfo.url || currentUrlOrHost;
const base = submitInfo.url || currentUrlOrHost;
@@ -226,9 +268,17 @@ export function classifySubmitRisk(submitInfo = {}, currentUrlOrHost = '') {
const fields = Array.isArray(submitInfo.fields) ? submitInfo.fields.slice(0, 20) : [];
if (!fields.length) return freshSubmitRisk('form has no resolved search fields');
+ // Hidden controls are excluded from visible fields by the probe, but their
+ // names/ids can still carry secrets (csrf_token, access_token, api_key).
+ // The probe reports them as metadata-only hiddenFields (no values), so a
+ // hidden token field still disqualifies the form from grouping.
+ const hiddenFields = Array.isArray(submitInfo.hiddenFields) ? submitInfo.hiddenFields.slice(0, 20) : [];
if (fields.some(field => SENSITIVE_SUBMIT_FIELD_RE.test(submitFieldDescriptor(field)))) {
return freshSubmitRisk('form contains a credential or payment field');
}
+ if (hiddenFields.some(field => SENSITIVE_SUBMIT_FIELD_RE.test(submitFieldDescriptor(field)))) {
+ return freshSubmitRisk('form contains a hidden credential or token field');
+ }
const pathname = actionUrl.pathname || '/';
const actionParameters = [...actionUrl.searchParams.keys()].join(' ');
@@ -295,7 +345,8 @@ export function submitActionKey(submitInfo = {}, currentUrlOrHost = '') {
const host = normalizeHost(actionUrl?.hostname || submitInfo.host || currentUrlOrHost);
const method = String(submitInfo.method || 'GET').trim().toUpperCase();
const fields = Array.isArray(submitInfo.fields) ? submitInfo.fields : [];
- const sensitive = fields
+ const hiddenFields = Array.isArray(submitInfo.hiddenFields) ? submitInfo.hiddenFields : [];
+ const sensitive = [...fields, ...hiddenFields]
.filter(field => SENSITIVE_SUBMIT_FIELD_RE.test(submitFieldDescriptor(field)))
.map(field => submitFieldDescriptor(field));
const changed = (Array.isArray(submitInfo.changedFields) ? submitInfo.changedFields : fields.filter(field => field?.changed))
@@ -645,18 +696,30 @@ export class PermissionManager {
return this.intentCandidates.some(candidate => candidate.tabId === tabId);
}
- checkIntentCandidate(host, tabId, capability = null) {
+ /**
+ * Check a provisional navigation candidate. The candidate is bound to the
+ * approved search endpoint (origin + pathname via normalizeSearchActionBase)
+ * in addition to the registrable host, so approving one search form does not
+ * auto-approve a different form or a different search URL on the same site.
+ * Pass expectedAction (the new navigation target or form action) to enforce
+ * the binding; omitting it preserves the legacy host-only check.
+ */
+ checkIntentCandidate(host, tabId, capability = null, expectedAction = '') {
const targetSite = registrableHost(host);
+ const expectedBase = normalizeSearchActionBase(expectedAction);
const candidate = this.intentCandidates.find(item =>
item.tabId === tabId
&& registrableHost(item.host) === targetSite
&& (!capability || item.capabilities.includes(capability))
);
if (!candidate) return { allowed: false, needsPrompt: true };
+ if (expectedBase && candidate.actionBase && candidate.actionBase !== expectedBase) {
+ return { allowed: false, needsPrompt: true };
+ }
return { allowed: candidate.action === 'allow', needsPrompt: false, candidate };
}
- recordIntentCandidate(host, capabilities, action, tabId) {
+ recordIntentCandidate(host, capabilities, action, tabId, actionUrl = '') {
const normalizedHost = normalizeHost(host);
if (!normalizedHost) return;
this.intentCandidates = this.intentCandidates.filter(candidate => candidate.tabId !== tabId);
@@ -664,11 +727,27 @@ export class PermissionManager {
host: normalizedHost,
capabilities: [...new Set(Array.isArray(capabilities) ? capabilities : [])],
action: action === 'allow' ? 'allow' : 'deny',
+ actionBase: normalizeSearchActionBase(actionUrl || host),
+ actionUrl: String(actionUrl || '').slice(0, 300),
tabId,
ts: Date.now(),
});
}
+ /**
+ * Consume a single-use allow candidate after it promotes to a full intent
+ * grant. Without this, one approval would auto-promote every subsequent
+ * same-site search for the rest of the turn, contradicting the "only this
+ * unchanged search" consent copy. Deny candidates persist so retries fail
+ * closed without re-prompting.
+ */
+ consumeIntentCandidate(tabId) {
+ const remaining = this.intentCandidates.filter(candidate =>
+ !(candidate.tabId === tabId && candidate.action === 'allow')
+ );
+ this.intentCandidates = remaining;
+ }
+
clearIntentCandidates(tabId) {
this.intentCandidates = this.intentCandidates.filter(candidate => candidate.tabId !== tabId);
}
diff --git a/test/run.js b/test/run.js
index 8151e9d61..f72d0c637 100644
--- a/test/run.js
+++ b/test/run.js
@@ -106687,6 +106687,13 @@ test('submit risk classifier groups only conservative same-site GET searches', (
);
assert.equal(registrableHost('api.example.co.uk'), 'example.co.uk');
assert.equal(registrableHostCh('www.example.co.uk'), 'example.co.uk');
+ // Multi-tenant suffixes keep distinct tenants isolated
+ assert.equal(registrableHost('alice.blogspot.com'), 'alice.blogspot.com');
+ assert.notEqual(registrableHost('alice.blogspot.com'), registrableHost('victim.blogspot.com'));
+ assert.equal(registrableHost('user.notion.site'), 'user.notion.site');
+ assert.equal(registrableHost('store.myshopify.com'), 'store.myshopify.com');
+ assert.equal(registrableHost('alice.blogspot.co.uk'), 'alice.blogspot.co.uk');
+ assert.notEqual(registrableHost('alice.blogspot.co.uk'), registrableHost('victim.blogspot.co.uk'));
for (const [label, classify] of [['firefox', classifySubmitRisk], ['chrome', classifySubmitRiskCh]]) {
const cases = [
@@ -106696,6 +106703,8 @@ test('submit risk classifier groups only conservative same-site GET searches', (
[{ ...search, fields: [{ type: 'text', name: 'cardnumber', label: 'Card number' }] }, 'payment'],
[{ ...search, fields: [{ type: 'password', name: 'q', label: 'Search' }] }, 'credential'],
[{ ...search, actionUrl: 'https://scholar.google.com/account', fields: [{ type: 'text', name: 'title', label: 'Title' }] }, 'resolved search'],
+ [{ ...search, hiddenFields: [{ type: 'hidden', name: 'csrf_token' }] }, 'hidden csrf token'],
+ [{ ...search, hiddenFields: [{ type: 'hidden', name: 'api_key' }] }, 'hidden api key'],
];
for (const [info, reason] of cases) {
const result = classify(info, search.url);
@@ -106733,6 +106742,15 @@ test('task-scoped grouped approvals stay per-tab, deny retries, and expire at tu
assert.equal(pm.checkIntent(key, 1, Capability.CLICK).needsPrompt, false);
pm.beginTurn(1);
assert.equal(pm.checkIntent(key, 1, Capability.CLICK).needsPrompt, true);
+
+ // Candidate grants are bound to action URL and single-use allow promotion
+ pm.recordIntentCandidate('scholar.google.com', [Capability.NAVIGATE, Capability.TYPE, Capability.CLICK], 'allow', 1, 'https://scholar.google.com/scholar');
+ assert.equal(pm.checkIntentCandidate('scholar.google.com', 1, null, 'https://scholar.google.com/scholar').allowed, true);
+ // Different action path on same site must not be allowed
+ assert.equal(pm.checkIntentCandidate('scholar.google.com', 1, null, 'https://scholar.google.com/different').needsPrompt, true);
+ // Single-use allow candidate consumption
+ pm.consumeIntentCandidate(1);
+ assert.equal(pm.checkIntentCandidate('scholar.google.com', 1, null, 'https://scholar.google.com/scholar').needsPrompt, true);
});
test('parity: chrome & firefox permission-gate behave identically', async () => {