Repository navigation
Conversation
browser_exec runs the model's code as Python on this host (the harness exec()s it) whatever browser it drives, but no approval layer saw it, so a messaging or API turn could run subprocesses with no prompt in any approval mode. It now goes through execute_code's one-shot whole-script gate, with its own key and wording, before anything launches. No container fast path: the code never runs in the terminal backend. Cron, -q and unattended platforms are not asked, so documented scheduled browser runs keep working under the default deny modes. Fixes #157913
…elpers, refuse before asking Round-1 review: the approval also covers the agent_helpers.py the harness imports before the code (an agent could otherwise hide code there behind a harmless-looking script); presence decides who is asked, so an api_server turn with an approval client is asked like execute_code; a denial carries user_summary; checks that would fail anyway (bad session name, missing harness) run before the prompt, in one helper that keeps browser_exec under the complexity cap.
…use a stranded API child (#157913) - The approval now lists the workspace .env the harness loads into its environment, not only agent_helpers.py. - Helpers are decoded the way Python decodes source: a coding cookie (utf-7) could make a shown comment line run as code. - Workspace files are read without blocking (a FIFO hung the agent), must be regular files under 256 KB, and are read only when someone will be asked; a file that cannot be shown in full refuses the call, never a truncated listing. - An async delegate_task child of an api_server session whose turn ended ran unasked: _presence() reads the missing notifier as nobody to ask. It is refused like a messaging session's stranded child.
… a client (#157913) The stranded-child refusal also caught children of sessions nobody could ever answer (a plain chat completion, a webhook turn whose TurnRunner notifier nobody can answer), which ran unasked before. A lease now records whether its dispatching turn had a notifier, and only an api_server session's child is refused. A directory named agent_helpers.py or .env raised (and leaked its fd) instead of refusing; the read now fstat()s first and always closes. The .env listing is split like the harness splits it (str.splitlines), so a \x1c line break shows as one.
|
@greptileai review |
૮ >ﻌ< ა ci reviewran on 2b9e6cb — test(browser): pin .env masking at the smart approver's inpu ℹ️ InfoCI caches · View report · View job27 / 27 cache hits (0 misses) per-job cache resultshits
missesnone Compressed archive bytes. Not-restored bytes use the main-size reference; missing sizes remain unknown. debug infoCI timingsCI timings · View report · View jobWall time 6m15s vs 6m23s (-2.1%). 6 job(s) slower, 7 faster,
|
[Medium impact] The change affects host-side Python runs through the browser tool. The PR should not merge until the harness is bound to the workspace contents that were approved. Findings
Fix with agent prompt### Issue 1
tools/browser_use_cli.py:undefined-797
The approval is not tied to the workspace files that actually run. `_workspace_listing` reads and closes them before the approval wait, but the harness later loads the same writable paths. Concurrent calls share the task’s workspace, so a `write_file` call can create or replace `agent_helpers.py` while the browser prompt is open. Approving the earlier listing then runs unseen host Python.
Preserve the approved file contents for the harness to load, including the absence of files, rather than approving text and later reopening mutable paths.
**How this was verified:** Concurrent workers receive the same task ID, the approval retains only a listing string, and the launch passes the workspace path without binding it to the approved contents.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
|
| "dashes, or underscores (e.g. 'r7k2').") | ||
| from tools.approval import check_browser_exec_guard | ||
| try: | ||
| guard = check_browser_exec_guard(lambda: code + _workspace_listing(task_id)) |
There was a problem hiding this comment.
The approval is not tied to the workspace files that actually run. _workspace_listing reads and closes them before the approval wait, but the harness later loads the same writable paths. Concurrent calls share the task’s workspace, so a write_file call can create or replace agent_helpers.py while the browser prompt is open. Approving the earlier listing then runs unseen host Python.
Preserve the approved file contents for the harness to load, including the absence of files, rather than approving text and later reopening mutable paths.
How this was verified: Concurrent workers receive the same task ID, the approval retains only a listing string, and the launch passes the workspace path without binding it to the approved contents.
Knowledge Base Used: Agent tools and guardrails
Prompt To Fix With AI
This is a comment left during a code review.
Path: tools/browser_use_cli.py
Line: 797
Comment:
**Approved helpers can change**
The approval is not tied to the workspace files that actually run. `_workspace_listing` reads and closes them before the approval wait, but the harness later loads the same writable paths. Concurrent calls share the task’s workspace, so a `write_file` call can create or replace `agent_helpers.py` while the browser prompt is open. Approving the earlier listing then runs unseen host Python.
Preserve the approved file contents for the harness to load, including the absence of files, rather than approving text and later reopening mutable paths.
**How this was verified:** Concurrent workers receive the same task ID, the approval retains only a listing string, and the launch passes the workspace path without binding it to the approved contents.
**Knowledge Base Used:** [Agent tools and guardrails](https://app.greptile.com/-/switch-tenant?tenant=nous-research&next=%2Fcustom-context%2Fknowledge-base%2Fnousresearch%2Fhermes-agent%2F-%2Fdocs%2Fagent-tools-and-guardrails.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.…e workspace changed during the wait (#157913) The listing goes to the smart approver's model and onto a chat card, and a workspace .env's values were never shown to either: secret values are masked with the shared redactor (names and other values stay visible). Another call can rewrite agent_helpers.py or .env while the prompt waits, so the files are read again after approval and the call is refused when they differ from what was shown.
browser_execruns itscodewith Python'sexec()inside the harness process on this host, whichever browser it drives: local, a CDP endpoint, or a cloud browser. Until now it never went through the approval gate, so it was an unapproved way to run host code next toexecute_code.It now gets the same one-shot whole-script approval as
execute_code, under its own approval key:execute_code. Messaging gateways, plugin-injected turns, and API turns whose client can answer an approval are asked. The interactive CLI and a local viewer's own turn are not asked for each script.browser_exec, because the code never runs inside it.-q, webhooks, API turns with no approval client) still run without asking, whatevercron_mode/single_query_mode/unattended_modesay. Scheduled browser runs are a documented feature, and those modes default to deny.security.mdsays to remove thebrowsertoolset where that isn't wanted.agent_helpers.pyand the workspace.env), decoded the way Python and the harness read them. A file that can't be shown in full (a FIFO, a non-regular file, more than 256 KB, undecodable) refuses the call instead of being truncated.delegate_taskchild of an API session whose turn has ended is refused. The client it would have been asked through is gone.Streaming
/v1/chat/completionsclients that ignore theapproval.requestevent now wait out the approval timeout onbrowser_exec, as they already do for dangerous terminal commands. This is documented.Fixes #157913