fix(controlplane): stop exposing pprof /debug endpoints on public listeners#3241
Merged
matiasinsaurralde merged 1 commit intoJun 25, 2026
Merged
Conversation
…teners The net/http/pprof blank import registered its /debug/pprof/* handlers on the process-wide http.DefaultServeMux, and go-kratos points every HTTP server's NotFoundHandler at that mux. As a result the pprof endpoints were reachable, unauthenticated, on the public API and metrics listeners regardless of the enable_profiler setting. Override NotFoundHandler/MethodNotAllowedHandler on every kratos HTTP server so unmatched routes no longer fall through to DefaultServeMux, and register the pprof handlers explicitly on the opt-in profiler server only. Assisted-by: Claude Code Signed-off-by: Jose I. Paris <jiparis@chainloop.dev> Chainloop-Trace-Sessions: e6906bba-e9a1-468f-8d04-e3fe7ae231df
There was a problem hiding this comment.
1 issue found across 7 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
javirln
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The controlplane exposed Go pprof
/debug/pprof/*endpoints, unauthenticated, on the public API and metrics HTTP listeners regardless of theenable_profilersetting.The cause is a combination of two behaviors:
net/http/pprofblank import registers its handlers on the process-widehttp.DefaultServeMuxat init time.NotFoundHandler(andMethodNotAllowedHandler) tohttp.DefaultServeMux, so any unmatched route falls through to those pprof handlers. The kratos auth/RBAC middleware does not run on that fall-through path.As a result
/debug/pprof/*was reachable on the public API port and the metrics port even withenable_profiler: false.Changes
hardenedRouteOptions()which overridesNotFoundHandler/MethodNotAllowedHandlerwith plain 404/405 responses so no kratos HTTP server falls through tohttp.DefaultServeMux. Applied to the main API server, the metrics server, and the profiler server.net/http/pprofblank imports from the controlplane entrypoint.With these changes pprof is unreachable when profiling is disabled, and when enabled it is served only on the dedicated profiler port.
AI assistance
This change was produced with assistance from Claude Code.