Skip to content

fix(web): gate pprof behind the login - #245

Merged
pk910 merged 2 commits into
masterfrom
pk910/pprof-hardening
Oct 18, 2026
Merged

pk910 merged 2 commits into
masterfrom
pk910/pprof-hardening

Conversation

@pk910

@pk910 pk910 commented Oct 18, 2026

Copy link
Copy Markdown
Member

Problem

/debug/pprof was mounted fully unauthenticated whenever web.frontend.pprof was enabled. Anyone who could reach the web port could take a heap dump and read RPC credentials, private keys and similar secrets out of it.

Changes

  • /debug/pprof needs the login once an authProviderUrl is configured. The token is taken from the Authorization header (curl, go tool pprof) or from the assertoor_debug_token cookie (browser).
  • A browser without a valid token gets the SPA. Its gate page (web-ui/src/pages/DebugLogin.tsx, not in the nav) sets the cookie from the session (scoped to /debug/pprof, SameSite=Strict, Secure on https, at most 30 minutes or the token expiry) and reloads, or asks the user to log in. A refused token is remembered in session storage so the page cannot reload in a loop.
  • Tools without a token get a 401 with WWW-Authenticate: Bearer. With the frontend disabled, browsers get the 401 as well.
  • The bare /debug/pprof path redirects to the index at /debug/pprof/ instead of landing on the SPA route.
  • Every profile download (heap, goroutine, CPU profile, trace, ...) is logged with the requesting user, query and remote address. The index page is not.
  • Open mode (no auth provider) is unchanged.

Mirrors ethpandaops/buildoor@ff6081f.

Testing

  • Table-driven tests for the gate handler in pkg/web/pprof_test.go (open mode, bearer header, cookie, bad header not rescued by cookie, tool 401, browser gate, browser POST, no-gate 401), passing with -race.
  • go build, go vet, UI typecheck, eslint and a production webpack build pass.
  • Not exercised against a live authenticatoor.

pk910 added 2 commits October 18, 2026 22:41
/debug/pprof was mounted unauthenticated whenever web.frontend.pprof was
on: anyone could take a heap dump and read RPC credentials and keys out
of it.

- /debug/pprof needs the login once an auth provider is configured: a
  bearer header (curl, go tool pprof) or the assertoor_debug_token cookie
  (browser). A browser without it gets the SPA, whose gate page sets the
  cookie from the session (path-scoped, SameSite=Strict, <= 30 min) and
  reloads, or asks for a login. Tools without a token get a 401. Open
  mode is unchanged.
- The bare /debug/pprof path redirects to the index at /debug/pprof/
  instead of landing on the SPA route.
- Every profile download is logged with the requesting user; the index
  page is not.
@pk910
pk910 merged commit 87bbbd6 into master Oct 18, 2026
11 of 12 checks passed
@pk910
pk910 deleted the pk910/pprof-hardening branch October 18, 2026 21:00
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.

2 participants