Skip to content

Commit

Permalink
fix(security): Add ReadHeaderTimeout to pprof server to mitigate G112
Browse files Browse the repository at this point in the history
Signed-off-by: grzesuav <grzesuav@gmail.com>
  • Loading branch information
grzesuav committed Jul 21, 2022
1 parent aaedd7e commit a11059f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/profile/pprof_profiler.go
Expand Up @@ -7,6 +7,7 @@ import (
_ "net/http/pprof"
"os"
"os/signal"
"time"
)

func EnablePprof(address string) <-chan struct{} {
Expand All @@ -32,7 +33,11 @@ func EnablePprof(address string) <-chan struct{} {
logging.Logger.V(4).Info("enabling pprof", "address", address)
pprofMux := http.DefaultServeMux
http.DefaultServeMux = http.NewServeMux()
server := &http.Server{Addr: address, Handler: pprofMux}
server := &http.Server{
Addr: address,
Handler: pprofMux,
ReadHeaderTimeout: 30 * time.Second,
}
pprofStopChan := make(chan struct{})

go func() {
Expand Down

0 comments on commit a11059f

Please sign in to comment.