New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 825557 link

Starred by 4 users

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac , Fuchsia
Pri: 3
Type: Bug



Sign in to add a comment

X-XSS-Protection: allow report URL containing semicolon

Reported by yurn...@gmail.com, Mar 25 2018

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

Steps to reproduce the problem:
Response headers contain:

X-XSS-Protection: 1; mode=block; report="http://foo.com/bar.jsp;JSESSIONID=1234567"

What is the expected behavior?
Parse report URL as http://foo.com/bar.jsp;JSESSIONID=1234567

What went wrong?
Error in developer console:

Error parsing header X-XSS-Protection: 1; mode=block; report="http://foo.com/bar.jsp;JSESSIONID=1234567": unrecognized directive at character position 46. The default protections will be applied.

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 65.0.3325.181  Channel: stable
OS Version: 10.0
Flash Version: 

If report URL doesn't contain special characters, header can be written without escape-sequence:

X-XSS-Protection: 1; mode=block; report=http://foo.com/bar.jsp

But if your header contains special characters, for example, semicolon (which separates key=value pairs), you need to escape value. As per RFC2616, value can be escaped as quoted-string. So I'm quoting my URL:

X-XSS-Protection: 1; mode=block; report="http://foo.com/bar.jsp;JSESSIONID=1234567"

But then Chromium informs me (in developer console) that it couldn't parse header because it didn't follow RFC2616 and instead of parsing quoted value as quoted-string it parsed it as a plain string, found semicolon inside it and treated as a key=value separator:

Error parsing header X-XSS-Protection: 1; mode=block; report="http://foo.com/bar.jsp;JSESSIONID=1234567": unrecognized directive at character position 46. The default protections will be applied.
 

Comment 1 by ajha@chromium.org, Mar 26 2018

Labels: Needs-Triage-M65
Components: Blink>SecurityFeature>XSSAuditor
Labels: OS-Android OS-Chrome OS-Fuchsia OS-Linux OS-Mac
Status: Untriaged (was: Unconfirmed)
ParseXSSProtectionHeader tokenizes the URL using semicolon as a delimiter.

If you URL-encode the semicolon (using %3b) does the report submit as expected?

Comment 3 by mkwst@chromium.org, Mar 27 2018

Cc: tsepez@chromium.org
Labels: -Pri-2 Pri-3
Status: Available (was: Untriaged)
Thanks for the report!

As Eric suggests, URL-encoding the report URL should do the trick today. I suppose we could change the parser to accept strings. That shouldn't be terribly difficult, if someone's interested in doing it.

Comment 4 by yurn...@gmail.com, Mar 27 2018

In this case semicolon is a delimiter of special path parameters (the most widely known is JSESSIONID holding session identifier for Java EE).

Unfortunately, URL-escaping for semicolon as path-parameter delimiter breaks it. That's the same if you escape & as a query parameter delimiter - it would break query parameter.

Imagine you have normal query parameters: foo.com?bar=1&foobar=2. So there you have two parameters: bar="1" and foobar="2". What would happen if you escape ampersand? In our example: foo.com?bar=1%26foobar=2. This would give just one parameter: bar="1%26foobar=2". So escaping a delimiter is required for parameter values containing this delimiter.

So, URL-escaped parameter delimiter stops being parameter delimiter. It applies both to normal query parameters (delimiter is '&') and to path parameters (delimiter is ';').

Comment 5 by yurn...@gmail.com, Mar 27 2018

> ParseXSSProtectionHeader tokenizes the URL using semicolon as a delimiter.

This is against best-practice of RFC2616 (https://tools.ietf.org/html/rfc2616) which says that in complex header values semicolon separated token value may be either a token or quoted-string:

";" token [ "=" ( token | quoted-string ) ]

Comment 6 by tsepez@chromium.org, Mar 27 2018

Cc: mkwst@chromium.org
Owner: tsepez@chromium.org
Status: Assigned (was: Available)
We should probably fix this, eventually, given the report of at least one real-world server that parses paths in this manner. It's not a high priority, though.

Comment 7 by yurn...@gmail.com, Mar 27 2018

Any Java-based web-server parses paths in this manner. The most popular one is Apache Tomcat. Also JBoss/WildFly, Jetty, Glassfish, WebLogic, WebSphere, etc.

Comment 8 by tsepez@chromium.org, Mar 27 2018

Yeah, esp. given https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/network/HeaderFieldTokenizer.h, using our own hand-rolled tokenizer for this one header seems wrong and error-prone.  I'll try banging this out just for the code savings, if nothing else.
Status: Fixed (was: Assigned)

Comment 12 by yurn...@gmail.com, Apr 6 2018

Thanks!

Sign in to add a comment