Skip to content

fix(agent): listen on the guest's address, not every interface - #431

Merged
WaylandYang merged 1 commit into
devfrom
fix/agent-bind-address
Oct 31, 2026
Merged

WaylandYang merged 1 commit into
devfrom
fix/agent-bind-address

Conversation

@WaylandYang

Copy link
Copy Markdown
Contributor

The last open CodeQL alert on dev, py/bind-socket-all-network-interfaces in sandstorm-agent.py: a Firecracker guest's agent listened on 0.0.0.0:8888.

The host reaches it at the guest's address, so it now binds that, read from the kernel's ip= argument, and 127.0.0.1 when there is none. The address is not hard-coded here: firecracker.rs decides it, and a boot without a network has no ip=.

This is not a boundary. The agent runs commands without a credential, and code inside the sandbox can still reach it at 10.42.0.2:8888. Nothing outside the guest could reach it any other way before this either: the guest has lo and eth0, and the namespace's rules forward to the guest. This narrows what is exposed by loopback, and closes the alert.

bind_address is covered by new tests in rootfs-init/tests/test_agent_env.py.

Testing

On Firecracker on bare metal, with a template pulled through from-image, so it carries this agent:

  • /proc/net/tcp inside the guest shows the listener on 10.42.0.2 only.
  • exec works after a cold boot, after a branch, in a fork of that tag, and back from frozen and from on disk.

test_agent_env.py 23 of 23, plus test_agent_stream.py and test_agent_app.py pass on macOS. scripts/dev/e2b-sdk.py was not run: it does not use this agent's port. gVisor does not run this agent.

Existing Firecracker templates keep the agent they were built with until they are rebuilt.

🤖 Generated with Claude Code

The host reaches the agent at the address the guest was booted with, so it binds
that, read from the kernel's ip= argument, and loopback when there is none. Code
inside the sandbox can still reach it, so this narrows what is exposed and is not
a boundary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: WaylandYang <145302500+WaylandYang@users.noreply.github.com>
@WaylandYang
WaylandYang merged commit 3c3b245 into dev Oct 31, 2026
9 checks passed
@WaylandYang
WaylandYang deleted the fix/agent-bind-address branch October 31, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant