Skip to content

WebFirewall falsifies method not allowed responses #17045

Closed
@reitzmichnicht

Description

@reitzmichnicht

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.

Metadata

Metadata

Assignees

Labels

status: invalidAn issue that we don't feel is validtype: bugA general bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions