Skip to content

fix(sandbox): refuse a port that isn't a TCP port before it reaches a host command - #948

Closed
earakely-scale wants to merge 4 commits into
mainfrom
edgararakelyan/sandbox-port-integers
Closed

earakely-scale wants to merge 4 commits into
mainfrom
edgararakelyan/sandbox-port-integers

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

What this fixes

A deploy_sandbox step's port and exposed_ports, and a run_docker_container step's ports, came from the task document unchecked. They went into shell text unconverted and unquoted:

  • the docker run -p publish specs (port_bindings);
  • the local provider's relay line on the closed-network path;
  • the VM firewall rule (iptables … --dport).

Under the default local provider that shell runs on the developer's machine. So a task, including one from a Hub bundle, could set "port": "8080; <command>" and run commands on the host, or add docker run options such as -v /:/host. Those commands would inherit the CLI's environment, model key included.

The change

  • The shared sinks check the port. port_bindings and VmSandbox.setup_vm_for_gateway take only an integer from 1 to 65535 (checked_port) and raise ValueError for anything else: strings, floats, bools, out-of-range numbers. So no non-integer reaches a publish spec or firewall rule, from any caller.
  • The providers check first. SandboxProvider.create_container and reset_container check the port before they create a VM or run anything. So do the local provider's create_vm, create_container and reset_container: before drawing a host port, making a sandbox folder, building the relay or running docker.
  • The steps report it as a config problem. deploy_sandbox and run_docker_container report a non-integer port (port_problems). Running a bundle (agent-env run, the Hub-bundle path), agent-env task create and task validate, and task lint all refuse such a task before any step runs.
  • A stored task run directly is still stopped. agent-env task run and the hub worker skip preflight. There the provider check above stops the run before anything is made or run.

Compatibility

Every port stored in prod tasks is already an integer in range. I checked the synced TASKS collection:

  • about 403k deploy_sandbox ports and exposed_ports entries, 7681–9004;
  • about 4k run_docker_container ports, 8000–8080.

No task stores a port as a string, so nothing that runs today is refused.

Tests

  • local_sandbox_host_ports_test.py:
    • port_bindings refuses each non-port, as host or container port;
    • the local provider's create_vm, create_container (open and closed network) and reset_container (open and closed network) raise before any host port is drawn, sandbox folder made, relay built or command run;
    • setup_vm_for_gateway opens no firewall port when one entry isn't a port.
  • deploy_sandbox_port_test.py: port and exposed_ports config problems, and that real ports pass.
  • run_docker_container_test.py: the ports config problem.

🤖 Generated with Claude Code

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Adds port checks before Docker publish specs, local relay commands, and VM firewall rules are built.

  • Sandbox ports are checked before they reach Docker and firewall commands.
  • Task steps report invalid sandbox ports as configuration problems.

Reviews (9) · Last reviewed commit: "fix(sandbox): name the highest TCP port;..." · Reviewed by Greptile

… host command

A task's deploy_sandbox port and exposed_ports, and run_docker_container's ports, went into docker run publish specs,
the local relay line and the VM firewall rule unconverted and unquoted, so a string from a task document (a Hub bundle
among them) was parsed as shell on the developer's machine under the local provider.

port_bindings and setup_vm_for_gateway now take only an integer from 1 to 65535 (checked_port), the base and local
providers check a port before they draw a host port, make a sandbox folder, build the relay or run anything, and both
steps report a non-integer port as a config problem, so such a task is refused when it loads. Every port stored in
prod tasks today is an integer in range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale and others added 3 commits November 28, 2026 18:48
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…container builds one list of problems

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dbox gives a real host port

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale

Copy link
Copy Markdown
Collaborator Author

Closing unmerged: the finding is risk-accepted for now. Under the local provider a bundle's steps already run code on the developer's machine, so this check doesn't move that boundary, and the change spreads across five modules. The branch stays for if it's revisited.

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