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

Referrer Header is set in Reactive Web Applications by default, although doc says it is not. #13561

Closed
stefanocke opened this issue Jul 18, 2023 · 2 comments
Assignees
Labels
in: config An issue in spring-security-config type: bug A general bug
Milestone

Comments

@stefanocke
Copy link

stefanocke commented Jul 18, 2023

Describe the bug

https://docs.spring.io/spring-security/reference/reactive/exploits/headers.html#webflux-headers-referrer says:

"By default, Spring Security does not add Referrer Policy headers."

But in fact, it does for reactive applications. And the default value is "no-referrer"
Note, that this is not the case for servlet stack.

To Reproduce

  1. Create a Spring Boot App with webflux and security (as below)
  2. Start it and open it in a browser (it will show login page)
  3. In the network console of the browser, it shows "Referrer-Policy: no-referrer" in the HTTP repsonse hhaders.

Expected behavior
The behavior for reactive stack should be consistent with the documentation.
Preferrably, it should also be consistent with the behavior for servlet stack.

Sample
https://start.spring.io/#!type=maven-project&language=java&platformVersion=3.1.1&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=referrerdemo&name=referrerdemo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.referrerdemo&dependencies=webflux,security

@stefanocke stefanocke added status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Jul 18, 2023
@stefanocke stefanocke changed the title Referrer Header is set in Reactive Web Applications by default, altough doc says it is not. Referrer Header is set in Reactive Web Applications by default, although doc says it is not. Jul 18, 2023
@marcusdacoregio marcusdacoregio self-assigned this Jul 19, 2023
@marcusdacoregio marcusdacoregio added in: config An issue in spring-security-config and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 19, 2023
@marcusdacoregio
Copy link
Contributor

marcusdacoregio commented Jul 20, 2023

Hi @stefanocke, thanks for the report.

It seems that the header has always been added by default, therefore we cannot change the behavior now since it is a breaking change and it is a better security default. In my opinion, the best approach here would be to update the documentation to reflect that Referrer-Policy: no-referrer is added, which is aligned with the recommendations [1][2].

In order to align the Servlet implementation, we can change the defaults to also include Referrer-Policy: no-referrer, but that won't happen until Spring Security 7.0 since it is a breaking change, I've created #13567 to track it.

@marcusdacoregio
Copy link
Contributor

With that said, are you interested in submitting a PR that updates the documentation? Ideally, the PR should target the 5.8.x branch.

@marcusdacoregio marcusdacoregio added the status: ideal-for-contribution An issue that we actively are looking for someone to help us with label Jul 20, 2023
@marcusdacoregio marcusdacoregio added this to the 5.8.6 milestone Jul 27, 2023
@marcusdacoregio marcusdacoregio removed the status: ideal-for-contribution An issue that we actively are looking for someone to help us with label Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: config An issue in spring-security-config type: bug A general bug
Projects
Archived in project
Development

No branches or pull requests

2 participants