Coraza has potential denial of service vulnerability
Description
Published to the GitHub Advisory Database
Jun 26, 2023
Reviewed
Jun 26, 2023
Published by the National Vulnerability Database
Aug 25, 2023
Last updated
Nov 10, 2023
Summary
Due to the misuse of
log.Fatalf
, the application using coraza crashed after receiving crafted requests from attackers.Details
https://github.com/corazawaf/coraza/blob/82157f85f24c6107667bf0f686b71a72aafdf8a5/internal/bodyprocessors/multipart.go#L26-L29
The bodyprocessors of multipart uses
log.Fatalf
to handle errors from themime.ParseMediaType
, butlog.Fatalf
callsos.Exit
directly after logging the error.https://github.com/golang/go/blob/a031f4ef83edc132d5f49382bfef491161de2476/src/log/log.go#L288-L291
This means that the application will immediately crash after receiving a malicious request that triggers an error in
mime.ParseMediaType
.PoC
The server can be demonstrated by https://github.com/corazawaf/coraza/tree/main/examples/http-server
After sending this request
The server will crash immediately. The
a=1; a=2
inContent-Type
makesmime: duplicate parameter name
error.Impact
I believe the vulnerability was introduced by the following commit: corazawaf/coraza@24af0c8.
Mitigation
The error from
mime.ParseMediaType
should return directly.References