Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HSTS header also in case of a RequestRejectedException #16358

Open
askuri opened this issue Jan 2, 2025 · 0 comments
Open

Add HSTS header also in case of a RequestRejectedException #16358

askuri opened this issue Jan 2, 2025 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement

Comments

@askuri
Copy link

askuri commented Jan 2, 2025

Expected Behavior

By default, Spring sends an HSTS (Strict-TransportSecurity) header, though this can be configured. Requests that are rejected by the StrictHttpFirewall (with a RequestRejectedException) should result in a response with a HSTS header like for all other requests, given that the protocol is HTTPS and HSTS is enabled.

Current Behavior

Requests that are rejected by the StrictHttpFirewall currently do not receive a HSTS header while request that are not rejected, have the header in their response.

Context

The Web Application Scanner we use checks our application for presence of HSTS headers on any request it generates towards a live instance of our application. Some of our endpoints have path parameters (such as /api/v1/resource/:id/subresource), for which the scan creates a request (among others) /api/v1/resource//subresource - note the double slash because the ID is left out. Double slashes lead to a rejection of the request by the StrictHttpFirewall. That in turn results in a response without the HSTS header, which makes our scanner complain.

As a workaround, we have added a Bean for a RequestRejectedHandler that adds the header to the response and then terminates it with status 400.

@askuri askuri added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant