Why it matters
A client that sends its request one byte at a time holds a connection open indefinitely, and enough of them exhaust the server.
How to fix it
Construct an http.Server with ReadHeaderTimeout, ReadTimeout, WriteTimeout and IdleTimeout set, and call its ListenAndServe.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
package fixture
import "net/http"
func serve(handler http.Handler) error {
return http.ListenAndServe(":8080", handler)
}package fixture
import (
"net/http"
"time"
)
func serve(handler http.Handler) error {
server := &http.Server{
Addr: ":8080",
Handler: handler,
ReadHeaderTimeout: 5 * time.Second,
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
IdleTimeout: 2 * time.Minute,
}
return server.ListenAndServe()
}What TrustIvan reads
Runs on repository scans of Go source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- SSH host key not verified (Go)
GoSeverity: High
trustivan-go-ssh-host-key-not-verified - World writable file mode (Go)
GoSeverity: Medium
trustivan-go-world-writable-file-mode - TLS old minimum version (Go)
GoSeverity: Medium
trustivan-go-tls-old-minimum-version - Zip slip (Go)
GoSeverity: High
trustivan-go-zip-slip - Math rand secret (Go)
GoSeverity: Medium
trustivan-go-math-rand-secret - JWT parse unverified (Go)
GoSeverity: High
trustivan-go-jwt-parse-unverified
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation