summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/caddyhttp/server.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go
index e302c36..964b2a4 100644
--- a/modules/caddyhttp/server.go
+++ b/modules/caddyhttp/server.go
@@ -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)