Skip to content

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

Placeholder guard: keep a receipt for appends whose result is unknown

Claude8fa45b4adeff
diff --git a/docs/security-model.md b/docs/security-model.md
index 9075ce99a..8f382ba6a 100644
--- a/docs/security-model.md
+++ b/docs/security-model.md
@@ -223,7 +223,7 @@ The primary threat: a malicious page crafts content that, when read by the agent
| **`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. |
| **Duplicate-submit guard** | A second text click on the same caption within 45 seconds on the same tab and URL is blocked when a model read the caption, in any language, as committing something (sending, saving, paying, publishing, creating, confirming and so on). A caption read as anything else, or that could not be read, stays repeatable; app-observed popups, links, fields and draft tools are always repeatable. Both builds. |
-| **Placeholder-value guard** | A form submission whose edited field still holds that field's own placeholder text, the page's example such as `[email protected]` in an email box, is not sent and gets no card unless the user gave that value as a whole answer on one of the current task's cards. The words of a request do not count, whether they give the value or refuse it ("do not use [email protected]"): a text match cannot tell which, in any language, so the model asks and the answer decides. An earlier, unrelated turn's answers do not count either. A field counts as edited when the submit probe sees it differ from its default or WebBrain's own write put the value into that same field in this task, with tracing on or off. The field is matched by its ref, which names one element in one document: the write's own ref, or for a write by selector or focus, the ref its target check resolved. A name or id is not enough, since another form, page or frame can reuse it. The receipts are kept in memory and rebuilt from the task's own fill calls and results, so a worker restart does not lose them. In Chrome, a submit control the page probe cannot reach (a closed shadow root) has its form's fields read through the debugger. This holds with confirmations off and in scheduled runs too. The probe checks every field of the form, not only the eight its summary shows, and never reports a password. The model is told to ask the user for the value. A script (`execute_js`) is not covered: what it fills is not known before it runs. A placeholder without a letter or shorter than three characters (a `1` in a quantity box) does not count, and grouped searches keep their approval. Both builds. |
+| **Placeholder-value guard** | A form submission whose edited field still holds that field's own placeholder text, the page's example such as `[email protected]` in an email box, is not sent and gets no card unless the user gave that value as a whole answer on one of the current task's cards. The words of a request do not count, whether they give the value or refuse it ("do not use [email protected]"): a text match cannot tell which, in any language, so the model asks and the answer decides. An earlier, unrelated turn's answers do not count either. A field counts as edited when the submit probe sees it differ from its default or WebBrain's own write put the value into that same field in this task, with tracing on or off. The field is matched by its ref, which names one element in one document: the write's own ref, or for a write by selector or focus, the ref its target check resolved. An append whose result does not report the field's whole value counts for whatever the field then holds. A name or id is not enough, since another form, page or frame can reuse it. The receipts are kept in memory and rebuilt from the task's own fill calls and results, so a worker restart does not lose them. In Chrome, a submit control the page probe cannot reach (a closed shadow root) has its form's fields read through the debugger. This holds with confirmations off and in scheduled runs too. The probe checks every field of the form, not only the eight its summary shows, and never reports a password. The model is told to ask the user for the value. A script (`execute_js`) is not covered: what it fills is not known before it runs. A placeholder without a letter or shorter than three characters (a `1` in a quantity box) does not count, and grouped searches keep their approval. Both builds. |
| **CLICK occlusion test** | Before clicking, the resolver calls `elementFromPoint()`. If another element is visually on top, the click is refused. |
| **Modal-scoped click** | When a dialog is open, text clicks are scoped to that subtree so the agent doesn't click a dimmed background element. |
| **Universal preamble** | Every system prompt includes guidance on cookie banners and paywalls — two common injection vectors that look like benign page content. |
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index d0a0eae41..156189e84 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -52588,22 +52588,27 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
|| !response || typeof response !== 'object' || response.success !== true) return null;
const meta = response.fieldMeta;
if (!meta || String(meta.type || '').toLowerCase() === 'password') return null;
+ const ref = [args?.ref_id, response.ref_id, targetRef].map(value => String(value || '')).find(value => /^ref_\d+$/.test(value)) || '';
const whole = text => String(text ?? '').replace(/\s+/g, ' ').trim();
const normalize = text => whole(text).toLowerCase();
const placeholder = normalize(meta.placeholder);
- // The typed text, whole, when the write replaced the value: set_field
+ if (!ref || !placeholder) return null;
+ // A write that replaced the value put the typed text there: set_field
// replaces it unless clear is false, the typing tools only with
- // clear:true. An append reads the field's result instead, which the
- // receipt reports shortened.
- const result = this._textMutationReplacesValue(toolName, args || {}) && typeof args?.text === 'string'
- ? args.text : response.value;
+ // clear:true. An append keeps what the field held before, so its result
+ // is read instead: the field's value as the result reports it, whole
+ // only when shorter than the 100 characters results are cut to. An
+ // append whose result is missing or may be cut short leaves the value
+ // unknown (null), and its receipt matches whatever the field then holds.
+ const replaced = this._textMutationReplacesValue(toolName, args || {});
+ const result = replaced && typeof args?.text === 'string' ? args.text : response.value;
+ if (!replaced && (typeof result !== 'string' || result.length >= 100)) return { value: null, ref };
if (typeof result !== 'string') return null;
const typed = whole(result);
- if (!placeholder || normalize(typed) !== placeholder) return null;
- const ref = [args?.ref_id, response.ref_id, targetRef].map(value => String(value || '')).find(value => /^ref_\d+$/.test(value)) || '';
+ if (normalize(typed) !== placeholder) return null;
// Kept as the probe returns a whole value: its first 4,000 characters,
// cut before the case is folded, as the probe cuts it.
- return ref ? { value: normalize(typed.slice(0, 4000)), ref } : null;
+ return { value: normalize(typed.slice(0, 4000)), ref };
}
// Keeps a placeholder write's receipt for the current task, scoped by the
@@ -52641,10 +52646,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
}
// Whether WebBrain's own write in this task put `value` into this probed
- // field, the one with the same ref.
+ // field, the one with the same ref, or appended to it with a result
+ // nobody read whole.
_placeholderWritten(tabId, field, value, writes = null) {
const ref = String(field?.ref || '');
- return !!ref && (writes || this._placeholderTaskWrites(tabId)).some(write => write.value === value && write.ref === ref);
+ return !!ref && (writes || this._placeholderTaskWrites(tabId))
+ .some(write => write.ref === ref && (write.value === null || write.value === value));
}
// Adds values to the tab's known credentials, keeping the most recent 64.
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 64dadc74e..73453194c 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -45791,22 +45791,27 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
|| !response || typeof response !== 'object' || response.success !== true) return null;
const meta = response.fieldMeta;
if (!meta || String(meta.type || '').toLowerCase() === 'password') return null;
+ const ref = [args?.ref_id, response.ref_id, targetRef].map(value => String(value || '')).find(value => /^ref_\d+$/.test(value)) || '';
const whole = text => String(text ?? '').replace(/\s+/g, ' ').trim();
const normalize = text => whole(text).toLowerCase();
const placeholder = normalize(meta.placeholder);
- // The typed text, whole, when the write replaced the value: set_field
+ if (!ref || !placeholder) return null;
+ // A write that replaced the value put the typed text there: set_field
// replaces it unless clear is false, the typing tools only with
- // clear:true. An append reads the field's result instead, which the
- // receipt reports shortened.
- const result = this._textMutationReplacesValue(toolName, args || {}) && typeof args?.text === 'string'
- ? args.text : response.value;
+ // clear:true. An append keeps what the field held before, so its result
+ // is read instead: the field's value as the result reports it, whole
+ // only when shorter than the 100 characters results are cut to. An
+ // append whose result is missing or may be cut short leaves the value
+ // unknown (null), and its receipt matches whatever the field then holds.
+ const replaced = this._textMutationReplacesValue(toolName, args || {});
+ const result = replaced && typeof args?.text === 'string' ? args.text : response.value;
+ if (!replaced && (typeof result !== 'string' || result.length >= 100)) return { value: null, ref };
if (typeof result !== 'string') return null;
const typed = whole(result);
- if (!placeholder || normalize(typed) !== placeholder) return null;
- const ref = [args?.ref_id, response.ref_id, targetRef].map(value => String(value || '')).find(value => /^ref_\d+$/.test(value)) || '';
+ if (normalize(typed) !== placeholder) return null;
// Kept as the probe returns a whole value: its first 4,000 characters,
// cut before the case is folded, as the probe cuts it.
- return ref ? { value: normalize(typed.slice(0, 4000)), ref } : null;
+ return { value: normalize(typed.slice(0, 4000)), ref };
}
// Keeps a placeholder write's receipt for the current task, scoped by the
@@ -45844,10 +45849,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
}
// Whether WebBrain's own write in this task put `value` into this probed
- // field, the one with the same ref.
+ // field, the one with the same ref, or appended to it with a result
+ // nobody read whole.
_placeholderWritten(tabId, field, value, writes = null) {
const ref = String(field?.ref || '');
- return !!ref && (writes || this._placeholderTaskWrites(tabId)).some(write => write.value === value && write.ref === ref);
+ return !!ref && (writes || this._placeholderTaskWrites(tabId))
+ .some(write => write.ref === ref && (write.value === null || write.value === value));
}
// Adds values to the tab's known credentials, keeping the most recent 64.
diff --git a/test/run.js b/test/run.js
index 1ce39861a..a74971545 100644
--- a/test/run.js
+++ b/test/run.js
@@ -82795,6 +82795,22 @@ test('a field holding its own placeholder text is not submitted', async () => {
{ success: true, value: '[email protected]', fieldMeta: appendMeta }, 'ref_404');
assert.equal(agent._placeholderWritten(tabId, appendField, '[email protected]'), true,
`${AgentClass.name}: an append that left the placeholder was missed`);
+ // An append whose result does not report the value, as type_ax's
+ // default append does not, or reports it possibly cut short, leaves
+ // the value unknown: the receipt counts for whatever the field holds.
+ agent._rememberPlaceholderWrite(tabId, 'type_ax', { ref_id: 'ref_606', text: 'example.com' },
+ { success: true, fieldMeta: appendMeta });
+ assert.equal(agent._placeholderWritten(tabId, { ref: 'ref_606' }, '[email protected]'), true,
+ `${AgentClass.name}: an append without a reported value was missed`);
+ agent._rememberPlaceholderWrite(tabId, 'type_text', { text: 'more' },
+ { success: true, value: 'x'.repeat(100), fieldMeta: appendMeta }, 'ref_707');
+ assert.equal(agent._placeholderWritten(tabId, { ref: 'ref_707' }, '[email protected]'), true,
+ `${AgentClass.name}: an append with a cut-short value was missed`);
+ // A replacing write that did not put the placeholder there has no receipt.
+ agent._rememberPlaceholderWrite(tabId, 'type_ax', { ref_id: 'ref_808', text: '[email protected]', clear: true },
+ { success: true, fieldMeta: appendMeta });
+ assert.equal(agent._placeholderWritten(tabId, { ref: 'ref_808' }, '[email protected]'), false,
+ `${AgentClass.name}: a write of another value counted`);
// A name and id are not the field: another field (another form, page
// or frame) can have the same ones. Only the ref counts, and a write
// without one is not kept.