Repository navigation
Studio sandbox: state that the python tool host allowlist is advisory at runtime - #13345
Open
danielhanchen wants to merge 1 commit into
Open
danielhanchen wants to merge 1 commit into
danielhanchen wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
1 similar comment
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danielhanchen
added a commit
that referenced
this pull request
Nov 5, 2026
…allowlist (#16674) Fixes #16625 (the host allowlist part) ## Problem Python tool code that reaches a host outside the built in allowlist (for example `requests.get("https://example.com/")`) is flagged as risky, so in **Ask for approval** and **Approve for me** the user gets an approval prompt. Clicking Approve did nothing: `_python_exec` re-ran the same static check and refused the call with `Blocked: host not in sandbox allowlist`. The only way to reach such a host was **Full access**, which also turns off every file restriction. That is exactly the "soften the network while keeping file access strict" gap from the issue. Measured on main (Linux, software safeguards): | Python code | asks first | approved | result | |---|---|---|---| | `urlopen("https://example.com/")` | yes | no | `Blocked: host not in sandbox allowlist` | | `urlopen("https://example.com/")` | yes | yes | `Blocked: host not in sandbox allowlist` | ## Fix `_check_code_safety` takes `host_approved`; when set it drops only the `untrusted_host_blocked` findings. `_python_exec` passes it for a call the user approved, the same way an approved `rm` is already let through in `_bash_exec`. - The allowlist is advisory today: every sandbox backend reports `unrestricted_network` (see #13345), so this changes no boundary. - Cloud-metadata hosts, uploads, non-literal destinations and every other static check stay blocked, approved or not. - File isolation is unchanged: the call still runs in the OS sandbox unless it names host paths, which was already the rule for approved calls. - API-key requests keep the allowlist even after an approval, matching #14345 / #14422. - Run automatically and unapproved calls behave exactly as before. No UI change. - A remembered "Always allow" for Python in a chat counts as an approval here, the same way it already does for host file access. After the fix: | Python code | approved | result | |---|---|---| | `urlopen("https://example.com/")` | no | `Blocked: host not in sandbox allowlist` (unchanged) | | `urlopen("https://example.com/")` | yes | `200` | | `urlopen("http://169.254.169.254/...")` | yes | `Blocked: cloud-metadata host` (unchanged) | | `urlopen("https://pypi.org/simple/")` | either | `200` (unchanged) | ## Tests `tests/test_sandbox_tools.py::TestApprovedHostLiftsOnlyTheAllowlist` (5 cases) fails on main and passes here: the approved host goes through, metadata / upload / non-literal destinations stay blocked, and an API-key caller is still refused. Base vs head over the 11 test files that touch the changed code (`test_sandbox_tools`, `test_tool_sandbox_*`, `test_api_key_tool_confirm`, `test_approved_rm`, `test_permission_mode*`, the tool loop tests, `test_windows_cmd_terminal_profile`): base 6 failed / 4336 passed, head 1 failed / 4341 passed. The 5 new tests are the only change; the remaining failure (`test_llama_cpp_tool_loop.py::test_web_search_keeps_to_the_requested_domains`) fails on main too. Extra folders and per-tool allow rules from the issue are separate features and are not part of this PR.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #11412
Summary
#11412 asks whether the python tool host allowlist is a security boundary or a hygiene default, and says that if it is a default, that should be written down next to the check. The product already answers it: every sandbox backend (software safeguards, bubblewrap, Seatbelt, MXC) reports
unrestricted_network, the execution record saysnetwork_policy: unrestricted, and the capability text reads "The network is not confined; a tool call can still reach the internet." Two comments intools.pystill read as though the allowlist is enforced:_sandbox_preexec: "Network policy is enforced by the AST host check and the bash blocklist."_check_signal_escape_patterns, which describes blocking metadata hosts and non-allowlisted hosts with no caveat.This rewrites both to say what holds: the network is unconfined at runtime, and the AST check and bash blocklist stop ordinary code, not code written to get around them. Comments only, no code change.
Measured on main at fcee648
Static check (
_check_code_safety):requests.get("http://example.com/")requests.get("http://169.254.169.254/latest/meta-data/")getattr(__import__("requests"), "get")("http://example.com/")importlib.import_module("requests").get(...),eval(...),exec(...), a callable in a dictEnd to end through
_python_exec(software safeguards on Linux):getattr(__import__("urllib.request").request, "urlopen")("http://example.com/")printedSTATUS 200.".".join(["169", "254", "169", "254"])port 80 throughgetattr(__import__("socket"), "create_connection")printedCONNECTED ('169.254.169.254', 80). No HTTP request was sent.Test plan
comment_tools.py check --changed --base origin/main: code unchanged (comments only).ruff check studio/backend/core/inference/tools.pyclean.