mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-22 20:27:01 +08:00
caddyhttp: Reject absurd methods (#4538)
* caddyhttp: Reject absurdly long methods * Limit method to 32 chars and truncate * Just reject the request and debug-log it * Log remote address
This commit is contained in:
parent
94035c1797
commit
bf380d00ab
|
@ -150,6 +150,17 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
// reject very long methods; probably a mistake or an attack
|
||||
if len(r.Method) > 32 {
|
||||
if s.shouldLogRequest(r) {
|
||||
s.accessLogger.Debug("rejecting request with long method",
|
||||
zap.String("method_trunc", r.Method[:32]),
|
||||
zap.String("remote_addr", r.RemoteAddr))
|
||||
}
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
repl := caddy.NewReplacer()
|
||||
r = PrepareRequest(r, repl, w, s)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user