WAF bypass via double encoded non standard ASCII chars permitted a reflected XSS on response page not found pages - (629745 bypass)
The WAF protecting Starbucks 404 pages could be bypassed by inserting a double-encoded non-standard ASCII character (e.g., %80) between the double-encoded quote and space, allowing a reflected XSS payload to execute. An attacker could run JavaScript in a victim's browser on Starbucks domains, leading to information theft or unwanted actions.
- Triaged in 20 hours
- Fixed in 2 months
- Paid in 2 months
- Disclosed after 3 months
Summary by the program
laszaro uncovered a bypass for report 629745 whereby the range of hex values %80-%FF was breaking the WAF filter which had not been accounted for in the original report.
@laszaro — thank you for reporting this vulnerability and confirming the resolution.
The report
Summary: Report 629745 not properly resolved: "Many Starbucks websites are vulnerable to cross-site scripting on 404 pages because double quotes lack sanitizing in hidden input tags, which leads to JavaScript execution".
Description: Report 629745 caught my attention, so I began testing the WAF to see if I could find any other issues. After a while I found out that the previously reported issue was not properly resolved as I was able to bypass the double encoding filter.
The original payload on the report was something like this:
https://www.starbucks.com.br/testing%2522%2520accesskey='x'%2520onclick='confirm%601%60'
and it got resolved. But you can bypass the filter with this:
https://www.starbucks.com.br/testing%2522%80%2520accesskey='x'%2520onclick='confirm%601%60'
Notice the %80 between %2522 and %2520. In fact, you can replace the %80 with any hex value beyond %7f and the payload still works (there's a couple of exceptions throwing "Bad Request" errors: %81, %8d, %8f, %90, and %9d), but values in the range %00-%7f get properly filtered out (throwing custom "Server Error" pages and 404 pages, 301 and 302 redirect pages, and default 400 Bad Request errors, depending on the value)
So, this payload works:
https://www.starbucks.com.br/testing%2522%FF%2520accesskey='x'%2520onclick='confirm%601%60'
but this one doesn't:
https://www.starbucks.com.br/testing%2522%7F%2520accesskey='x'%2520onclick='confirm%601%60'
There is a similar behaviour if you put the double-hex digit first. This payload breaks the filter:
https://www.starbucks.com.br/testing%80%2522%2520accesskey='x'%2520onclick='confirm%601%60'
but this one doesn't:
https://www.starbucks.com.br/testing%7F%2522%2520accesskey='x'%2520onclick='confirm%601%60'
Platform(s) Affected: Firefox 69.0.3
Steps To Reproduce:
- Visit this link on Firefox:
https://www.starbucks.com.br/testing%2522%80%2520accesskey='x'%2520onclick='confirm%601%60'
- Press CONTROL+ALT+X on Mac, or ALT+SHIFT+X on Windows
Recommendations for fix
The range of hex values %80-%FF is breaking the WAF filter, those values need to be filtered out just like the range %00-%7F is being filtered out.
Impact
As the original report said: "JavaScript is against Starbucks users on multiple critical domains. JavaScript execution results in information theft and an attacker can perform unwanted actions on a victim's behalf".
Context
Starbucks runs several regional sites, and this report concerns the Brazilian site, www.starbucks.com.br. The behaviour under test is the 404 page: when a request hits a path that does not exist, the site reflects part of the requested URL back into the page, inside a hidden input tag. The earlier report 629745 established that double quotes in that reflected value were not sanitised, so a crafted URL could break out of the hidden input's attribute and inject an event handler that runs JavaScript.
This report is about the fix for that earlier issue not being complete. The researcher, laszaro, tested the web application firewall (WAF) in front of the site and found that the double encoding filter could still be bypassed, so the reflected XSS on 404 pages remained exploitable. The program's summary describes it as a bypass for report 629745, where the range of hex values %80 to %FF was breaking the WAF filter and had not been accounted for in the original report.
Setup
The only client detail given is the browser: Firefox 69.0.3, listed as the affected platform. No accounts, roles or special tooling are described. The precondition is simply that the target reflects the requested path into the 404 page and that a WAF sits in front of it, filtering the double-encoded quote sequence used in the original payload.
Finding it
Report 629745 caught the researcher's attention, so the starting point was to test the WAF itself to see whether other issues existed. After a while of testing, the conclusion was that the previously reported issue had not been properly resolved: the double encoding filter could be bypassed.
The original payload from report 629745 looked something like this:
https://www.starbucks.com.br/testing%2522%2520accesskey='x'%2520onclick='confirm%601%60'
That payload was resolved. The bypass adds a single extra encoded byte between the double-encoded quote and the double-encoded space:
https://www.starbucks.com.br/testing%2522%80%2520accesskey='x'%2520onclick='confirm%601%60'
The difference is the %80 between %2522 and %2520. The researcher then mapped the boundary: the %80 can be replaced with any hex value beyond %7f, and the payload still works. There are a few exceptions that produce "Bad Request" errors: %81, %8d, %8f, %90 and %9d. Values in the range %00 to %7f are properly filtered out, producing custom "Server Error" pages, 404 pages, 301 and 302 redirect pages, or default 400 Bad Request errors, depending on the value.
So this payload works:
https://www.starbucks.com.br/testing%2522%FF%2520accesskey='x'%2520onclick='confirm%601%60'
while this one does not:
https://www.starbucks.com.br/testing%2522%7F%2520accesskey='x'%2520onclick='confirm%601%60'
The same behaviour appears when the extra byte is placed before the double-encoded quote. This payload breaks the filter:
https://www.starbucks.com.br/testing%80%2522%2520accesskey='x'%2520onclick='confirm%601%60'
but this one does not:
https://www.starbucks.com.br/testing%7F%2522%2520accesskey='x'%2520onclick='confirm%601%60'
Exploitation
Step 1: open the crafted URL in Firefox
Visit the following link in Firefox:
https://www.starbucks.com.br/testing%2522%80%2520accesskey='x'%2520onclick='confirm%601%60'
The payload is carried in the path after the site name. The rest of the path carries the payload. %2522 is a double-encoded double quote, %80 is the non-standard byte that slips past the WAF, and %2520 is a double-encoded space. Together they close the hidden input's attribute and start a new one: accesskey='x' followed by onclick='confirm%601%60'. The %60 sequences are encoded backticks, so the handler body is confirm1``, a call to the browser's confirm dialog. When the injected attribute is triggered, the handler runs.
Step 2: trigger the handler
Press CONTROL+ALT+X on Mac, or ALT+SHIFT+X on Windows. This is the browser shortcut that activates the element carrying the injected accesskey, firing the onclick handler and executing the JavaScript.
Root cause
The 404 page reflects the requested path into a hidden input tag without sanitising double quotes, which is the flaw identified in report 629745. The defence in front of it is a WAF rule that filters the double-encoded quote sequence. That rule only accounts for the %00 to %7f range: when a byte above %7f is inserted into the sequence, the filter no longer matches and the request passes through, while the browser still decodes the payload into a working attribute break. The filter did not account for bytes above %7f, so a single extra byte restored the bypass.
Impact
The impact is the same as described in the original report: JavaScript execution against Starbucks users on multiple critical domains. As the original report put it, JavaScript execution results in information theft, and an attacker can perform unwanted actions on a victim's behalf. Exploitation requires the victim to open the crafted link and then use the accesskey shortcut, and the payload as demonstrated targets the Brazilian site's 404 page.
Fix
The recommendation is to filter the range of hex values %80 to %FF in the WAF, just as the range %00 to %7F is already filtered out, because those values are what break the filter. The program's summary thanks the researcher for reporting the vulnerability and confirming the resolution.
Variants to test
- Insert a byte above
%7fat other positions in a known blocked payload, for example between other double-encoded characters, and check whether the request reaches the application instead of being rejected. A positive result is the page reflecting the payload rather than returning a WAF error page. - Try the full
%80to%FFrange, skipping the values that return "Bad Request" (%81,%8d,%8f,%90,%9d), and confirm which ones still deliver the payload. A positive result is JavaScript execution for values the filter was expected to block. - Place the extra byte before the double-encoded quote rather than after it, as in the second bypass above. A positive result is the same attribute break and handler execution.
- Test the boundary values
%7Fand%80side by side on any similar reflection. A positive result is%7Fbeing filtered while%80passes, which shows the filter's range is incomplete.
What happened, in plain words
Starbucks runs websites for many countries. This report is about the Brazilian one, www.starbucks.com.br. When you ask a website for a page that does not exist, the site usually shows a "page not found" message. On this site, 404 pages reflected part of the address back into a hidden input tag. That copying is the seed of the problem: if the site copies your text without cleaning it, you can type text that the browser treats as instructions rather than as plain words.
An earlier report, number 629745, had already found this. Someone showed that a double quote character in the address was not cleaned, so a crafted link could break out of a hidden form field and add a small piece of JavaScript. JavaScript is the programming language that runs inside your browser; it can read what is on the page and act on your behalf. The earlier report was marked resolved, but the issue was not properly fixed.
The researcher here, laszaro, did not start from scratch. He started by testing the shield that sits in front of the site, called a web application firewall (WAF). A WAF is like a security guard at the door of a building: it reads every request before it reaches the website and turns away the ones that look like known attacks. The guard had a rule for the earlier attack, but the rule only looked at part of the picture. By slipping one extra encoded character into the link, laszaro got past the guard, and the old attack worked again. The program's own summary calls it a bypass for report 629745, where the range of hex values %80 to %FF was breaking the WAF filter and had not been accounted for in the original report.
The pieces you need to know
Before the steps, a few everyday ideas.
- URL and path: a URL is the address of a page, like a street address. The part after the site name, here
/testing..., is the path. It is the bit that says which page you want. - 404 page: the page a site shows when the path does not match anything. It is the site's way of saying "I have no page at that address".
- Hidden input tag: a form field that the visitor cannot see. It still exists in the page's code and can carry a value. Think of a label stuck on the back of a form that the clerk reads but the customer never sees.
- Attribute: a setting written inside an HTML tag, such as
onclick='...'. HTML is the language pages are written in; attributes are the extra instructions attached to an element. - Event handler: a piece of JavaScript that runs when something happens, for example when an element is clicked (
onclick) or when a keyboard shortcut tied to an element is used (accesskey). - Reflected XSS: cross-site scripting where the site takes something you sent and echoes it back into the page. "Reflected" means it bounces straight back at you; "XSS" means the echoed text can become live JavaScript in the browser.
- Encoding: computers cannot put every character directly into a URL, so characters are written as codes.
%22means a double quote.%20means a space.%60means a backtick. When a value is encoded twice,%22becomes%2522, because the%itself is encoded as%25. - Hex value: a number written in base 16, using 0 to 9 and A to F. In a URL,
%80means the byte with hex value 80. The range%00to%7Fcovers the standard ASCII characters;%80to%FFgoes beyond them. - WAF: the security guard described above. It inspects requests and blocks patterns it recognises.
- Removing or encoding quotes is a common example.
Setting the scene
The only client detail given is the browser: Firefox 69.0.3, listed as the affected platform. No accounts, roles or special tools are described. The precondition is simply that the target reflects the requested path into the 404 page and that a WAF sits in front of it, filtering the double-encoded quote sequence used in the original payload.
Finding it
Report 629745 caught the researcher's attention, so the starting point was to test the WAF itself, to see whether other issues existed. After a while of testing, the conclusion was that the previously reported issue had not been properly resolved: the double encoding filter could be bypassed.
The original payload from report 629745 looked something like this:
https://www.starbucks.com.br/testing%2522%2520accesskey='x'%2520onclick='confirm%601%60'
Line by line, in plain words:
https://www.starbucks.com.br/is the site.testingis the path segment that carries the payload.%2522is a double-encoded double quote. The browser and the server each decode one layer, and a real"comes out at the end. That quote is meant to close the hidden input's attribute.%2520is a double-encoded space, which separates one attribute from the next.accesskey='x'adds a keyboard shortcut to the element: pressing the shortcut key together with the browser's modifier keys activates it.onclick='confirm%601%60'adds a click handler.%60is an encoded backtick, so the handler body becomesconfirm1``, a call to the browser's confirm dialog.
That payload was resolved. The bypass adds a single extra encoded byte between the double-encoded quote and the double-encoded space:
https://www.starbucks.com.br/testing%2522%80%2520accesskey='x'%2520onclick='confirm%601%60'
- Everything is the same as the original payload except for
%80, which sits between%2522and%2520. %80is a byte above the standard ASCII range. The WAF's rule was written for the standard range, so this extra byte makes the request stop matching the rule and the guard lets it through.- The payload still works with this extra byte in place.
The researcher then mapped the boundary: the %80 can be replaced with any hex value beyond %7f, and the payload still works. There are a few exceptions that produce "Bad Request" errors: %81, %8d, %8f, %90 and %9d. Values in the range %00 to %7f are properly filtered out, producing custom "Server Error" pages, 404 pages, 301 and 302 redirect pages, or default 400 Bad Request errors, depending on the value.
So this payload works:
https://www.starbucks.com.br/testing%2522%FF%2520accesskey='x'%2520onclick='confirm%601%60'
%FFis the top of the byte range, well above%7f. It plays the same role as%80: it is an unusual byte the WAF rule did not expect, so the request passes and the quote and space still decode.
while this one does not:
https://www.starbucks.com.br/testing%2522%7F%2520accesskey='x'%2520onclick='confirm%601%60'
%7Fis the last value inside the standard range. The WAF rule covers this range, so the request is caught and the payload never reaches the page.
The same behaviour appears when the extra byte is placed before the double-encoded quote. This payload breaks the filter:
https://www.starbucks.com.br/testing%80%2522%2520accesskey='x'%2520onclick='confirm%601%60'
- Here
%80comes first, before%2522. Here%80comes first, before%2522, and the payload still breaks the filter.
but this one does not:
https://www.starbucks.com.br/testing%7F%2522%2520accesskey='x'%2520onclick='confirm%601%60'
%7Fin the same leading position is inside the range the rule covers, so it is filtered out.
Exploitation
Step 1: open the crafted URL in Firefox
Visit the following link in Firefox:
https://www.starbucks.com.br/testing%2522%80%2520accesskey='x'%2520onclick='confirm%601%60'
- The payload is carried in the path after the site name.
- The rest of the path carries the payload.
%2522is a double-encoded double quote,%80is the non-standard byte that slips past the WAF, and%2520is a double-encoded space. - Together they close the hidden input's attribute and start a new one:
accesskey='x'followed byonclick='confirm%601%60'. - The
%60sequences are encoded backticks, so the handler body isconfirm1``, a call to the browser's confirm dialog. - When the injected attribute is triggered, the handler runs. "Origin" means the site's own security boundary: code running there is treated as part of that site, which is why this matters.
Step 2: trigger the handler
Press CONTROL+ALT+X on Mac, or ALT+SHIFT+X on Windows. This is the browser shortcut that activates the element carrying the injected accesskey, firing the onclick handler and executing the JavaScript.
Why a shortcut and not a click? The accesskey attribute gives it a keyboard route instead, and the browser's modifier keys plus the letter are that route.
Root cause
The 404 page reflects the requested path into a hidden input tag without sanitising double quotes, which is the flaw identified in report 629745. The defence in front of it is a WAF rule that filters the double-encoded quote sequence. That rule only accounts for the %00 to %7f range: when a byte above %7f is inserted into the sequence, the filter no longer matches and the request passes through, while the browser still decodes the payload into a working attribute break. The filter did not account for bytes above %7f, so a single extra byte restored the bypass.
In everyday terms: the guard was given a photo of the previous intruder and told to stop anyone who looks exactly like that. A hat was enough to get past.
Impact
The impact is the same as described in the original report: JavaScript execution against Starbucks users on multiple critical domains. As the original report put it, JavaScript execution results in information theft, and an attacker can perform unwanted actions on a victim's behalf. Exploitation requires the victim to open the crafted link and then use the accesskey shortcut, and the payload as demonstrated targets the Brazilian site's 404 page.
Fix
The recommendation is to filter the range of hex values %80 to %FF in the WAF, just as the range %00 to %7F is already filtered out, because those values are what break the filter. The program's summary thanks the researcher for reporting the vulnerability and confirming the resolution.
Variants to test
- Insert a byte above
%7fat other positions in a known blocked payload, for example between other double-encoded characters, and check whether the request reaches the application instead of being rejected. A positive result is the page reflecting the payload rather than returning a WAF error page. - Try the full
%80to%FFrange, skipping the values that return "Bad Request" (%81,%8d,%8f,%90,%9d), and confirm which ones still deliver the payload. A positive result is JavaScript execution for values the filter was expected to block. - Place the extra byte before the double-encoded quote rather than after it, as in the second bypass above. A positive result is the same attribute break and handler execution.
- Test the boundary values
%7Fand%80side by side on any similar reflection. A positive result is%7Fbeing filtered while%80passes, which shows the filter's range is incomplete.
Glossary
- 404 page: the page a website shows when the requested address does not exist.
- Accesskey: an HTML attribute that gives an element a keyboard shortcut, so it can be activated without a mouse.
- ASCII: the standard set of characters and codes used for basic text; in URLs its range runs from
%00to%7F. - Attribute: a setting written inside an HTML tag, such as
onclickoraccesskey. - Backtick: the
`character, used here as an alternative way to quote a string in JavaScript. - Bypass: getting past a protection without removing it, by finding a case it does not handle.
- Double encoding: encoding a value twice, so that one decoding step still leaves an encoded character behind;
%22becomes%2522. - Encoding: writing characters as codes so they can travel safely in a URL, for example
%22for a double quote. - Event handler: JavaScript attached to an element that runs when something happens, such as a click.
- Firefox 69.0.3: the browser version listed as the affected platform in this report.
- Hex value: a number written in base 16, using 0 to 9 and A to F; in a URL,
%80means the byte with hex value 80. - Hidden input tag: a form field that exists in the page but is not shown to the visitor.
- HTML: the language web pages are written in, made of tags and attributes.
- JavaScript: the programming language that runs in the browser and can act on the page and on the user's behalf.
- Origin: the security boundary of a site, made of its scheme, host and port; code running in an origin is treated as part of that site.
- Path: the part of a URL after the site name that says which page is requested.
- Reflected XSS: cross-site scripting where the site echoes the attacker's input straight back into the page.
- URL: the address of a page on the web.
- WAF (web application firewall): a filter in front of a website that inspects requests and blocks ones matching known attack patterns.