Repository navigation
Conversation
The HTTP API had no Origin or Host check, and POST /api/repos/{name}/ops
decoded a JSON body regardless of Content-Type. Any web page the user
visited while gebed ran could therefore issue a cross-origin "simple
request" (text/plain, no preflight) that created or changed beads, and a
comment with @name is delivered into the live Claude Code session of that
name, so the page could inject a prompt into an agent with shell access.
- Guard wraps the handler with http.CrossOriginProtection (Go 1.25), which
rejects unsafe-method cross-origin requests; safe reads are unaffected
- plus a Host allowlist limited to loopback names and the -addr host, which
closes DNS rebinding (CrossOriginProtection does not inspect Host)
- test covers same-origin and non-browser requests passing, cross-origin
writes and rebinding hosts refused
Co-Authored-By: Claude Opus 4.8 <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.
Fixes #1.
The HTTP API performed no
OriginorHostcheck, andPOST /api/repos/{name}/opsdecoded a JSON body regardless ofContent-Type. Since gebed listens on loopback, any web page the user visited while gebed was running could issue a cross-origin "simple request" (text/plain, no preflight) that created or changed beads — and, viaaddCommentwith an@name, inject a message into a live Claude Code session (an agent with shell access). DNS rebinding additionally defeated the missingHostcheck and exposed reads (all beads, comments, and/api/sessions).Change
A single
Guardwrapper applied inmain.go, outermost check first:localhost,127.0.0.1,::1) and the host:port from-addr. A request with a rebindingHost(e.g.evil.example) is refused. This is what closes DNS rebinding;CrossOriginProtectiondoes not look atHost.http.CrossOriginProtection(Go 1.25) — rejects unsafe-method (POST/PUT/PATCH/DELETE) cross-origin requests viaSec-Fetch-Site/Origin. Safe methods pass, so the read API is unchanged; the write endpoints are covered.Non-browser clients (no
Origin, noSec-Fetch-Site) and same-origin requests still pass, sogebed mcpand the UI are unaffected.A wildcard bind (
0.0.0.0/::) adds no host to the allowlist, so only loopback names are accepted then; exposing gebed deliberately is out of scope for this change and would need its own authentication.Tests
internal/server/guard_test.gocovers: loopback GET, localhost GET, same-origin POST and non-browser POST reaching the handler; cross-origin POST (with and withoutSec-Fetch-Site), rebinding Host, and wrong port refused.go test ./...andgo vet ./...pass.Verified end-to-end
Against the built binary on the default port:
🤖 Generated with Claude Code