Merge pull request #3951 from zishen/slowloris-attack
add http limit for the Slowloris attack
This commit is contained in:
commit
dc921e8a68
|
@ -43,6 +43,22 @@ const (
|
||||||
// References:
|
// References:
|
||||||
// - https://en.wikipedia.org/wiki/Slowloris_(computer_security)
|
// - https://en.wikipedia.org/wiki/Slowloris_(computer_security)
|
||||||
ReadHeaderTimeout = 32 * time.Second
|
ReadHeaderTimeout = 32 * time.Second
|
||||||
|
// WriteTimeout is the amount of time allowed to write the
|
||||||
|
// request data.
|
||||||
|
// HTTP timeouts are necessary to expire inactive connections
|
||||||
|
// and failing to do so might make the application vulnerable
|
||||||
|
// to attacks like slowloris which work by sending data very slow,
|
||||||
|
// which in case of no timeout will keep the connection active
|
||||||
|
// eventually leading to a denial-of-service (DoS) attack.
|
||||||
|
WriteTimeout = 5 * time.Minute
|
||||||
|
// ReadTimeout is the amount of time allowed to read
|
||||||
|
// response data.
|
||||||
|
// HTTP timeouts are necessary to expire inactive connections
|
||||||
|
// and failing to do so might make the application vulnerable
|
||||||
|
// to attacks like slowloris which work by sending data very slow,
|
||||||
|
// which in case of no timeout will keep the connection active
|
||||||
|
// eventually leading to a denial-of-service (DoS) attack.
|
||||||
|
ReadTimeout = 5 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDeschedulerCommand creates a *cobra.Command object with default parameters
|
// NewDeschedulerCommand creates a *cobra.Command object with default parameters
|
||||||
|
@ -174,6 +190,8 @@ func serveHealthzAndMetrics(address string) {
|
||||||
Addr: address,
|
Addr: address,
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
ReadHeaderTimeout: ReadHeaderTimeout,
|
ReadHeaderTimeout: ReadHeaderTimeout,
|
||||||
|
WriteTimeout: WriteTimeout,
|
||||||
|
ReadTimeout: ReadTimeout,
|
||||||
}
|
}
|
||||||
if err := httpServer.ListenAndServe(); err != nil {
|
if err := httpServer.ListenAndServe(); err != nil {
|
||||||
klog.Errorf("Failed to serve healthz and metrics: %v", err)
|
klog.Errorf("Failed to serve healthz and metrics: %v", err)
|
||||||
|
|
|
@ -40,6 +40,22 @@ const (
|
||||||
// References:
|
// References:
|
||||||
// - https://en.wikipedia.org/wiki/Slowloris_(computer_security)
|
// - https://en.wikipedia.org/wiki/Slowloris_(computer_security)
|
||||||
ReadHeaderTimeout = 32 * time.Second
|
ReadHeaderTimeout = 32 * time.Second
|
||||||
|
// WriteTimeout is the amount of time allowed to write the
|
||||||
|
// request data.
|
||||||
|
// HTTP timeouts are necessary to expire inactive connections
|
||||||
|
// and failing to do so might make the application vulnerable
|
||||||
|
// to attacks like slowloris which work by sending data very slow,
|
||||||
|
// which in case of no timeout will keep the connection active
|
||||||
|
// eventually leading to a denial-of-service (DoS) attack.
|
||||||
|
WriteTimeout = 5 * time.Minute
|
||||||
|
// ReadTimeout is the amount of time allowed to read
|
||||||
|
// response data.
|
||||||
|
// HTTP timeouts are necessary to expire inactive connections
|
||||||
|
// and failing to do so might make the application vulnerable
|
||||||
|
// to attacks like slowloris which work by sending data very slow,
|
||||||
|
// which in case of no timeout will keep the connection active
|
||||||
|
// eventually leading to a denial-of-service (DoS) attack.
|
||||||
|
ReadTimeout = 5 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewSchedulerEstimatorCommand creates a *cobra.Command object with default parameters
|
// NewSchedulerEstimatorCommand creates a *cobra.Command object with default parameters
|
||||||
|
@ -121,6 +137,8 @@ func serveHealthzAndMetrics(address string) {
|
||||||
Addr: address,
|
Addr: address,
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
ReadHeaderTimeout: ReadHeaderTimeout,
|
ReadHeaderTimeout: ReadHeaderTimeout,
|
||||||
|
WriteTimeout: WriteTimeout,
|
||||||
|
ReadTimeout: ReadTimeout,
|
||||||
}
|
}
|
||||||
if err := httpServer.ListenAndServe(); err != nil {
|
if err := httpServer.ListenAndServe(); err != nil {
|
||||||
klog.Errorf("Failed to serve healthz and metrics: %v", err)
|
klog.Errorf("Failed to serve healthz and metrics: %v", err)
|
||||||
|
|
|
@ -45,6 +45,22 @@ const (
|
||||||
// References:
|
// References:
|
||||||
// - https://en.wikipedia.org/wiki/Slowloris_(computer_security)
|
// - https://en.wikipedia.org/wiki/Slowloris_(computer_security)
|
||||||
ReadHeaderTimeout = 32 * time.Second
|
ReadHeaderTimeout = 32 * time.Second
|
||||||
|
// WriteTimeout is the amount of time allowed to write the
|
||||||
|
// request data.
|
||||||
|
// HTTP timeouts are necessary to expire inactive connections
|
||||||
|
// and failing to do so might make the application vulnerable
|
||||||
|
// to attacks like slowloris which work by sending data very slow,
|
||||||
|
// which in case of no timeout will keep the connection active
|
||||||
|
// eventually leading to a denial-of-service (DoS) attack.
|
||||||
|
WriteTimeout = 5 * time.Minute
|
||||||
|
// ReadTimeout is the amount of time allowed to read
|
||||||
|
// response data.
|
||||||
|
// HTTP timeouts are necessary to expire inactive connections
|
||||||
|
// and failing to do so might make the application vulnerable
|
||||||
|
// to attacks like slowloris which work by sending data very slow,
|
||||||
|
// which in case of no timeout will keep the connection active
|
||||||
|
// eventually leading to a denial-of-service (DoS) attack.
|
||||||
|
ReadTimeout = 5 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
// Option configures a framework.Registry.
|
// Option configures a framework.Registry.
|
||||||
|
@ -207,6 +223,8 @@ func serveHealthzAndMetrics(address string) {
|
||||||
Addr: address,
|
Addr: address,
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
ReadHeaderTimeout: ReadHeaderTimeout,
|
ReadHeaderTimeout: ReadHeaderTimeout,
|
||||||
|
WriteTimeout: WriteTimeout,
|
||||||
|
ReadTimeout: ReadTimeout,
|
||||||
}
|
}
|
||||||
if err := httpServer.ListenAndServe(); err != nil {
|
if err := httpServer.ListenAndServe(); err != nil {
|
||||||
klog.Errorf("Failed to serve healthz and metrics: %v", err)
|
klog.Errorf("Failed to serve healthz and metrics: %v", err)
|
||||||
|
|
|
@ -21,6 +21,22 @@ const (
|
||||||
// References:
|
// References:
|
||||||
// - https://en.wikipedia.org/wiki/Slowloris_(computer_security)
|
// - https://en.wikipedia.org/wiki/Slowloris_(computer_security)
|
||||||
ReadHeaderTimeout = 32 * time.Second
|
ReadHeaderTimeout = 32 * time.Second
|
||||||
|
// WriteTimeout is the amount of time allowed to write the
|
||||||
|
// request data.
|
||||||
|
// HTTP timeouts are necessary to expire inactive connections
|
||||||
|
// and failing to do so might make the application vulnerable
|
||||||
|
// to attacks like slowloris which work by sending data very slow,
|
||||||
|
// which in case of no timeout will keep the connection active
|
||||||
|
// eventually leading to a denial-of-service (DoS) attack.
|
||||||
|
WriteTimeout = 5 * time.Minute
|
||||||
|
// ReadTimeout is the amount of time allowed to read
|
||||||
|
// response data.
|
||||||
|
// HTTP timeouts are necessary to expire inactive connections
|
||||||
|
// and failing to do so might make the application vulnerable
|
||||||
|
// to attacks like slowloris which work by sending data very slow,
|
||||||
|
// which in case of no timeout will keep the connection active
|
||||||
|
// eventually leading to a denial-of-service (DoS) attack.
|
||||||
|
ReadTimeout = 5 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
// Options are options for pprof.
|
// Options are options for pprof.
|
||||||
|
@ -57,6 +73,8 @@ func ListenAndServe(opts Options) {
|
||||||
Addr: opts.ProfilingBindAddress,
|
Addr: opts.ProfilingBindAddress,
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
ReadHeaderTimeout: ReadHeaderTimeout,
|
ReadHeaderTimeout: ReadHeaderTimeout,
|
||||||
|
WriteTimeout: WriteTimeout,
|
||||||
|
ReadTimeout: ReadTimeout,
|
||||||
}
|
}
|
||||||
if err := httpServer.ListenAndServe(); err != nil {
|
if err := httpServer.ListenAndServe(); err != nil {
|
||||||
klog.Errorf("Failed to enable profiling: %v", err)
|
klog.Errorf("Failed to enable profiling: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue