WebFirewall falsifies method not allowed responses #17045
Labels
status: waiting-for-feedback
We need additional information before we can continue
type: bug
A general bug
Describe the bug
With Spring Boot 3.4.3 and Spring Security 6.4.5
Testing a not annotated HTTP method against a Spring Rest Controller is expected to return a 405 http status, but instead returns 400 in some cases.
To Reproduce
Setup a RestController endpoint in spring and include spring security with default firewall settings. Then issue a TRACE request against the endpoint. (Trace is by default blocked by the spring security firewall settings)
Expected behavior
The spring web stack internally correctly generates a 405 response in this case, but the HttpStatusRequestRejectedHandler does map all those errors to a 400 bad request. While it could be argued that this is security by hiding details, this is not the case as the Allow header from the 405 response is still part of the bad request response. Our quickfix is to patch the HttpStatusRequestRejectedHandler to not overwrite 405 responses, but I do not know if this is the desired solution.
Sample
Can be provided on request.
The text was updated successfully, but these errors were encountered: