Non-BMP code points that are WhiteSpace/LineTerminator when truncated to char16_t (e.g. U+4000D -> U+000D) should not be considered WhiteSpace
Firefox's JavaScript parser incorrectly treats a non-BMP character (U+4000D) as whitespace when truncated to 16 bits, allowing attackers to bypass WAFs and XSS filters that do not account for this behaviour. The reporter demonstrated bypasses of Cloudflare and Akamai WAFs using this character in XSS payloads.
- Fixed in 9 days
- Paid in 22 days
- Disclosed after 9 days
Tested On :
- Browser : Firefox Quantum Version 67.0 (64-bit)
- OS : macOS Mojave Version 10.14.5 Beta
Issue:
The character "\uD8C0\uDC0D" is ignored by the JS Parser. So below JS code is executable in Firefox browser.
For Example :
alert() //It is equivalent to alert()
document.domain // It is equivalent to document.domain
Impact: (Security Impact) :
The impact is most of WAF or XSS filters are built on the basis of defined specifications of HTML and Javascript. So it is unlikely to consider the behaviour of "\uD8C0\uDC0D" character while developing any WAF. So this leaves most of existing WAF's vulnerable to XSS even though they are perfectly secure for browsers like Chrome or Safari. I have used this unexpected behaviour of Firefox to bypass few popular WAF's.
Cloudflare Bypass : https://coinmarketcap.com/?<img%20src=x%20onerror=alert()>
Akamai Bypass : https://www.aliexpress.com/?<img%20src=x%20onerror=alert()>
The number of ways this behaviour can be exploited are endless and depends of attackers creativity.
Proof Of Concept:
1. Open console and type below Payload and see it getting executed without any error.
Payload : alert(document.domain) // It should alert "document.domain" property.
2. Save below HTML code and open in Firefox browser :
HTML code : <script>alert(document.domain)</script> // It should alert "document.domain" property.
What the report shows
The target is the JavaScript engine in Firefox. The researcher tested Firefox Quantum 67.0 (64-bit) on macOS Mojave 10.14.5 Beta and found that the surrogate pair \uD8C0\uDC0D is ignored by the JS parser. The pair encodes a non-BMP code point whose low 16 bits are 0x000D, a carriage return, and the parser ignores the character.
Because the character is silently dropped, ordinary JavaScript can be written with it inserted between tokens and still run. The report gives two examples:
alert() //It is equivalent to alert()
document.domain // It is equivalent to document.domain
The researcher's reasoning is that WAFs and XSS filters are built against the defined specifications of HTML and JavaScript, so they are unlikely to model this character. A filter that inspects a payload for alert( or document.domain will not match when the character is interleaved, while Firefox will still execute the result. The report states that this was used to bypass a few popular WAFs, with two examples:
Cloudflare Bypass : https://coinmarketcap.com/?<img%20src=x%20onerror=alert()>
Akamai Bypass : https://www.aliexpress.com/?<img%20src=x%20onerror=alert()>
The proof of concept has two steps. First, open the console and run:
alert(document.domain) // It should alert "document.domain" property.
Second, save the following HTML and open it in Firefox:
<script>alert(document.domain)</script> // It should alert "document.domain" property.
It does not describe a fix, a bounty amount or a CVE.
Root cause
The report does not explain the cause. The specification defines whitespace and line terminators over code points, and U+4000D is neither. If the engine truncates the code point to a 16-bit value before the whitespace check, the low half becomes U+000D, which is a line terminator, and the character is skipped. The same class of mistake can appear wherever a full code point is narrowed to char16_t before a character-class test.
Impact
The impact is filter evasion rather than a memory-safety issue. An attacker who can get a payload past a WAF or an XSS filter can have it executed by Firefox even though the filter saw nothing suspicious. The report is careful to say that the number of ways this can be exploited is endless and depends on the attacker's creativity, and that the two WAF bypasses are examples rather than a complete list. The practical consequence is that a site protected only by a signature-based filter can be attacked through Firefox while appearing safe for other browsers.
How this kind of bug works
Parsers and filters rarely agree on what counts as insignificant. JavaScript allows whitespace and line terminators between most tokens, and HTML has its own rules for character references and attribute parsing. A filter that tokenises input according to the specification will see a character it does not recognise as whitespace, while a browser that mishandles the character will treat it as whitespace and continue parsing. The payload is therefore valid to the browser and opaque to the filter.
The general pattern is a normalisation gap: two components decode or classify the same bytes differently. It shows up with Unicode case folding, overlong encodings, surrogate handling, null bytes and, as here, code points outside the Basic Multilingual Plane. Defences that help are strict input validation against an allowlist, canonicalisation before comparison, and filters that parse with the same grammar and Unicode tables as the target browser rather than matching strings.
How to test for it
- Identify a place where user input reaches a JavaScript context, either inline in HTML or in a script block, and where a WAF or filter sits in front.
- Establish a baseline: send a simple payload such as an
alertcall and confirm the filter blocks it. - Insert candidate characters between tokens of the same payload, one at a time. Start with non-BMP code points whose low 16 bits are whitespace or line terminators, and with other Unicode characters that browsers may normalise.
- Send each variant and observe both the filter response and the browser. A positive result is a payload the filter passes unchanged that the browser still executes.
- Confirm execution in the actual target browser, not only in a proxy or a parser library, because the behaviour is engine-specific.
Common false positives are a filter that blocks the request for an unrelated reason, a payload that is reflected but never reaches an executable context, and a browser that renders the character visibly instead of ignoring it. Always verify that the script actually runs.
How it is fixed
Hunting notes
This class of bug tends to hide in parser and tokeniser code, especially where Unicode handling, surrogate pairs and character classification meet. Recon signals include engines or libraries with recent changes to Unicode tables, custom parsers in proxies and filters, and any component that converts between encodings.
What happened, in plain words
Firefox is a web browser, and inside it sits a JavaScript engine: the part that reads the JavaScript code that web pages contain and runs it. JavaScript is the programming language that makes pages interactive, and it is also the language attackers abuse when they inject code into a page. The researcher tested Firefox Quantum 67.0 (64-bit) on macOS Mojave 10.14.5 Beta and found that the engine quietly ignores a particular character, written \uD8C0\uDC0D.
That character is unusual. Most text characters fit in a single 16-bit slot, but some, called non-BMP code points, need two slots, known as a surrogate pair. The pair \uD8C0\uDC0D stands for one such character, and its lower 16 bits happen to be 0x000D, which is a carriage return, a character that JavaScript treats as a line break. The engine appears to ignore the character entirely.
Because the character is silently dropped, ordinary JavaScript still runs when it is inserted between words. The report gives two examples:
alert() //It is equivalent to alert()
document.domain // It is equivalent to document.domain
Line by line: alert is a JavaScript function that pops up a message box, and alert() calls it with no message. document.domain reads the domain name of the current page. In both lines the invisible character sits between the parts of the code, and Firefox runs the code as if it were not there.
Why does that matter? Many websites are protected by a WAF, a web application firewall: a filter that inspects incoming requests and blocks ones that look like attacks. A very common attack is XSS, cross-site scripting, where an attacker slips JavaScript into a page so that it runs in other visitors' browsers. XSS filters look for telltale strings such as alert( or document.domain. They are built from the published rules of HTML and JavaScript, and those rules do not list this character as whitespace, so the filters do not expect it. A filter looking for alert( will not match alert with an invisible character in the middle, but Firefox will still execute it.
The report says this was used to get past a few popular WAFs, with two examples:
Cloudflare Bypass : https://coinmarketcap.com/?<img%20src=x%20onerror=alert()>
Akamai Bypass : https://www.aliexpress.com/?<img%20src=x%20onerror=alert()>
These are URLs with a payload appended. %20 is the URL encoding of a space. The payload is an HTML image tag, <img src=x onerror=...>: the browser tries to load an image from x, fails, and then runs whatever sits in onerror. Here that is alert(), again with the invisible character inserted. Cloudflare and Akamai are WAF providers, and the report says these payloads got past their filters on the two sites shown.
The proof of concept has two steps. First, open the browser console, a panel where you can type JavaScript directly, and run:
alert(document.domain) // It should alert "document.domain" property.
This should show a pop-up containing the page's domain name, with no error. Second, save the following as an HTML file and open it in Firefox:
<script>alert(document.domain)</script> // It should alert "document.domain" property.
A <script> tag tells the browser that what follows is JavaScript, so the same code runs when the page loads. The report does not describe a fix, a bounty amount or a CVE identifier.
In general, how this kind of bug works
Parsers and filters rarely agree on what counts as insignificant. A parser is the part of a program that reads text and works out its structure; a filter is a program that reads the same text looking for something bad. JavaScript allows whitespace and line breaks between most of its words, much as a sentence still makes sense with extra spaces. A filter that follows the specification sees a character it does not recognise as whitespace, while a browser that mishandles the character treats it as whitespace and carries on. The payload is valid to the browser and invisible to the filter.
The general pattern is a normalisation gap: two programs read the same bytes and classify them differently. It appears with Unicode case folding (where different characters are treated as the same letter), overlong encodings, surrogate handling, null bytes and, as here, code points outside the Basic Multilingual Plane. Defences that help are strict input validation against an allowlist (accept only what is known to be good), canonicalisation before comparison (reduce input to one standard form first), and filters that parse with the same grammar and Unicode tables as the target browser rather than matching strings.
How to test for it
- Find a place where user input reaches a JavaScript context, either inline in HTML or inside a script block, and where a WAF or filter sits in front.
- Establish a baseline: send a simple payload such as an
alertcall and confirm the filter blocks it. - Insert candidate characters between the parts of the same payload, one at a time. Start with non-BMP code points whose low 16 bits are whitespace or line terminators, and with other Unicode characters browsers may normalise.
- Send each variant and watch both the filter response and the browser. A positive result is a payload the filter passes unchanged that the browser still executes.
- Confirm execution in the actual target browser, not only in a proxy or a parser library, because the behaviour is engine-specific.
Common false positives are a filter that blocks the request for an unrelated reason, a payload that is reflected but never reaches an executable context, and a browser that shows the character visibly instead of ignoring it. Always verify that the script actually runs.
How it is fixed
Hunting notes
This class of bug tends to hide in parser and tokeniser code, especially where Unicode handling, surrogate pairs and character classification meet. Signals worth watching include engines or libraries with recent changes to Unicode tables, custom parsers in proxies and filters, and any component that converts between encodings.
Glossary
- JavaScript engine: the part of a browser that reads and runs JavaScript code.
- JavaScript: the programming language used to make web pages interactive.
- Parser: the component that reads text and works out its structure.
- Code point: a single character in the Unicode standard, identified by a number.
- Non-BMP code point: a character outside the Basic Multilingual Plane, the first 65,536 Unicode characters, which needs more than 16 bits to store.
- Surrogate pair: two 16-bit values used together to represent one non-BMP code point.
- 16-bit / char16_t: a storage unit holding 16 bits, enough for most but not all characters.
- Whitespace: characters such as spaces and tabs that separate words without being part of them.
- Line terminator: a character that marks the end of a line, such as a carriage return.
- WAF (web application firewall): a filter that inspects incoming web requests and blocks ones that look like attacks.
- XSS (cross-site scripting): an attack that slips JavaScript into a page so it runs in other visitors' browsers.
- XSS filter: a filter that looks for patterns typical of XSS payloads.
- Payload: the part of an attack that carries the malicious code.
- URL encoding: a way of writing characters in a URL, for example
%20for a space. onerror: an HTML attribute that runs code when an image fails to load.- Browser console: a panel in the browser where you can type and run JavaScript directly.
- Normalisation gap: a difference in how two programs interpret the same input.
- Canonicalisation: reducing input to one standard form before comparing it.
- Allowlist: a list of inputs that are known to be acceptable, with everything else rejected.
- CVE: a public identifier for a known security vulnerability.
- Severity: a rating of how serious a vulnerability is.