Skip to content

Conversation

invario
Copy link
Contributor

@invario invario commented Jun 13, 2025

Summary

Use of the X-XSS-Protection header with value "1; mode=block" is deprecated and in fact it appears to generally be recommended against. There are indications that from searching online that using it may actually cause vulnerabilities.

TODO

Test for any issues? I put this PR together quickly by just searching the repo for any mention of X-XSS-Protection and removing it/the corresponding code. There were a total of (8) instances located and I removed them all in this PR.

If simply removing this is bad practice, I would appreciate input/direction, as from what I read, the proper solution is to implement a "strong" CSP. One of the suggestions to avoid problems is to ensure unsafe-inline isn't used, but when I spot checked various NC apps and pages, I saw it was being used.

**However**, I believe it is still recommended to remove X-XSS-Protection no matter what.

Checklist

@invario invario requested review from a team, SebastianKrupinski and hamza221 as code owners June 13, 2025 19:36
@invario invario requested review from ArtificialOwl, skjnldsv and sorbaugh and removed request for a team June 13, 2025 19:36
@invario invario force-pushed the remove-x-xss-protection branch from e397074 to 2b58f74 Compare June 13, 2025 20:13
@iasdeoupxe
Copy link

Looks a documentation PR is there since some years as well: nextcloud/documentation#9188

@invario
Copy link
Contributor Author

invario commented Jun 13, 2025

Looks a documentation PR is there since some years as well: nextcloud/documentation#9188

Thanks! I didn't even look into the documentation yet, but now that I searched, it seems there are (3) instances of it being mentioned in the docs. (2) of them are for nginx sample configurations, and (1) is the one you mentioned. I'll gladly do another PR to remove those mentions... but wondering if I should wait to see if my current PR gets a green light.

Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking to prevent merge during vacations

@MichaIng
Copy link
Member

MichaIng commented Jun 27, 2025

Umm, coincidentally I was just annoyed enough by the false warning and created as well a PR to address this 😅. It however leaves the check in place, just allows 0 to be an accepted value as well, and suggests it, since this is the last well-known recommendation: #53711
And to not cause a ton of issues/topics on forum GitHub, I also allowed the old value to remain.

But OWASP indeed suggests both, either disabling XSS filtering explicitly, or not setting the header at all. So removing it from checks entirely is probably the better move. But I will leave the PR as alternative, if someone prefers it that way.

For anyone who is interested in more details about this header, and the actual vulnerabilities XSS filtering causes, even if combined with page blocking:

@MichaIng MichaIng added the 3. to review Waiting for reviews label Jun 27, 2025
@MichaIng MichaIng added this to the Nextcloud 32 milestone Jun 27, 2025
@MichaIng MichaIng added security feature: settings pending documentation This pull request needs an associated documentation update labels Jun 27, 2025
@github-actions
Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@MichaIng
Copy link
Member

MichaIng commented Jun 28, 2025

@invario can you rebase please, so we get checks green? I did locally, so there are no conflicts, but better to keep your commit signature. We need to wait for vacation lock to be lifted anyway, but lets assure everything else is finished and ready, to minimize any further delay.

I updated nextcloud/documentation#9188 to match this PR.

@invario
Copy link
Contributor Author

invario commented Jun 28, 2025

@invario can you rebase please, so we get checks green? I did locally, so there are no conflicts, but better to keep your commit signature. We need to wait for vacation lock to be lifted anyway, but lets assure everything else is finished and ready, to minimize any further delay.

I updated nextcloud/documentation#9188 to match this PR.

Great, thanks! Will rebase. Need bit of time. limited Internet on cruise lol

@nickvergessen
Copy link
Member

From: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-XSS-Protection#security_considerations

though this approach might be vulnerable to side-channel attacks if the website is embeddable in an <iframe>

But that is basically exactly it. By default Nextcloud is not embeddable from anywhere but itself:

/** @var array Domains which can embed this Nextcloud instance */
protected $allowedFrameAncestors = [
'\'self\'',
];

But reading further it seems CSP is covering this in general and for more browsers (comments against it were from 12-15y ago before CSP was a wide-spread thing).

@MichaIng
Copy link
Member

MichaIng commented Jun 30, 2025

But that is basically exactly it. By default Nextcloud is not embeddable from anywhere but itself:

Right, and even if CSP is not supported, it sets (and checks for) X-Frame-Options. So the side channel attacks possible with 1; mode=block are probably not possible on Nextcloud if everything else is correctly configured. Either way, no point to enforce anything in either direction: 1; mode=block, 0, and not defining the header at all should all be fine.

@nickvergessen
Copy link
Member

Tests are weirdly failing.

@MichaIng
Copy link
Member

Cypress and performance tests are expected to fail, but no idea what the background of this is:

Can not run cypress on forks

Can not run performance tests on forks

@nickvergessen
Copy link
Member

That is not what was confusing, the background is security of our GitHub tokens.
No-DB unit tests however were failing with something unrelated that is discussed in another PR to be added. Let's see if it passes here now.

@MichaIng
Copy link
Member

MichaIng commented Jun 30, 2025

Ah right, secrets are not accessible by forks, so Cypress would then fail due to empty CYPRESS_RECORD_KEY, unless that is added to the fork.

But why was the performance test failing, or why shall it not run on forks? Regarding secrets, it uses ${{ secrets.GITHUB_TOKEN }} only, which is set by GitHub and always available. Could be actually replaced by ${{ github.token }}, which is exactly the same, but makes more clear that it is not really a secret.

However, nodb tests and everything else is green.

Suitable for backport to 31 and 30 or not?

@nickvergessen nickvergessen merged commit 875e707 into nextcloud:master Jun 30, 2025
179 of 182 checks passed
@invario invario deleted the remove-x-xss-protection branch July 5, 2025 15:43
@skjnldsv skjnldsv mentioned this pull request Aug 19, 2025
dotlambda added a commit to dotlambda/nixpkgs that referenced this pull request Aug 31, 2025
bachp pushed a commit to NixOS/nixpkgs that referenced this pull request Aug 31, 2025
kieranknowles1 pushed a commit to kieranknowles1/nixpkgs that referenced this pull request Sep 1, 2025
@iasdeoupxe
Copy link

iasdeoupxe commented Sep 3, 2025

Not sure who is responsible so posting just here for now, https://scan.nextcloud.com probably needs adjustments as well as it reports e.g. the header as missing now.

@MichaIng
Copy link
Member

MichaIng commented Sep 3, 2025

Good point! Not sure where to report best 🤔.

mdaniels5757 pushed a commit to mdaniels5757/nixpkgs that referenced this pull request Sep 13, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews feature: settings feedback-requested pending documentation This pull request needs an associated documentation update security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Setup check for X-XSS-Protection recommendation is deprecated

5 participants