Skip to content

Conversation

@1seal
Copy link

@1seal 1seal commented Jan 26, 2026

Rationale

The metrics HTTP listener currently uses http.DefaultServeMux (via http.Handle/http.HandleFunc).
If net/http/pprof is imported elsewhere in the binary (e.g., for debugging), its handlers are
registered on the default mux and become reachable on the metrics endpoint.

While the metrics listener defaults to localhost, deployments may expose it for scraping
(Prometheus / managed monitoring). Using a dedicated mux makes the contract explicit and prevents
unintended handler exposure.

Testing

Added TestHTTPServerDoesNotExposeDefaultServeMux which:

  • Imports net/http/pprof (registers on default mux).
  • Starts serverutil.Main with an HTTP endpoint.
  • Verifies /metrics returns 200.
  • Verifies /debug/pprof/ returns 404.

@1seal 1seal requested a review from a team as a code owner January 26, 2026 16:59
@1seal 1seal requested a review from phbnf January 26, 2026 16:59
@google-cla
Copy link

google-cla bot commented Jan 26, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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