Repository navigation
fix(sandbox): drop browser-controlled headers when forwarding - #217
Merged
Merged
Conversation
The guest's model requests carry sec-fetch-mode (and friends), which a host forwarding through Chromium's network stack may not set: Electron's net.fetch rejected every such request with net::ERR_INVALID_ARGUMENT, so chat inside a sandbox failed on attempt after attempt while a plain curl through the same broker succeeded. Strip sec-fetch-*, sec-ch-*, and proxy-* alongside the existing hop-by-hop set. Header hygiene belongs in the broker rather than in one host's fetch wrapper, since any Chromium-backed forwarder hits this. Verified in-app: a sandbox session now answers "run pwd" with /home/codev — inside the guest, through the broker, no prompt. 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.
Reported from a real sandbox session: every message failed with
Bad Gateway: net::ERR_INVALID_ARGUMENT, retrying forever — the same symptom #215 fixed for one case, but still present for the agent's actual requests.Root cause
The guest's model requests carry
sec-fetch-mode(plusaccept-language,user-agent,sec-ch-*in principle). Chromium refuses to let a caller setSec-*headers, so Electron'snet.fetchrejects the whole request — the broker then returns 502 and the guest retries.This is why it escaped earlier verification: my probes used
curl, which sends none of those headers, so the same broker, same route, same body size all succeeded. Isolated with a temporary diagnostic on the broker's upstream call, which printed the real header set, and then reproduced deterministically with a single added header:Fix
forwardableRequestHeadersnow stripssec-fetch-*,sec-ch-*, andproxy-*alongside the existing hop-by-hop/host set. This belongs in the broker rather than in the desktop's fetch wrapper: any Chromium-backed forwarder hits the same wall, and the broker is where header hygiene already lives.Verification
In-app, after the fix: a sandbox session answered "run pwd" with
/home/codev— a guest path, so the agent genuinely ran inside the VM, reached the model through the broker, and executed its shell tool with no permission prompt (per #210). Package suites: sandbox 92 pass / 2 skip, desktop 76 pass.Note on the earlier "session binding" concern
While chasing this I reported that selecting a sandbox project and clicking New session ran the session on the Local Server. That conclusion was too strong: the sidebar's Recents list holds one draft row per server, all labelled "New session", and my scripted click was taking the first (local) row. Clicking the sandbox's own draft binds correctly — proven by the
/home/codevanswer above. What remains is a discoverability wrinkle rather than a wiring bug: two identically-labelled rows distinguished only by a small icon, where picking the wrong one silently runs on the real machine instead of the sandbox. Worth a UX pass, not a fix here.🤖 Generated with Claude Code