Skip to content

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

Closed

Conversation

Kehrlann
Copy link
Contributor

@Kehrlann Kehrlann commented Sep 27, 2022

Make X-Xss-Protection header configurable in ServerHttpSecurity, re issue: gh-9631.
XSS Protection is configurable through ServerHttpSecurity#xssProtection#headerValue, with a HeaderValue 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 the enabled and block 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 Servlet
  • X-Xss-Protection: 1 ; mode=block in Reactive, with an extra space

Should we plan to align the Reactive header with the Servlet version?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 27, 2022
@Kehrlann Kehrlann force-pushed the 5.8/x-xss-protection branch 3 times, most recently from f423809 to 809dc96 Compare September 27, 2022 15:17
@Kehrlann Kehrlann force-pushed the 5.8/x-xss-protection branch from 809dc96 to f9c2ae2 Compare September 28, 2022 08:26
Copy link
Member

@sjohnr sjohnr left a 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.

@Kehrlann Kehrlann force-pushed the 5.8/x-xss-protection branch 2 times, most recently from 4da0bd8 to 57bc437 Compare September 29, 2022 12:17
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
@Kehrlann Kehrlann force-pushed the 5.8/x-xss-protection branch from 57bc437 to a5b23e6 Compare September 30, 2022 09:45
@sjohnr
Copy link
Member

sjohnr commented Sep 30, 2022

Merged via 9325001

@sjohnr sjohnr closed this Sep 30, 2022
@sjohnr sjohnr added in: web An issue in web modules (web, webmvc) type: enhancement A general enhancement type: breaks-passivity A change that breaks passivity with the previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 30, 2022
@sjohnr
Copy link
Member

sjohnr commented Sep 30, 2022

Note that we will want to update What's New with this change as a separate commit in 5.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) type: breaks-passivity A change that breaks passivity with the previous release type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants