Repository navigation
fix(sandbox): give each WSL sandbox its own guest broker stub port - #228
Merged
Merged
Conversation
quickbeard
force-pushed
the
feat/wsl-egress-firewall
branch
3 times, most recently
from
August 13, 2026 15:42
c09d7aa to
b8f19db
Compare
quickbeard
force-pushed
the
fix/wsl-stub-port
branch
from
August 13, 2026 15:50
e717756 to
ee0bdad
Compare
Every backend parked the guest-loopback broker stub on 8788, which is fine for vz/bwrap (private guest loopbacks) but not for WSL: all WSL2 distros share the VM loopback, so a second concurrent sandbox's socat lost the bind silently and its model traffic landed on the first sandbox's broker, where the per-start auth secret rejected it. The WSL provider now reserves a per-sandbox stub port (against the Windows loopback, where WSL republishes guest binds) and resolveEgress receives the port so the gateway guest config points at it; vz and bwrap pass their fixed 8788. e2e-wsl gains --name for concurrent instances and per-instance broker markers so cross-sandbox leakage fails loudly. Verified live: two sandboxes ran concurrently, each probe returned its own broker's marker, and the first sandbox's broker still answered correctly after the second's full lifecycle. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Docker COPYs these files into Linux guest images verbatim, so a CRLF checkout (Windows autocrlf default) ships \r into the guest: the office layer died on `set: pipefail: invalid option name` when built from a Windows working tree, and codev-init would break the same way as the vz guest's PID 1. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A Windows image build hands describeAsset a backslash path, which
split("/") returns whole, so the manifest URL embedded the local build
path verbatim.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
Stacked on #227.
Problem
Every backend parked the guest-loopback broker stub on port 8788. That's fine for vz/bwrap — their guests have private loopbacks — but all WSL2 distributions share one VM loopback: with two Windows sandboxes running, the second socat lost the 8788 bind silently (backgrounded with
&), and the second sandbox's model traffic landed on the first sandbox's broker, where the per-start auth secret rejected it with 401s.Fix
reserveLoopbackPort()used for the server port — the Windows loopback is the right uniqueness domain because WSL republishes guest loopback binds there.resolveEgressnow receives{ guestBrokerPort }so the desktop's gateway guest config points the model provider at the actual stub. vz passes its image-baked 8788 (codev-init), bwrap itsGUEST_BROKER_PORT— no behavior change on those backends.e2e-wsl.tsgains--namefor concurrent instances; each instance's broker upstream returns a per-name marker, so cross-sandbox leakage shows up as a wrong marker instead of a false pass, and the guest probe discovers the stub port from the running socat instead of assuming 8788.Verification
Unit:
bun test src/wsl/(egress test now asserts the port handed toresolveEgressis the one socat listens on, and that it isn't the shared 8788); typecheck clean incodev-sandboxanddesktop.Live, two concurrent sandboxes on Windows 11 / WSL 2.7.11 (
--name alpha --hold+--name beta):Before this fix, beta's stub would have died at bind time and its probe would have hit alpha's broker.
🤖 Generated with Claude Code