ADR-0037: Pprof Explicit Handler + Rate Limit + Audit Log
Status: Accepted
Date: 2026-06-12
Author: @johalputt
Context
Go's net/http/pprof package registers handlers on http.DefaultServeMux when imported. Accidentally importing it in production exposes CPU profiles, heap dumps, and goroutine traces — sensitive operational data — to anyone who can reach the server. Even when intentionally enabled, pprof access should be logged and rate-limited.
Decision
- The
net/http/pprofpackage is not imported via blank import. Pprof handlers are registered explicitly on a dedicated sub-router (/debug/pprof/). - Access to
/debug/pprof/*requires theAuthorization: Bearer <VAYU_API_KEY>header — the same admin API key. - Pprof endpoint access is rate-limited to 5 requests per minute per IP using a token bucket.
- Every pprof access (successful or rejected) is written to the
audit_logtable: timestamp, IP, path, status, admin key hash (not the key itself). - The
allowPprofboolean in config controls whether pprof is registered at all. Default:falsein production,truein development.
Rationale
CPU profiles reveal algorithmic secrets. Heap dumps can contain secrets in memory. Goroutine traces expose internal state. Explicit registration (vs. blank import) prevents accidental enablement. Audit logging ensures any pprof access is traceable.
Consequences
- Positive: No accidental pprof exposure in production.
- Positive: All pprof access is auditable.
- Positive: Rate limiting prevents pprof from being used as a DoS vector.
- Negative: Developers must explicitly enable pprof in dev environments.