Lint / SEC: Add mitigation for slowloris DoS attack vector

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2022-09-06 00:35:40 +02:00
parent e259ca209c
commit 6210646351
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -32,6 +32,8 @@ const (
initialIRCRetryBackoff = 500 * time.Millisecond initialIRCRetryBackoff = 500 * time.Millisecond
ircRetryBackoffMultiplier = 1.5 ircRetryBackoffMultiplier = 1.5
maxIRCRetryBackoff = time.Minute maxIRCRetryBackoff = time.Minute
httpReadHeaderTimeout = 5 * time.Second
) )
var ( var (
@ -252,7 +254,12 @@ func main() {
log.WithError(err).Fatal("Unable to open http_listen port") log.WithError(err).Fatal("Unable to open http_listen port")
} }
go http.Serve(listener, router) server := &http.Server{
ReadHeaderTimeout: httpReadHeaderTimeout, // gosec: G114 - Mitigate "slowloris" DoS attack vector
Handler: router,
}
go server.Serve(listener)
log.WithField("address", listener.Addr().String()).Info("HTTP server started") log.WithField("address", listener.Addr().String()).Info("HTTP server started")
checkExternalHTTP() checkExternalHTTP()