Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why this error in dev console of chrome when using x-xss-protection?

How to fix this error in console?

Error parsing header X-XSS-Protection: 1; mode=block, 1;
mode=block:expected semicolon at character position 14.
The default protections will be applied.
like image 888
Vamsi Krishna Avatar asked Mar 31 '16 09:03

Vamsi Krishna


People also ask

Does Chrome prevent XSS?

On July 15, Google announced that the XSS Auditor module that protects Chrome users against Cross-site Scripting attacks is to be abandoned. It was found to be easy to bypass, inefficient, and causing too many false positives.

Can I use X-XSS-protection?

The X-XSS-Protection header is designed to enable the cross-site scripting (XSS) filter built into modern web browsers. This is usually enabled by default, but using it will enforce it. It is supported by Internet Explorer 8+, Chrome, and Safari.

What is X-XSS-protection?

The HTTP X-XSS-Protection response header is a feature of Internet Explorer, Chrome and Safari that stops pages from loading when they detect reflected cross-site scripting (XSS) attacks.

What is browser Xss not enabled?

Why Web Browser XSS Protection Not Enabled can be dangerous. Web Browser XSS Protection is not enabled, or is disabled by the configuration of the 'X-XSS-Protection' HTTP response header on the web server. Hackers use XSS attacks to trick trusted websites into delivering malicious content.


5 Answers

If the error is shown even you send the right header, check if you send the header perhaps twice. This is shown in the error-console below network and you click on any file.

Sending the header twice can happen if for the server

add_header X-XSS-Protection "1; mode=block";

is noted in two different include-files or one include-file is included twice. Browsers or at least chrome is concatenating the two headers then internally and the applied WRONG rule is then, like shown in the question:

X-XSS-Protection: "1; mode=block, 1; mode=block"
like image 150
David Avatar answered Oct 16 '22 23:10

David


I had the same error in Chrome. I was adding the header to multiple sites.

Instead, you should add it to the http block if you are using NGINX:

http {
    add_header X-XSS-Protection "1; mode=block";

    ...
}
like image 26
Christopher Markieta Avatar answered Oct 16 '22 22:10

Christopher Markieta


I had this error when I’m proxying a Docker service through NGINX. Both the Docker service and NGINX adds the header, so I need to dedupe. I finally came out with this:

map $upstream_http_x_xss_protection $xss_p {
    '' '1; mode=block';
}
add_header X-XSS-Protection $xss_p always;

I call this “poor man’s set_header”. Thanks to great hint from David and kolbyjack.

like image 29
Franklin Yu Avatar answered Oct 16 '22 21:10

Franklin Yu


If you are using Akamai use "modify" instead of "add" behavior in your configuration. Make sure you have selected the "avoid duplicate headers" option, which is only available in "modify" modus.

like image 2
Gianni C Avatar answered Oct 16 '22 23:10

Gianni C


You are not following the proper syntax of X-XSS-Protection, so you are getting a parsing error.

I think you are looking for this:

X-XSS-Protection: 1; mode=block

So remove the , 1 at the end of yours

like image 1
SBurris Avatar answered Oct 16 '22 21:10

SBurris