Explicitly hardcode MaxHeaderBytes as 1k, to prevent slowloris attack

This commit is contained in:
eleksir
2026-04-04 16:08:57 +03:00
parent 729b147b90
commit ae321a216d
2 changed files with 5 additions and 0 deletions

View File

@@ -11,6 +11,9 @@ const (
// copyBufferSize is the buffer size used for streaming file contents.
copyBufferSize = 32 * 1024
// maxHeaderBytes is the maximum size of request headers (1KB).
maxHeaderBytes = 1024
// portMin is the minimum valid port number.
portMin = 1

View File

@@ -184,6 +184,7 @@ func NewServer(configPath string) (*ServerWrapper, error) {
Handler: withServerHeader(mux),
ReadHeaderTimeout: readHeaderTimeout,
WriteTimeout: time.Duration(C.BackupTimeout) * time.Minute,
MaxHeaderBytes: maxHeaderBytes,
ErrorLog: log.DebugLogger(),
},
}, nil
@@ -195,6 +196,7 @@ func NewServer(configPath string) (*ServerWrapper, error) {
Handler: withServerHeader(mux),
ReadHeaderTimeout: readHeaderTimeout,
WriteTimeout: time.Duration(C.BackupTimeout) * time.Minute,
MaxHeaderBytes: maxHeaderBytes,
TLSConfig: &tls.Config{
MinVersion: tls.VersionTLS13,
},