Skip to content

fix(server): guard the page's origin against other sites - #70

Merged
enricobuehler merged 1 commit into
mainfrom
fix/server-origin-gates
Nov 5, 2026
Merged

enricobuehler merged 1 commit into
mainfrom
fix/server-origin-gates

Conversation

@enricobuehler

Copy link
Copy Markdown
Member

The page server held no line around its own origin. This is the first of two pull requests that harden it for people who expose it (design: planning design/web-client-exposure.md); it stands alone and closes the two holes that also reach a server nobody exposed.

  • Names. A request must name an IP address, a name no public DNS holds (localhost, one label, .local, .home.arpa, .internal) or one in TLS_NAMES, or it gets 421. A site that rebinds its own name to the server's address is no longer same-origin with it. With an operator certificate and no TLS_NAMES there is no check: the browser has already refused other names.
  • Same-origin. /h/, /a/, /w/, /wa/, /wake/ and /config.json refuse a request another site made (Sec-Fetch-Site, Origin). One check where the bridge and wake had two.
  • Relay headers are an allowlist both ways. Going up: authorization, content-type, accept, if-none-match, content-length, the set the host's own tunnel passes. Coming back: what describes the body and its caching. A host can no longer set CORS, a cookie, Clear-Site-Data, a credential prompt or a redirect target on the page's origin.
  • Page headers. A CSP (own scripts and wasm, never framed), nosniff, no-referrer, COOP. No HSTS from the server: it binds a name, not a port, and would break other plain-HTTP services on a shared hostname.

Breaking

A page opened at a domain behind a reverse proxy or tunnel needs that domain in TLS_NAMES, and the proxy must pass Host through unchanged. The 421 names the variable; compose.proxy.yaml and compose.tailscale.yaml carry the line.

Checked

  • server/: fmt, clippy -D warnings, 26 tests.
  • The built page loads under the CSP in Chromium and WebKit, at / and /?ui=console, with no violation; stand-in probes for the worklet, the bridge socket, WebTransport and blob, data and https images raise none, and an injected script is blocked.

Not checked

Firefox, and every streaming path under the CSP (real worklets, a plane session, art and avatars). Owed on glass before a release.

The server held no line around its origin. A site that rebinds its name
to the server's address was same-origin with it, and any other site
could call /h/, /a/ and /config.json, read host answers through the
relay, and reach into the LAN through a server nobody exposed.

A request now names an address, a local name or one in TLS_NAMES, or
gets 421; only an operator certificate with no names skips that. Every
route but the static files refuses another site's request, with one
check where the bridge and wake had two. The relay passes an allowlist
of headers each way, so a visitor cannot vouch for itself to a host and
a host cannot set cookies, prompts, CORS or storage wipes on the page's
origin. The page carries a CSP, nosniff, no-referrer and COOP.

BREAKING CHANGE: a page opened at a domain, behind a proxy or tunnel,
needs that domain in TLS_NAMES, and the proxy must pass Host through.
@enricobuehler
enricobuehler merged commit 0c98fe5 into main Nov 5, 2026
7 checks passed
@enricobuehler
enricobuehler deleted the fix/server-origin-gates branch November 5, 2026 22:09
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