Guard the Go server's request boundary: loopback Host, no Origin on /connect, shared token

The server answered any Host, so a DNS-rebinding page reached /connect (101)
and could drive terminals. Every route now refuses a non-loopback Host on a
loopback connection (421), /connect refuses any Origin (403), and a server
started with -token-file requires X-Pipelines-Token (401; /mcp and /healthz
exempt). The CLI/TUI send the token only to loopback URLs.
This commit is contained in:
2026-11-10 00:59:39 +00:00
parent a706739088
commit 84f7e33872
13 changed files with 585 additions and 5 deletions
+4 -1
View File
@@ -72,6 +72,9 @@ type Options struct {
// them so they never share the real server's tmux sessions.
TerminalTmuxSocket string
TerminalWithoutTmux bool
// AccessToken, when set, is required on every request (servertoken.Header)
// except the chat-tools MCP endpoint and /healthz (request_boundary.go).
AccessToken string
}
// Handler serves the persistent connection with default options. Canceling ctx
@@ -576,7 +579,7 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
// runner's collaborators are wired and before any request is served.
runs.reattachRuns()
}
return &runHandler{Handler: mux, runner: runs, hub: hub}
return &runHandler{Handler: guardRequests(mux, options.AccessToken), runner: runs, hub: hub}
}
type runHandler struct {