summaryrefslogtreecommitdiff
path: root/api/server
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2022-09-22 12:13:28 +0200
committerSebastiaan van Stijn <github@gone.nl>2022-09-22 12:13:28 +0200
commit55fd77f7246a8113b81eb0de5644ce651db1ace0 (patch)
treeea02d33de013b3916a6de4dcb66815f652cc686b /api/server
parent08dccc2cb49796d5606a93f4cb24c9c88fb3b304 (diff)
downloaddocker-55fd77f7246a8113b81eb0de5644ce651db1ace0.tar.gz
set ReadHeaderTimeout to address G112: Potential Slowloris Attack (gosec)
After discussing in the maintainers meeting, we concluded that Slowloris attacks are not a real risk other than potentially having some additional goroutines lingering around, so setting a long timeout to satisfy the linter, and to at least have "some" timeout. libnetwork/diagnostic/server.go:96:10: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec) srv := &http.Server{ Addr: net.JoinHostPort(ip, strconv.Itoa(port)), Handler: s, } api/server/server.go:60:10: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec) srv: &http.Server{ Addr: addr, }, daemon/metrics_unix.go:34:13: G114: Use of net/http serve function that has no support for setting timeouts (gosec) if err := http.Serve(l, mux); err != nil && !strings.Contains(err.Error(), "use of closed network connection") { ^ cmd/dockerd/metrics.go:27:13: G114: Use of net/http serve function that has no support for setting timeouts (gosec) if err := http.Serve(l, mux); err != nil && !strings.Contains(err.Error(), "use of closed network connection") { ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'api/server')
-rw-r--r--api/server/server.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/api/server/server.go b/api/server/server.go
index 5f01a8b1dd..e8714eb060 100644
--- a/api/server/server.go
+++ b/api/server/server.go
@@ -6,6 +6,7 @@ import (
"net"
"net/http"
"strings"
+ "time"
"github.com/docker/docker/api/server/httpstatus"
"github.com/docker/docker/api/server/httputils"
@@ -58,7 +59,8 @@ func (s *Server) Accept(addr string, listeners ...net.Listener) {
for _, listener := range listeners {
httpServer := &HTTPServer{
srv: &http.Server{
- Addr: addr,
+ Addr: addr,
+ ReadHeaderTimeout: 5 * time.Minute, // "G112: Potential Slowloris Attack (gosec)"; not a real concern for our use, so setting a long timeout.
},
l: listener,
}