-
Notifications
You must be signed in to change notification settings - Fork 6k
Make X-Xss-Protection header value configurable in ServerHttpSecurity #11908
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
Conversation
f423809
to
809dc96
Compare
...n/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurer.java
Show resolved
Hide resolved
809dc96
to
f9c2ae2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Kehrlann!
Should we plan to align the Reactive header with the Servlet version?
While I don't know the answer off-hand, shall we create a separate issue to track this? You can label it with for: team-attention
and ask about it at our next standup if needed.
You may know the process already, but in case it's new:
When merging this, you can merge into 5.8.x
, then immediately merge 5.8.x
into main
. Afterwards, you would want to update whats-new.adoc
in 5.8.x
and then git merge -s ours 5.8.x
into main
so that What's New is only updated in 5.8.
Let us know if you would like another review before merging. My review below is mostly cosmetic.
config/src/main/kotlin/org/springframework/security/config/web/server/ServerXssProtectionDsl.kt
Show resolved
Hide resolved
...ain/kotlin/org/springframework/security/config/web/servlet/headers/XssProtectionConfigDsl.kt
Show resolved
Hide resolved
...rc/main/java/org/springframework/security/web/header/writers/XXssProtectionHeaderWriter.java
Show resolved
Hide resolved
...va/org/springframework/security/web/server/header/XXssProtectionServerHttpHeadersWriter.java
Show resolved
Hide resolved
4da0bd8
to
57bc437
Compare
OWASP recommends using "X-Xss-Protection: 0". The default is currently "X-Xss-Protection: 1; mode=block". In 6.0, the default will be "0". This commits adds the ability to configure the xssProtection header value in ServerHttpSecurity. This commit deprecates the use of "enabled" and "block" booleans to configure XSS protection, as the state "!enabled + block" is invalid. This impacts HttpSecurity. Issue spring-projectsgh-9631
57bc437
to
a5b23e6
Compare
Merged via 9325001 |
Note that we will want to update What's New with this change as a separate commit in 5.8. |
Make
X-Xss-Protection
header configurable inServerHttpSecurity
, re issue: gh-9631.XSS Protection is configurable through
ServerHttpSecurity#xssProtection#headerValue
, with aHeaderValue
enum (DISABLED / ENABLED / ENABLED_MODE_BLOCK). This is because the state!enabled && block
is invalid, thus we restrict the API to the three valid states only.I ported the changes over to the Servlet stack, which has more configuration exposed in
HttpSecurity
, so the deprecations bubble up to that class too.The idea in 6.0 is to change the default to
HeaderValue = DISABLED
, and also remove theenabled
andblock
booleans.As part of this change, I noticed that in servlet the "mode=block" header values are different in the Servlet and Reactive stacks:
X-Xss-Protection: 1; mode=block
in ServletX-Xss-Protection: 1 ; mode=block
in Reactive, with an extra spaceShould we plan to align the Reactive header with the Servlet version?