Skip to content

Studio sandbox: state that the python tool host allowlist is advisory at runtime - #13345

Open
danielhanchen wants to merge 1 commit into
mainfrom
studio-sandbox-network-advisory-doc
Open

danielhanchen wants to merge 1 commit into
mainfrom
studio-sandbox-network-advisory-doc

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

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 says network_policy: unrestricted, and the capability text reads "The network is not confined; a tool call can still reach the internet." Two comments in tools.py still read as though the allowlist is enforced:

  • _sandbox_preexec: "Network policy is enforced by the AST host check and the bash blocklist."
  • the static host policy block in _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):

Sandboxed code Verdict
requests.get("http://example.com/") blocked, host not in allowlist
requests.get("http://169.254.169.254/latest/meta-data/") blocked, cloud-metadata host
getattr(__import__("requests"), "get")("http://example.com/") allowed
importlib.import_module("requests").get(...), eval(...), exec(...), a callable in a dict allowed

End to end through _python_exec (software safeguards on Linux):

  • getattr(__import__("urllib.request").request, "urlopen")("http://example.com/") printed STATUS 200.
  • A TCP connect to ".".join(["169", "254", "169", "254"]) port 80 through getattr(__import__("socket"), "create_connection") printed CONNECTED ('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.py clean.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T01:06:47.170335Z e5301b5 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen danielhanchen self-assigned this Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: e5301b5768

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant