Skip to content

pages: an opt-in public listener that serves share links and nothing else - #1025

Merged
ZacxDev merged 5 commits into
mainfrom
feat/public-page-listener
Nov 23, 2026
Merged

ZacxDev merged 5 commits into
mainfrom
feat/public-page-listener

Conversation

@ZacxDev

@ZacxDev ZacxDev commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

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]:port opens a listener that serves only api.PagesPublicRoutes. It wraps the same Server.Handler the 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, /health and /metrics. A method mismatch or a non-canonical path also gets the 404, never a 405 or a redirect.
  • MUSTER_PAGES_PUBLIC_URL is the base every handed-on link is written under: the owner's Share, an agent's page_share_request and the page's screen, all through pageLinkURL. The owner's own view and every other link stay under MUSTER_PUBLIC_URL. A token works on both listeners.
  • The two variables are a pair. They need MUSTER_PAGES=1 and a port no other listener uses, and the URL must be an https origin with no path (http only to loopback). Otherwise the server refuses to boot.
  • Security: only api.PagesPublicRequestHeaders (plus the configured MUSTER_CLIENT_IP_HEADER) reach muster; every other header, cookies and credentials included, is removed. Set-Cookie is 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: docs/pages.md "Sharing with people outside your network", docs/configuration.md rows, docs/architecture.md listener 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 in tests/features_config_test.py.

The allowlist:

GET  /s/{token}             GET /s/{token}/content     GET /s/{token}/assets/{asset}
POST /s/{token}/submit      POST /s/{token}/upload
GET  /brand/logo.png        GET /brand/icon-192.png    GET /static/icons/icon-192.png

Tests

  • internal/api/pages_public_test.go:
    • The guard sends a matching request for every route RegisterRoutes records through the surface. The set that gets through must equal a hand-written ledger, so the test fails if the set grows or shrinks.
    • Only the shell's own icon passes under /static/.
    • Refused shapes: wrong method, //, .., an extra segment.
    • Credential and Set-Cookie stripping.
  • internal/api/pages_public_pg_test.go (real handler, real DB):
    • A link's shell, every same-origin file it references and the content open on the public listener, and a submit and an upload are recorded as the link's, even with the owner's cookie sent along.
    • A revoked or unknown token gets the share routes' 404.
    • The UI, the API, sign-in, MCP, health and the owner's own routes get 404 there with a valid owner cookie, and the private listener honours that same cookie (the control).
    • Links are written under the new URL, and under MUSTER_PUBLIC_URL without it.
  • cmd/muster-server/pages_public_test.go:
    • Boot refusals.
    • A real boot binds the port and serves only share links there.

Red/green. At origin/main the new tests do not compile (PagesPublicURL, envPagesPublicListen undefined). At the head they pass. Mutations, each red:

  • Adding "GET /pages" to the list fails the guard with its own message ("passes on these registered routes … Update pagesPublicLedger only if that is meant").
  • Dropping a route.
  • An identity surface.
  • No credential strip.
  • No Set-Cookie strip.
  • No canonical-path check.
  • A link base that ignores the new URL.

Local runs. I ran only the scoped tests, against a throwaway Postgres: cmd/muster-server (green), internal/pages (green) and an internal/api subset for pages, routes and listeners. In that subset TestTheAsksPageDrawsStalledAndWaitingRows failed once, and it passes when run alone; it is attention-episode state shared with another test, which this change does not touch. The whole internal/api package hit the 10-minute local timeout, so it is left to CI.

For review

  • It is a filter in front of the full handler, not a second registration site, so the route golden's single-chokepoint premise holds.
  • Both variables are required together. Alternatives would be to allow the URL alone (an edge routing /s/ straight to the main port) or to fall back to MUSTER_PUBLIC_URL.
  • The miss budget is checked before the lookup on the public listener only. Muster's own listeners keep the earlier contract that a throttled address still opens a live link (TestAThrottledAddressStillOpensALiveLink), because the two rules contradict each other.

Audit round 1 (8bea601)

  • Timeouts: api.NewPagesPublicServer sets 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.
  • Headers: an allowlist (one list) replaces the denylist. The client-address header is passed through and is believed only from trusted proxies.
  • Miss budget: the 429 comes before the store lookup on the public listener (counted through a fake store).
  • Logs: the panic line, the plugin-host refusal and three refusal lines now redact the path, like the access log. The access log already redacted /%73/<token>; that test is an invariant guard.
  • Set-Cookie: also stripped on Flush; Hijack is refused.
  • TestEveryProvisionerRouteIsDerivedNotDeclared failed 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

ZacxDev and others added 5 commits November 23, 2026 14:42
…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>
@ZacxDev
ZacxDev merged commit ccdde8c into main Nov 23, 2026
33 checks passed
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