Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused bind-policy change, regression coverage, caller updates, and documentation are consistent, with no unresolved blocking findings.
No open issues 🎉
What changed in this PR
This PR makes host networking enforce the documented bind policy: nonzero ports require an explicit listen-port allowance, while port 0 remains permitted for host-assigned ports.
Changes:
- Reject unlisted fixed-port binds, including outbound source-port selection, and add regression coverage.
- Give affected Python tests explicit port permissions and enable all ports in CPython conformance recipes.
- Align CLI help, API documentation, integration documentation, and release notes with the policy.
| File | Description |
|---|---|
tests/python.rs |
Allow the fixed ports used by three server tests. |
src/net_policy.rs |
Clarify listen-port requirements and the ephemeral-port exception. |
src/hostnet.rs |
Enforce the bind gate and update unit tests. |
src/cli/mod.rs |
Clarify --port help text. |
justfile |
Pass --port all in both conformance recipes. |
integrations/smolagents/src/smolagents_hyperlight/executor.py |
Correct the executor’s networking docstring. |
integrations/smolagents/README.md |
Clarify outbound policy versus fixed-port permissions. |
docs/net.md |
Document bind rejection and source-port restrictions. |
CHANGELOG.md |
Record the fix and migration guidance for embedders. |
Review effort: Balanced
A guest given a network policy and no listen ports could bind any port: allow_bind let every bind through when there was no ListenPorts to ask, while --port's help, SandboxBuilder::listen_ports and net.md promise a guest that cannot. The gate refuses every bind but an ephemeral one now unless the port is listed, whether the guest means to listen on it or to connect from it, so a guest that serves on a port of its own needs --port, as documented, and still serves on one the host picks. The tests that bound a fixed port under a bare policy list it, and the CPython conformance recipes pass --port all: those tests bind as they please, and the test host is the boundary. Signed-off-by: danbugs <danilochiarlone@gmail.com>
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.
A guest given a network policy and no listen ports could bind any port.
Net::allow_bindlet every bind through when there was noListenPortsto ask, while--port's help ("Without this flag or a project's ports, bind() is rejected"), theListenPortsrustdoc and docs/net.md all promise a guest that cannot serve on a port of its own without one. Found while integrating hyperlight-unikraft guests with urunc (urunc-dev/urunc#1135):hluk run --netwith no--portserved happily. Targets v0.19.0.allow_bindrefuses every bind but an ephemeral one (port 0) unless the port is listed, whether the guest means to listen on it or to connect from it (source_address). A guest that serves on a port of its own needs--port, a manifest'sports, orlisten_ports, as documented, and can still serve on a port the host picks.AllowAll(tcp_bidir,http_server_client,threaded_select) list it, and the datagram rebind test lists the port it binds.tcp_echoandserver_shutdownbind port 0 and are unchanged.--port all:test_ftplibandtest_smtplibbind a source port before connecting and failed under the gate with the bare--netthey ran with, and the test host is the boundary there.--porthelp and theListenPortsrustdoc say the same; the smolagents README and executor docstring no longer tie "cannot listen" tonet_allowbeing empty (the executor never passes--port, so the guest cannot listen on a port of its own either way, andhluk_args=["--port", ...]opens one); CHANGELOG entry under Fixed.Behaviour change for embedders:
.network(policy)alone no longer lets the guest listen on a port of its own, or choose its source port; addlisten_ports. The integrations (smolagents executor, MCP server, ClickHouse driver) never bind and are unaffected. urunc (urunc-dev/urunc#1135) passes--port=allunless a deployment lists ports.Testing
Rebased onto main after #180, on Linux/KVM:
cargo test --lib, the wholecargo test --test pythonsuite andcargo test --test networkingpass;cargo fmt --checkandcargo clippy --all-targets --locked -- -D warningsare clean.just conformance python test_ftplib test_smtplibwith the branch's release build: both PASS (96 and 82 tests), where they failed under the old recipe. By hand,hluk run --initrd python-rootfs.cpio --net examples/python/http_server_client.pyfails to bind withPermission deniedand--net --port 9997serves.