Skip to content

Commit 9bbd7d7

Browse files
authored
Merge pull request from GHSA-cjr9-mr35-7xh6
pkg/cmd: disable cmdline profile
2 parents 7ecd240 + f2b1f9c commit 9bbd7d7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pkg/cmd/server/defaults.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,21 @@ func DefaultPreRunE(programName string) cobrautil.CobraRunFunc {
7373
// metrics and pprof endpoints.
7474
func MetricsHandler(telemetryRegistry *prometheus.Registry) http.Handler {
7575
mux := http.NewServeMux()
76+
7677
mux.Handle("/metrics", promhttp.Handler())
78+
if telemetryRegistry != nil {
79+
mux.Handle("/telemetry", promhttp.HandlerFor(telemetryRegistry, promhttp.HandlerOpts{}))
80+
}
81+
7782
mux.HandleFunc("/debug/pprof/", pprof.Index)
78-
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
7983
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
8084
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
8185
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
82-
if telemetryRegistry != nil {
83-
mux.Handle("/telemetry", promhttp.HandlerFor(telemetryRegistry, promhttp.HandlerOpts{}))
84-
}
86+
mux.HandleFunc("/debug/pprof/cmdline", func(w http.ResponseWriter, r *http.Request) {
87+
w.WriteHeader(http.StatusNotFound)
88+
fmt.Fprintf(w, "This profile type has been disabled to avoid leaking private command-line arguments")
89+
})
90+
8591
return mux
8692
}
8793

0 commit comments

Comments
 (0)