net/http/pprof is incredibly useful during performance incidents, but it should never be open to the public internet. I register the pprof handlers on a separate mux and wrap them with Basic Auth (or, better, your real auth middleware). The important practice is separation: run pprof on an internal port, bind it to 127.0.0.1 in non-container environments, and gate it in Kubernetes via an internal Service. The code below shows a minimal wrapper that checks credentials, then forwards to the pprof handler. In production, I also add a timeout and a rate limit because profiles can be expensive. With this in place, you can grab CPU/heap profiles safely without turning diagnostics into a security incident.