Skip to content

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

Keep Ask read-only for API mutations, including automatic mode's Ask start

Claude6b7f87eeba12
diff --git a/docs/security-model.md b/docs/security-model.md
index bc2f939a8..7f9f6bce8 100644
--- a/docs/security-model.md
+++ b/docs/security-model.md
@@ -218,7 +218,7 @@ The primary threat: a malicious page crafts content that, when read by the agent
| **Plan before Act** | When enabled, action-mode runs first produce a structured plan and wait for side-panel approval before any browser tool executes. In Try mode, planner JSON that remains invalid after repair degrades that turn to Ask/read-only; Strict stops. Scheduled runs can auto-approve the plan only through scheduler policy. |
| **Skill import boundary** | Skills can expose read-only HTTP tools and download-job tools through a `webbrain-tools` manifest. Importing or keeping the skill enabled is the trust decision for the declared HTTPS endpoint; declared skill tools use `credentials: "omit"` and should mark third-party results `resultPolicy: "untrusted"`. Download-job skill tools still require an action mode and the normal Downloads permission gate before saving files. |
| **WebMCP boundary** | Experimental WebMCP is on by default, so its tools and prompt guidance enter ordinary model requests unless the user opts out under Settings → Bridge. Chrome page-registered names, descriptions, schemas, frame URLs, annotations, outputs, and errors are page-controlled and always use the untrusted-content wrapper. Calls use opaque IDs. Ask may list tools but cannot invoke them. Because a callback can run arbitrary page logic, every invocation requires Act/Dev, fresh per-call confirmation, and a permission grant for the actual registration-frame origin; a page-authored `readOnly` hint never bypasses those gates. Missing/opaque frame identity fails closed, and the frame plus effective HTTP(S) security origin are revalidated immediately before dispatch to prevent navigation races from borrowing an old grant. |
-| **API mutation override** | A per-conversation `/allow-api` flag, or the default-on persistent setting under Settings → Advanced, *waives* the permission prompt for write-method network egress (`fetch_url`/`research_url` with POST/PUT/PATCH/DELETE). Neither option waives GET egress or any other capability. Conversation reset clears only the slash-command override. |
+| **API mutation override** | A per-conversation `/allow-api` flag, or the default-on persistent setting under Settings → Advanced, *waives* the permission prompt for write-method network egress (`fetch_url`/`research_url` with POST/PUT/PATCH/DELETE) in Act and Dev. Ask stays read-only: an Ask run, including a turn that automatic mode starts in Ask, refuses a write-method request whatever these say. Neither option waives GET egress or any other capability. Conversation reset clears only the slash-command override. |
| **Decision models** | Auto (default) uses the downloaded in-browser model for completion and scheduled checks, or Compass's managed route while Compass is the chat provider; Off uses none. In On, OpenRouter, direct TypeSafe and local/custom System One endpoints share independent per-feature switches. Keys are optional for local servers. Compass completion uses its managed decision route unless D1 or the in-browser chat model is chosen. Bounded/redacted task and fresh page evidence are untrusted data. Judges have no browser executor; ordinary tool calls still pass policy, permission and completion layers. Strict Secret Mode, cancellation, quota and cost limits apply. Unavailable or malformed judgments fall through to the active LLM and existing checks. |
| **`done()` verification** | Decision and tool-free LLM checks prefer vision, then AX. Confident pending/failed outcomes require read-only recovery before another submission. Accepted task-bound proof can satisfy generic evidence despite an unrelated comment form, while explicit recipient, payment, download, authorization and workflow contracts remain required. Existing dialog/form checks are the final fallback. |
| **Grouped search approval** | A same-site GET form with no credential, payment or hidden token field, and no side-effect action address, shares one task-scoped approval for its navigation, typing and submit when the page's structure marks it as a search: a search landmark, a search-typed field or one whose keyboard says search, code names such as `q` or `query`, a search address, or a submit control a model read, in any language, as only searching or filtering. Words in a field's visible label decide nothing. Every other form keeps its fresh confirmation. |
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 6f2a81642..0de17f669 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -15769,7 +15769,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
|| this._pageFeedbackCalculationResponseScope?.(tabId) || null;
let didStateChange = false;
let autoScreenshotToolName = '';
- const apiMutationsDeniedForRun = runOptions.apiMutationsDenied === true;
+ // Ask is read-only, including a turn that automatic mode starts in Ask:
+ // a POST/PUT/PATCH/DELETE request changes something on the server, so
+ // neither /allow-api nor the API-mutations setting lets one out of Ask.
+ const apiMutationsDeniedForRun = runOptions.apiMutationsDenied === true
+ || this.conversationModes.get(tabId) === 'ask';
const apiMutationsAllowedForRun = () =>
!apiMutationsDeniedForRun && this.isApiMutationsAllowed(tabId);
const promptTier = this._resolvePromptTier(provider);
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 71cbfa5be..d3e12ecb1 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -14019,7 +14019,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
|| this._pageFeedbackCalculationResponseScope?.(tabId) || null;
let didStateChange = false;
let autoScreenshotToolName = '';
- const apiMutationsDeniedForRun = runOptions.apiMutationsDenied === true;
+ // Ask is read-only, including a turn that automatic mode starts in Ask:
+ // a POST/PUT/PATCH/DELETE request changes something on the server, so
+ // neither /allow-api nor the API-mutations setting lets one out of Ask.
+ const apiMutationsDeniedForRun = runOptions.apiMutationsDenied === true
+ || this.conversationModes.get(tabId) === 'ask';
const apiMutationsAllowedForRun = () =>
!apiMutationsDeniedForRun && this.isApiMutationsAllowed(tabId);
const promptTier = this._resolvePromptTier(provider);
diff --git a/test/run.js b/test/run.js
index 64e262790..c4ecb65f2 100644
--- a/test/run.js
+++ b/test/run.js
@@ -85943,6 +85943,56 @@ test('cloud Ask dispatch blocks API mutations even with an existing conversation
assert.ok(updates.some(update => /Ask mode is read-only/.test(update.data?.message || '')));
});
+test('a local Ask run keeps API mutations off even with the API-mutations setting on', async () => {
+ for (const AgentClass of [AgentCh, AgentFx]) {
+ const agent = new AgentClass({ getVisionProvider: async () => null });
+ const tabId = 4907;
+ let executed = 0;
+ agent.executeTool = async () => {
+ executed += 1;
+ return { success: true };
+ };
+ agent._ensureGateSetting = async () => { };
+ agent._skipPermissionGate = true;
+ agent.alwaysAllowApiMutations = true;
+ agent.setApiMutationsAllowed(tabId, true);
+ const send = async (mode) => {
+ agent.conversationModes.set(tabId, mode);
+ const messages = [];
+ const updates = [];
+ await agent._executeToolBatch(
+ tabId,
+ [{
+ id: `${mode}_mutation`,
+ function: {
+ name: 'fetch_url',
+ arguments: JSON.stringify({ url: 'https://mastodon.example/api/v1/statuses', method: 'POST', body: '{"status":"hi"}' }),
+ },
+ }],
+ messages,
+ (type, data) => updates.push({ type, data }),
+ { supportsVision: false },
+ '',
+ new Set(['fetch_url']),
+ 1,
+ );
+ return { messages, updates };
+ };
+
+ const ask = await send('ask');
+ assert.equal(executed, 0, `${AgentClass.name}: an Ask run sent a POST`);
+ const denied = JSON.parse(ask.messages[0].content);
+ assert.equal(denied.denied, true, `${AgentClass.name}: the POST was not refused`);
+ assert.equal(denied.requiresApiAllow, false, `${AgentClass.name}: /allow-api cannot open Ask`);
+ assert.match(denied.error, /not allowed in Ask mode/);
+ assert.ok(ask.updates.some(update => /Ask mode is read-only/.test(update.data?.message || '')));
+ assert.equal(agent.isApiMutationsAllowed(tabId), true, `${AgentClass.name}: the user's grant stays for Act`);
+
+ await send('act');
+ assert.equal(executed, 1, `${AgentClass.name}: Act still honors the API-mutations setting`);
+ }
+});
+
test('agent counts failed API mutation batch as one loop strategy', async () => {
for (const AgentClass of [AgentCh, AgentFx]) {
const agent = new AgentClass({ getVisionProvider: async () => null });