Skip to content

Commit 875e707

Browse files
Merge pull request #53476 from invario/remove-x-xss-protection
Fix: Remove X-XSS-Protection use, check and recommendation
2 parents ac70e12 + 60b8384 commit 875e707

File tree

8 files changed

+1
-20
lines changed

8 files changed

+1
-20
lines changed

.htaccess

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@
4040
Header onsuccess unset X-Robots-Tag
4141
Header always set X-Robots-Tag "noindex, nofollow"
4242

43-
Header onsuccess unset X-XSS-Protection
44-
Header always set X-XSS-Protection "1; mode=block"
45-
4643
SetEnv modHeadersAvailable true
4744
</IfModule>
4845

apps/settings/lib/SetupChecks/SecurityHeaders.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ public function run(): SetupResult {
7272
}
7373
}
7474

75-
$xssFields = array_map('trim', explode(';', $response->getHeader('X-XSS-Protection')));
76-
if (!in_array('1', $xssFields) || !in_array('mode=block', $xssFields)) {
77-
$msg .= $this->l10n->t('- The `%1$s` HTTP header does not contain `%2$s`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', ['X-XSS-Protection', '1; mode=block']) . "\n";
78-
}
79-
8075
$referrerPolicy = $response->getHeader('Referrer-Policy');
8176
if (!preg_match('/(no-referrer(-when-downgrade)?|strict-origin(-when-cross-origin)?|same-origin)(,|$)/', $referrerPolicy)) {
8277
$msg .= $this->l10n->t(

apps/settings/tests/SetupChecks/SecurityHeadersTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function testSomeHeadersMissing(): void {
8484

8585
$result = $this->setupcheck->run();
8686
$this->assertEquals(
87-
"Some headers are not set correctly on your instance\n- The `X-Content-Type-Options` HTTP header is not set to `nosniff`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n- The `X-XSS-Protection` HTTP header does not contain `1; mode=block`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n",
87+
"Some headers are not set correctly on your instance\n- The `X-Content-Type-Options` HTTP header is not set to `nosniff`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n",
8888
$result->getDescription()
8989
);
9090
$this->assertEquals(SetupResult::WARNING, $result->getSeverity());
@@ -94,7 +94,6 @@ public static function dataSuccess(): array {
9494
return [
9595
// description => modifiedHeaders
9696
'basic' => [[]],
97-
'extra-xss-protection' => [['X-XSS-Protection' => '1; mode=block; report=https://example.com']],
9897
'no-space-in-x-robots' => [['X-Robots-Tag' => 'noindex,nofollow']],
9998
'strict-origin-when-cross-origin' => [['Referrer-Policy' => 'strict-origin-when-cross-origin']],
10099
'referrer-no-referrer-when-downgrade' => [['Referrer-Policy' => 'no-referrer-when-downgrade']],
@@ -113,7 +112,6 @@ public static function dataSuccess(): array {
113112
public function testSuccess(array $headers): void {
114113
$headers = array_merge(
115114
[
116-
'X-XSS-Protection' => '1; mode=block',
117115
'X-Content-Type-Options' => 'nosniff',
118116
'X-Robots-Tag' => 'noindex, nofollow',
119117
'X-Frame-Options' => 'SAMEORIGIN',
@@ -140,8 +138,6 @@ public static function dataFailure(): array {
140138
return [
141139
// description => modifiedHeaders
142140
'x-robots-none' => [['X-Robots-Tag' => 'none'], "- The `X-Robots-Tag` HTTP header is not set to `noindex,nofollow`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n"],
143-
'xss-protection-1' => [['X-XSS-Protection' => '1'], "- The `X-XSS-Protection` HTTP header does not contain `1; mode=block`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n"],
144-
'xss-protection-0' => [['X-XSS-Protection' => '0'], "- The `X-XSS-Protection` HTTP header does not contain `1; mode=block`. This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.\n"],
145141
'referrer-origin' => [['Referrer-Policy' => 'origin'], "- The `Referrer-Policy` HTTP header is not set to `no-referrer`, `no-referrer-when-downgrade`, `strict-origin`, `strict-origin-when-cross-origin` or `same-origin`. This can leak referer information. See the {w3c-recommendation}.\n"],
146142
'referrer-origin-when-cross-origin' => [['Referrer-Policy' => 'origin-when-cross-origin'], "- The `Referrer-Policy` HTTP header is not set to `no-referrer`, `no-referrer-when-downgrade`, `strict-origin`, `strict-origin-when-cross-origin` or `same-origin`. This can leak referer information. See the {w3c-recommendation}.\n"],
147143
'referrer-unsafe-url' => [['Referrer-Policy' => 'unsafe-url'], "- The `Referrer-Policy` HTTP header is not set to `no-referrer`, `no-referrer-when-downgrade`, `strict-origin`, `strict-origin-when-cross-origin` or `same-origin`. This can leak referer information. See the {w3c-recommendation}.\n"],
@@ -157,7 +153,6 @@ public static function dataFailure(): array {
157153
public function testFailure(array $headers, string $msg): void {
158154
$headers = array_merge(
159155
[
160-
'X-XSS-Protection' => '1; mode=block',
161156
'X-Content-Type-Options' => 'nosniff',
162157
'X-Robots-Tag' => 'noindex, nofollow',
163158
'X-Frame-Options' => 'SAMEORIGIN',

build/integration/dav_features/carddav.feature

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ Feature: carddav
4949
|X-Frame-Options|SAMEORIGIN|
5050
|X-Permitted-Cross-Domain-Policies|none|
5151
|X-Robots-Tag|noindex, nofollow|
52-
|X-XSS-Protection|1; mode=block|
5352

5453
Scenario: Exporting the picture of ones own contact
5554
Given "admin" creates an addressbook named "MyAddressbook" with statuscode "201"
@@ -63,7 +62,6 @@ Feature: carddav
6362
|X-Frame-Options|SAMEORIGIN|
6463
|X-Permitted-Cross-Domain-Policies|none|
6564
|X-Robots-Tag|noindex, nofollow|
66-
|X-XSS-Protection|1; mode=block|
6765

6866
Scenario: Create addressbook request for non-existing addressbook of another user
6967
Given user "user0" exists

build/integration/dav_features/dav-v2.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ Feature: dav-v2
4141
|X-Frame-Options|SAMEORIGIN|
4242
|X-Permitted-Cross-Domain-Policies|none|
4343
|X-Robots-Tag|noindex, nofollow|
44-
|X-XSS-Protection|1; mode=block|
4544
And Downloaded content should start with "Welcome to your Nextcloud account!"
4645

4746
Scenario: Doing a GET with a web login should work without CSRF token on the new backend

build/integration/dav_features/webdav-related.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ Feature: webdav-related
291291
|X-Frame-Options|SAMEORIGIN|
292292
|X-Permitted-Cross-Domain-Policies|none|
293293
|X-Robots-Tag|noindex, nofollow|
294-
|X-XSS-Protection|1; mode=block|
295294
And Downloaded content should start with "Welcome to your Nextcloud account!"
296295

297296
Scenario: Doing a GET with a web login should work without CSRF token on the old backend

lib/private/legacy/OC_Response.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public static function addSecurityHeaders() {
7878
header('X-Frame-Options: SAMEORIGIN'); // Disallow iFraming from other domains
7979
header('X-Permitted-Cross-Domain-Policies: none'); // https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html
8080
header('X-Robots-Tag: noindex, nofollow'); // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag
81-
header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters
8281
}
8382
}
8483
}

tests/data/setUploadLimit/htaccess

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<IfModule mod_env.c>
1111
# Add security and privacy related headers
1212
Header set X-Content-Type-Options "nosniff"
13-
Header set X-XSS-Protection "1; mode=block"
1413
Header set X-Robots-Tag "noindex, nofollow"
1514
Header set X-Frame-Options "SAMEORIGIN"
1615
SetEnv modHeadersAvailable true

0 commit comments

Comments
 (0)