Repository navigation
pages: an opt-in public listener that serves share links and nothing else - #1025
Merged
Merged
Conversation
…else MUSTER_PAGES_PUBLIC_LISTEN=[host]:port opens a listener of its own that passes on only api.PagesPublicRoutes (a link's shell, content, assets, submit and upload, plus the shell's logo and icon) to the same handler the main listener serves; every other request is one 404 there, the UI, /api/, sign-in, /plugin/, MCP, /health and /metrics included. Cookies and credential headers are taken off every request and Set-Cookie off every response, so an owner's session grants nothing on it. Rate limits and caps are the share routes' own. MUSTER_PAGES_PUBLIC_URL is the base every handed-on link is written under (pageLinkURL, the one place a link's address is made); the owner's own view and every other link stay under MUSTER_PUBLIC_URL. The two are a pair, need MUSTER_PAGES=1 and a port of their own, and the URL must be an https origin (http only to loopback), or the server refuses to boot. The allowlist guard walks every route RegisterRoutes records and demands the routes that get through equal a hand-written ledger (grow or shrink fails). Mutation-checked: adding "GET /pages" to the list fails it with its own message; so do dropping a route, an identity surface, no credential strip, no Set-Cookie strip, no canonical-path check, and a link base that ignores the new URL. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…udget, log redaction) From the security audit of the public pages listener: - Timeouts: api.NewPagesPublicServer gives the listener its own ReadTimeout (30s), IdleTimeout (1m) and a WriteTimeout derived from the upload's own budget (its read deadline + the store's 30s + 30s), so it never cuts off an upload its deadlines let through. A submit now sets a read deadline on every listener (15s) and answers 408 past it. - Headers: the credential denylist is replaced by ONE allowlist, api.PagesPublicRequestHeaders, plus the configured MUSTER_CLIENT_IP_HEADER, which clientaddr believes only from MUSTER_TRUSTED_PROXIES, so viewers behind a proxy keep their own budgets and cannot name their own address. - Miss budget: on the public listener an address past the failed-lookup limit is answered 429 before the store is asked. Muster's own listeners keep the earlier contract (a throttled address still opens a live link, TestAThrottledAddressStillOpensALiveLink). The comment says which is which. - Logs: the panic line, the plugin-host refusal and three refusal lines wrote r.URL.Path, so a share link's token reached the log there; they now write accessLogPath like the access log, which already redacted the decoded path (/%73/<token> included). - Set-Cookie is stripped on Flush as well as WriteHeader and Write, and a hijack is refused. - The matching mux holds a declared no-op handler instead of a local, which TestEveryProvisionerRouteIsDerivedNotDeclared refused. Each new test is red at f3f153a behind a shim with the old behaviour, except two invariant guards (the client-address test and the slow-upload test); every fix has a mutant its own test kills. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
refusePagesPublic (the public pages listener's one 404) sets Cache-Control: no-store, like refusePageLink, so no shared proxy in front of the internet-facing port keeps it. TestTheNoStoreLedger requires every function with a no-store literal to be named; it was not. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
TestFullyWiredServerSetsEveryExtensionField requires every Extensions field to be set in fullyWiredServer, so a registration branch on it would be visible to TestRegistrationIsIndependentOfDependencies. With it set (a synthetic https URL), that test still passes: the public listener's link base changes no route. Co-Authored-By: Claude Opus 5.5 (1M context) <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.
What
An opt-in second listener for shareable pages, so a client outside the owner's network can open a page link while the rest of muster stays private.
MUSTER_PAGES_PUBLIC_LISTEN=[host]:portopens a listener that serves onlyapi.PagesPublicRoutes. It wraps the sameServer.Handlerthe main listener serves (api.PagesPublicSurface), so the routes, rate limits, caps and headers are unchanged. Every other request gets one plain 404 there, including/,/api/*, sign-in,/plugin/*, MCP,/healthand/metrics. A method mismatch or a non-canonical path also gets the 404, never a 405 or a redirect.MUSTER_PAGES_PUBLIC_URLis the base every handed-on link is written under: the owner's Share, an agent'spage_share_requestand the page's screen, all throughpageLinkURL. The owner's own view and every other link stay underMUSTER_PUBLIC_URL. A token works on both listeners.MUSTER_PAGES=1and a port no other listener uses, and the URL must be anhttpsorigin with no path (httponly to loopback). Otherwise the server refuses to boot.api.PagesPublicRequestHeaders(plus the configuredMUSTER_CLIENT_IP_HEADER) reach muster; every other header, cookies and credentials included, is removed.Set-Cookieis removed on every path out (WriteHeader, Write, Flush); a hijack is refused. No CORS is added. The listener has its own read, write and idle timeouts.docs/pages.md"Sharing with people outside your network",docs/configuration.mdrows,docs/architecture.mdlistener table. The docs say plainly that the operator has to make the port reachable (reverse proxy, tunnel, Funnel). Compose and Helm do not set or publish the port. It is ledgered intests/features_config_test.py.The allowlist:
Tests
internal/api/pages_public_test.go:RegisterRoutesrecords through the surface. The set that gets through must equal a hand-written ledger, so the test fails if the set grows or shrinks./static/.//,.., an extra segment.Set-Cookiestripping.internal/api/pages_public_pg_test.go(real handler, real DB):MUSTER_PUBLIC_URLwithout it.cmd/muster-server/pages_public_test.go:Red/green. At
origin/mainthe new tests do not compile (PagesPublicURL,envPagesPublicListenundefined). At the head they pass. Mutations, each red:"GET /pages"to the list fails the guard with its own message ("passes on these registered routes … Update pagesPublicLedger only if that is meant").Set-Cookiestrip.Local runs. I ran only the scoped tests, against a throwaway Postgres:
cmd/muster-server(green),internal/pages(green) and aninternal/apisubset for pages, routes and listeners. In that subsetTestTheAsksPageDrawsStalledAndWaitingRowsfailed once, and it passes when run alone; it is attention-episode state shared with another test, which this change does not touch. The wholeinternal/apipackage hit the 10-minute local timeout, so it is left to CI.For review
/s/straight to the main port) or to fall back toMUSTER_PUBLIC_URL.TestAThrottledAddressStillOpensALiveLink), because the two rules contradict each other.Audit round 1 (8bea601)
api.NewPagesPublicServersets ReadTimeout 30s, IdleTimeout 1m and a WriteTimeout derived from the upload's own budget (2m). A submit has a 15s read deadline on every listener and answers 408 past it./%73/<token>; that test is an invariant guard.TestEveryProvisionerRouteIsDerivedNotDeclaredfailed on the first commit because the matching mux held a local handler. It now holds a declared no-op.The new tests are red at f3f153a behind a shim with the old behaviour, except two invariant guards (client address behind a proxy, slow upload). Each fix has a mutant that its own test kills.
🤖 Generated with Claude Code