From 9f6c00cd4313a63ef1fcf1d4e97a67be926a75f4 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 11:56:05 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[HIGH]=20Fi?= =?UTF-8?q?x=20pprof=20exposure=20on=20default=20mux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: rschumann <360788+rschumann@users.noreply.github.com> --- .jules/sentinel.md | 4 ++++ internal/observability/profiler.go | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.jules/sentinel.md b/.jules/sentinel.md index 33f2d09a..8fe090dd 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -361,3 +361,7 @@ Remember: You're Sentinel, the guardian of switchAILocal. Security is not option **Vulnerability:** The CLI executor proxy lacked scheme validation for the user-controlled `remoteHost`, creating an SSRF vulnerability. The OAuth callback forwarder lacked prefix validation for `targetBase`, creating an open redirect vulnerability. **Learning:** Taint analysis revealed that input passed from management configurations or remote host specifications must be strictly validated before being used in HTTP requests or redirect targets to prevent protocol abuse and unauthorized redirects. **Prevention:** Always enforce strict protocol validation (e.g., scheme is 'http' or 'https') for outbound requests and validate redirect targets against allowed prefixes (e.g., 'http://localhost' or '/'). +## 2026-11-10 - [G108: pprof exposure] +**Vulnerability:** pprof server endpoint exposed via net/http/pprof globally on the default server mux. +**Learning:** Using `_ "net/http/pprof"` globally binds pprof routes to the default HTTP server which may expose sensitive application metrics and diagnostics on all ports listening on the default mux. +**Prevention:** Avoid the blank import for `net/http/pprof`. Instead, explicitly instantiate a new `http.ServeMux` and register the pprof routes, ensuring they are only exposed via explicit intent. diff --git a/internal/observability/profiler.go b/internal/observability/profiler.go index 7dfa2ede..0b3bd9e0 100644 --- a/internal/observability/profiler.go +++ b/internal/observability/profiler.go @@ -7,7 +7,7 @@ package observability import ( "fmt" "net/http" - _ "net/http/pprof" // Register pprof handlers on default mux + "net/http/pprof" log "github.com/sirupsen/logrus" ) @@ -30,8 +30,15 @@ func StartPprofServer(port int) { addr := fmt.Sprintf("127.0.0.1:%d", port) log.Infof("Starting pprof server on %s", addr) go func() { - // Uses the default mux which has pprof handlers registered via the blank import above. - if err := http.ListenAndServe(addr, nil); err != nil && err != http.ErrServerClosed { + // Use a dedicated mux for pprof to prevent exposing diagnostic endpoints globally on the default mux. + mux := http.NewServeMux() + mux.HandleFunc("/debug/pprof/", pprof.Index) + mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) + mux.HandleFunc("/debug/pprof/profile", pprof.Profile) + mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) + mux.HandleFunc("/debug/pprof/trace", pprof.Trace) + + if err := http.ListenAndServe(addr, mux); err != nil && err != http.ErrServerClosed { log.Errorf("pprof server failed: %v", err) } }()