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

Explicit disable (unsafe) X-XSS-Protection-header #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ The default configuration:
`X-Frame-Options <https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options>`_
to ``SAMEORIGIN`` to avoid
`clickjacking <https://en.wikipedia.org/wiki/Clickjacking>`_.
- Sets `X-XSS-Protection
- Explicit disables `X-XSS-Protection
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection>`_
to enable a cross site scripting filter for IE and Safari (note Chrome has
removed this and Firefox never supported it).
to avoid introducing unintended vulnerabilities in otherwise safe code.
- Sets `X-Content-Type-Options
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options>`_
to prevent content type sniffing.
Expand Down
6 changes: 5 additions & 1 deletion flask_talisman/talisman.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@ def _set_frame_options_headers(self, headers, options):
options['frame_options_allow_from'])

def _set_content_security_policy_headers(self, headers, options):
headers['X-XSS-Protection'] = '1; mode=block'
# Yes, this is correct. The X-XSS-Protection header is deprecated and
# can actually introduce vulnerabilities in otherwise safe code, so lets
# explicit disable it. Ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
headers['X-XSS-Protection'] = '0'

headers['X-Content-Type-Options'] = 'nosniff'

if self.force_file_save:
Expand Down
2 changes: 1 addition & 1 deletion flask_talisman/talisman_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def testDefaults(self):
'X-Frame-Options': 'SAMEORIGIN',
'Strict-Transport-Security':
'max-age=31556926; includeSubDomains',
'X-XSS-Protection': '1; mode=block',
'X-XSS-Protection': '0',
'X-Content-Type-Options': 'nosniff',
'Content-Security-Policy': 'default-src \'self\'',
'Referrer-Policy': 'strict-origin-when-cross-origin'
Expand Down