Skip to content

feat(sandbox): named egress rules for the broker - #212

Merged
quickbeard merged 1 commit into
mainfrom
feat/sandbox-egress-rules
Aug 13, 2026
Merged

quickbeard merged 1 commit into
mainfrom
feat/sandbox-egress-rules

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

Phase 4c, first deliverable — the original Phase 4 headline item, now layered on the working broker.

What

  • parseBrokerRules (in @codev/sandbox): validates an object of name → upstream URL into broker routes — lowercase/digit/dash names, llm reserved for the gateway route, http(s) upstreams only. Throws on anything malformed so a bad config fails the sandbox start with the parse message — fail-closed and loud, never a silently smaller allowlist.
  • Desktop: resolveSandboxEgress reads the optional sandbox-egress.json from the app's userData dir at every sandbox start and appends the rules to the gateway route. Example:
{ "npm": "https://registry.npmjs.org", "pypi": "http://mirror.corp/simple" }

Inside every sandbox each rule is reachable at http://127.0.0.1:8788/<name>/... on all three backends (same guest stub the LLM route uses). Upstream calls go through the same Electron net fetch — host proxy/PAC/trust roots apply. There is deliberately no general-proxy escape hatch.

Hand-editable file, no UI — matches how an admin would roll this out fleet-wide; a settings surface can come later.

Remaining 4c items and why they're not in this PR

  • Unprivileged guest user: needs a uid-mapping design, not just a setpriv line — VZ's virtio-fs performs guest-side permission checks against host file uids, so a guest server at uid 1000 cannot write a workspace owned by host uid 501 (root currently masks this). Plan: carry the host uid into boot.json, remap the codev user at init, then drop privileges — an image respin, to be bundled with the next image build. WSL has the same shape via drvfs automount options in wsl.conf (also image-coupled).
  • WSL egress firewall: Hyper-V firewall rules per distro need elevation and a Windows machine to verify; implementing blind risks breaking fleet egress. Needs a session with the Windows box.
  • Resource limits: per-sandbox cpus/memory is real only on vz (WSL's .wslconfig limits are VM-global); worth doing together with the add-dialog fields.

Tests

New parseBrokerRules suite (valid, empty, array, bad name, reserved llm, non-http, non-string); package 89 pass / 2 skip; desktop typecheck green. CHANGELOG entry added. Fork-only files.

🤖 Generated with Claude Code

parseBrokerRules turns an admin-editable object of name → upstream URL
into broker routes (/name on the guest stub), validating names, the
reserved llm prefix, and http(s) upstreams — a malformed file fails the
sandbox start with the parse message instead of silently granting less
than intended. The desktop reads userData/sandbox-egress.json at each
sandbox start and appends the rules to the gateway route; still an
allowlist of named upstreams, never a general proxy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@quickbeard
quickbeard merged commit 6c80c98 into main Aug 13, 2026
0 of 5 checks passed
@quickbeard
quickbeard deleted the feat/sandbox-egress-rules branch August 13, 2026 04:15
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