10

Change default `X-XSS-Protection` header to '0' by csutter · Pull Request #41769...

 2 years ago
source link: https://github.com/rails/rails/pull/41769
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

New issue

Change default X-XSS-Protection header to '0' #41769

Conversation

Copy link

Contributor

csutter commented on Mar 26

edited

Summary

This header has been deprecated and the XSS auditor it triggered has been removed from all major modern browsers (in favour of Content Security Policy) that implemented this header to begin with (Firefox never did).

OWASP suggest setting this header to '0' to disable the default behaviour on old browsers as it can introduce additional security issues.

Added the new behaviour as a framework default from Rails 7.0.

Some other resources discussing this header and why it should be set to '0':

Copy link

Member

rafaelfranca commented on Mar 26

👍🏽 this make sense for all new apps but existing apps should decide if they want to change the value or not. So I think we should introduce the new value behind a configuration flag that is default in Rails 7.0 but for any other Rails version we keep the behavior and ask people to change the config to match Rials 7.0 in the new_frameworks_default file. Can you change your PR to reflect that plan?

Copy link

Contributor

Author

csutter commented on Mar 29

@rafaelfranca Thanks for the feedback! I've updated the change to be a defaults change instead, starting at 7.0.

I've considered having a specific configuration flag for this change, but that felt a bit strange – we'd have to start merging things into the default default_headers hash, and if users set their own hash we wouldn't want to override it. So I've made it set a new default for the whole hash.

This way we could maybe also add some additional headers/change existing headers for Rails 7.0 to reflect current best practice, and do it all in one go?

Copy link

rails-bot bot commented on Jun 27

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

Copy link

Member

zzak commented on Jun 29

@csutter Could you rebase please?

Also, copying the important part from that page since the link doesn't go directly to it for those curious:

X-XSS-Protection: Deprecated.

warning Warning: The X-XSS-Protection header has been deprecated by modern browsers and its use can introduce additional security issues on the client side. As such, it is recommended to set the header as X-XSS-Protection: 0 in order to disable the XSS Auditor, and not allow it to take the default behavior of the browser handling the response. Please use Content-Security-Policy instead.

Copy link

Contributor

Author

csutter commented on Sep 14

@rafaelfranca @zzak I've given this another rebase - would love to see it make it into 7.0!

rafaelfranca

merged commit 481343e into

rails:main yesterday

4 checks passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK