Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
13 changes: 10 additions & 3 deletions internal/observability/profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
}
}()
Expand Down
Loading