Repository navigation
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
Closed
earakely-scale wants to merge 4 commits into
earakely-scale wants to merge 4 commits into
Conversation
… 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>
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>
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. |
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.
What this fixes
A
deploy_sandboxstep'sportandexposed_ports, and arun_docker_containerstep'sports, came from the task document unchecked. They went into shell text unconverted and unquoted:docker run -ppublish specs (port_bindings);iptables … --dport).Under the default
localprovider 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 adddocker runoptions such as-v /:/host. Those commands would inherit the CLI's environment, model key included.The change
port_bindingsandVmSandbox.setup_vm_for_gatewaytake only an integer from 1 to 65535 (checked_port) and raiseValueErrorfor anything else: strings, floats, bools, out-of-range numbers. So no non-integer reaches a publish spec or firewall rule, from any caller.SandboxProvider.create_containerandreset_containercheck the port before they create a VM or run anything. So do the local provider'screate_vm,create_containerandreset_container: before drawing a host port, making a sandbox folder, building the relay or running docker.deploy_sandboxandrun_docker_containerreport a non-integer port (port_problems). Running a bundle (agent-env run, the Hub-bundle path),agent-env task createandtask validate, and task lint all refuse such a task before any step runs.agent-env task runand 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
TASKScollection:deploy_sandboxports andexposed_portsentries, 7681–9004;run_docker_containerports, 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_bindingsrefuses each non-port, as host or container port;create_vm,create_container(open and closed network) andreset_container(open and closed network) raise before any host port is drawn, sandbox folder made, relay built or command run;setup_vm_for_gatewayopens no firewall port when one entry isn't a port.deploy_sandbox_port_test.py:portandexposed_portsconfig problems, and that real ports pass.run_docker_container_test.py: theportsconfig problem.🤖 Generated with Claude Code


Confidence 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.
Reviews (9) · Last reviewed commit: "fix(sandbox): name the highest TCP port;..." · Reviewed by Greptile