The $1,000 worth cookie
A cookie parameter named 'gp' was reflected unsanitised into a script block on mail.ru, allowing DOM-based cross-site scripting. An attacker could execute arbitrary JavaScript in a victim's browser, potentially stealing cookies or performing actions as the user.
Published on medium.com
{{media:0}}
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
Mail.ru is described here as Russia's biggest Internet company, and the target of this hunt was its top-level domain, https://mail.ru. The write-up is about an XSS reached through an HTTP request header rather than a URL parameter: a cookie named gp whose value is reflected into the page response. The author frames the whole exercise as an early attempt at XSS hunting, a year after joining HackerOne, and the report was filed on that platform as report 690072.
Setup
The tooling was Burp Suite, used to intercept requests and inspect responses, plus the Param Miner extension from the Burp BApp Store, authored by James 'albinowax' Kettle of PortSwigger Web Security. Param Miner was used to brute-force hidden parameters. The browser used to load the reflected response was Firefox, and the request shown carries a Firefox 60 user agent on Linux x86_64. No account, role or special precondition is described: the researcher was simply browsing https://mail.ru with Burp in the loop.
Finding it
While browsing the site and watching requests and responses in Burp, the researcher ran Param Miner to look for hidden parameters. The Burp issue tab listed parameters the extension had brute-forced and found to be valid. One of them was a cookie HTTP request header called gp. It stood out because its value was reflected in the response to any request that contained it, which made it a candidate for XSS.

Exploitation
Step 1: a first payload in the cookie value
The researcher's stated method for reflected XSS is to throw dangerous characters at the parameter one at a time to work out which are filtered by a Web Application Firewall, if one is present, and then craft a bypass. In this case, the write-up says, no such filtering was in the way. The first attempt put this payload into the value of the gp cookie:
<script>alert(document.cookie)</script>
The response was opened with Burp's "Show response in browser" and the generated link loaded in Firefox. No alert box appeared. Several variations were tried over about an hour without success, and the researcher posted the issue on a Facebook bug bounty forum asking for help.
The request and response at that stage looked like this:
GET / HTTP/1.1 Host: mail.ru User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Cookie: gp= some alpha numeric string; Connection: close Upgrade-Insecure-Requests: 1 Cache-Control: max-age=0200 OK</script><script id="script:globals">var mr={:{BUILD:"307ad21",VERSION:1566410797,TIMESTAMP:1567848214281,TIMESTAMP_LOCAL: Date.now(),TIMEZONE:10800,AUTH:!1,CITY:"Кампала",REGION_ID:233, PAGE_ID: "15678651219031568689886875",ACC_CNT: false,MEDIA_ORDER:"regional,regional,auto,auto,lady,lady,deti,deti,health,health,sport,sport,cinema,cinema,hitech,hitech,games,games",INCUT_ORDER:"incut,stub",WIDGET_ORDER:"horo,tv,torg",FEATURE_ORDER:"auto,lady,sport,cinema,hitech,games",TARGET:"default",SITEZONE:15,SITEID:169,DEVICE:"desktop",BROWSER:"Firefox",PLATFORM:"Linux",REGION_LEVEL_ID:188,GP:"Payload gets reflected here ;",CSRF:"[redacted]",MANUAL_REGION_NOT_RUSSIA:true,HONEYPOT: '.gridmain-col .tgb, .grid .grid_main-col
The important part is the GP property inside the inline script:globals block, where the cookie value is written into a JavaScript string: GP:"Payload gets reflected here ;".
Step 2: closing the existing script element
The next day the researcher realised the initial script tag had to be closed before a new one could be introduced, and changed the payload to:
</script><script>alert(document.domain)</script>
The request was fired again and the payload was properly reflected in the response.

Step 3: confirming execution in the browser
Loading the response in the browser finally produced the alert box, together with the domain on which the XSS had been triggered.

Output for payload revealing user's cookies

Root cause
The value of the gp cookie is copied into the page inside an inline script, in the GP property of the mr object. Because the injection point sits inside a script element, the only thing needed to break out is a closing </script> sequence, after which the parser treats what follows as new markup. The write-up says no such filtering was in the way for the application. The author also notes not understanding the concept of context at the time.
Impact
The researcher's own assessment was that this looked like self-XSS at best, since the attacker has to control the victim's cookie header. What raised expectations of a reward was reading other reports in which hunters had shown Mail.ru that a man-in-the-middle attack vector could be used to deliver the attack to legitimate users by taking advantage of vulnerable cookie parameters in the site's infrastructure. The write-up points to a further Medium story by Max, "Сookie-based XSS exploitation | $2300 Bug Bounty story", for background on that delivery model. The payload used for the final proof reads document.domain, and the earlier attempt read document.cookie.
Fix
The report does not describe the change that was made. The timeline records the issue as fixed on September 27, 2019, the day after the bounty was awarded.
Timeline
| Date | Event |
|---|---|
| September 7, 2019 | Reported |
| September 8, 2019 | Triaged |
| September 26, 2019 | Bounty awarded |
| September 27, 2019 | Issue fixed |
The bounty was 1,000 USD, which gives the write-up its title.
Variants to test
- Run Param Miner (or any parameter brute-forcer) against a host and inspect the Burp issue tab for headers and cookies that are accepted and reflected. A positive result is a parameter whose value appears verbatim in the response body.
- For each reflected value, identify the surrounding context. If it lands inside an inline
<script>, try a payload that closes the element first, as here:
</script><script>alert(document.domain)</script>
Execution of the alert in a browser confirms the finding; a payload that only opens a new <script> tag will be inert in that context.
3. Test cookie-backed parameters specifically, since they are easy to overlook and, as other reports cited here show, can be set by an attacker positioned on the network path. A positive result is a cookie value that survives into the rendered page and executes.
4. When a payload fails, vary one character class at a time to map any filtering, as the author recommends, before concluding the parameter is not exploitable.
What happened, in plain words
A security researcher was hunting for bugs on HackerOne, a website where companies offer rewards to people who find security problems in their products. He was still new to this, about a year after joining the platform. He decided to look for one particular kind of bug, Cross-Site Scripting (XSS), on https://mail.ru, the top-level domain of what the write-up calls Russia's biggest Internet company.
XSS is a bug where an attacker manages to get their own little piece of code (usually JavaScript, the language web pages use to make things happen in your browser) into a page that other people load. When a victim opens that page, the attacker's code runs in the victim's browser, as if the website itself had written it. That code can then read things the browser holds for that site, such as cookies.
A cookie is a small piece of text that a website asks your browser to store and to send back with every request to that site. Cookies often hold a session identifier, which is like a coat-check ticket: the server gives you a number, you show it on every visit, and the server knows who you are without asking for your password each time. If an attacker can read someone's session cookie, they can often pretend to be that person.
In this case the researcher found, within minutes, a cookie named gp whose value was copied straight into the page that mail.ru sent back. That is the seed of an XSS: if you can put code into the cookie, the site will paste that code into its own page. The report was filed as HackerOne report 690072, and it earned a 1,000 USD bounty, which is where the title comes from.

Finding the vulnerable parameter
The researcher was browsing https://mail.ru with a tool called Burp Suite sitting between his browser and the website. Burp Suite is a program that lets you pause, look at and change the requests your browser sends and the responses the server sends back. Think of it as a transparent envelope you can open before the postman delivers the letter, and again before the recipient reads it.
To find hidden parameters, he used an extension for Burp called Param Miner, from the Burp BApp Store, written by James 'albinowax' Kettle of PortSwigger Web Security. A parameter is simply a named value that a request carries, for example ?page=2 in a URL. Many sites accept parameters that are not advertised anywhere, and Param Miner's job is to guess names in bulk (brute-force them) and see which ones the server reacts to.
After running it, the Burp issue tab listed parameters the extension had tried and found to be valid. One of them was a cookie HTTP request header called gp. A request header is a line of extra information your browser attaches to a request, such as which browser you use or which cookies you hold. This one was interesting because its value was reflected in the response to any request that contained it. "Reflected" means the server takes what you sent and writes it back into the page it returns. That is exactly the situation where XSS becomes possible: if the server copies your text into its page without cleaning it, your text can become code.

Verifying the XSS vulnerability
The researcher's stated method for testing reflected XSS is to send dangerous characters at the parameter one at a time, to work out which ones a Web Application Firewall filters out. A Web Application Firewall (WAF) is a filter that sits in front of a website and blocks requests that look malicious, a bit like a bouncer checking bags at a door. If you know which characters get through and which are stopped, you can build a payload that slips past. A payload is just the piece of text you send to try to trigger the bug.
In this case, the write-up says, there was no such filtering in the way. The first attempt put this payload into the value of the gp cookie:
<script>alert(document.cookie)</script>
Line by line, in plain words:
<script>is the HTML tag that tells a browser "everything until the closing tag is JavaScript, please run it".alert(...)is a built-in browser function that pops up a small dialog box with whatever you give it.document.cookieis the browser's way of reading the cookies that belong to the current page. If this code runs, the dialog shows the visitor's cookies, which is the classic proof that XSS works.</script>closes the script element.
So the whole payload means: "run a script that shows me this page's cookies".
He then clicked the response in Burp, chose "Show response in browser", and loaded the generated link in Firefox. He waited a few seconds, but no alert box appeared. He tried several variations over about an hour, then stopped for the day and posted the issue on a Facebook bug bounty forum to ask for help.
At that stage the request and response looked like this:
GET / HTTP/1.1 Host: mail.ru User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Cookie: gp= some alpha numeric string; Connection: close Upgrade-Insecure-Requests: 1 Cache-Control: max-age=0200 OK</script><script id="script:globals">var mr={:{BUILD:"307ad21",VERSION:1566410797,TIMESTAMP:1567848214281,TIMESTAMP_LOCAL: Date.now(),TIMEZONE:10800,AUTH:!1,CITY:"Кампала",REGION_ID:233, PAGE_ID: "15678651219031568689886875",ACC_CNT: false,MEDIA_ORDER:"regional,regional,auto,auto,lady,lady,deti,deti,health,health,sport,sport,cinema,cinema,hitech,hitech,games,games",INCUT_ORDER:"incut,stub",WIDGET_ORDER:"horo,tv,torg",FEATURE_ORDER:"auto,lady,sport,cinema,hitech,games",TARGET:"default",SITEZONE:15,SITEID:169,DEVICE:"desktop",BROWSER:"Firefox",PLATFORM:"Linux",REGION_LEVEL_ID:188,GP:"Payload gets reflected here ;",CSRF:"[redacted]",MANUAL_REGION_NOT_RUSSIA:true,HONEYPOT: '.gridmain-col .tgb, .grid .grid_main-col
What each part is doing:
GET / HTTP/1.1is the request line: "give me the front page, using version 1.1 of the HTTP protocol". HTTP is the language browsers and servers use to talk to each other.Host: mail.rusays which website the request is for. One server can host many sites, so it needs to be told which one.User-Agent: ...identifies the browser and operating system. Here it is Firefox 60 on 64-bit Linux.Accept,Accept-LanguageandAccept-Encodingtell the server what kinds of content, languages and compression the browser can handle.Cookie: gp= some alpha numeric string;is the important line. It sends the cookie namedgpwith a placeholder value. In a real attack, this is where the payload would sit.Connection: closeasks the server to close the connection after answering.Upgrade-Insecure-Requests: 1says the browser would prefer a secure (HTTPS) version of the page if one exists.Cache-Control: max-age=0asks for a fresh copy rather than a cached one.200 OKis the server's status line: the request succeeded.- Everything after that is the start of the page the server sent back. Inside it there is an inline
<script id="script:globals">block that defines a JavaScript object calledmr, holding settings such as build number, version, city, region and so on. - Near the end of that object you can see
GP:"Payload gets reflected here ;". That is the reflection: the value of thegpcookie has been pasted into a JavaScript string inside the page.
The payload landed inside an existing <script> element, in the middle of JavaScript code. The researcher later wrote that he did not understand the concept of context at the time. Context means: where exactly in the page does my input land, and what are the rules of that place? The same characters behave completely differently in HTML versus inside a script.
Closing the existing script element
The next day it occurred to him that he had to close the initial script tag first, and then introduce a new tag. He changed the payload to:
</script><script>alert(document.domain)</script>
Line by line:
</script>closes the script element that the page had already opened. The browser now thinks the JavaScript block is finished and goes back to reading ordinary HTML.<script>opens a brand new script element, which the browser will execute.alert(document.domain)pops up a dialog showing the domain of the page, for examplemail.ru.document.domainis the browser's way of reading the site's own name. Showing the domain is a common way to prove that code is really running on the target site and not somewhere harmless.</script>closes the new script element.
He fired the request again and saw the payload properly reflected in the response.

Confirming execution in the browser
Loading the response in the browser finally produced the alert box, together with the domain on which the XSS had been triggered.

Output for payload revealing user's cookies

Why it worked
The value of the gp cookie is copied into the page inside an inline script, in the GP property of the mr object. Escaping means converting characters that have a special meaning into harmless equivalents, so that user input is always treated as text and never as code. Because the injection point sits inside a script element, the only thing needed to break out is a closing </script> sequence; after that, the browser treats what follows as new markup. The write-up says no such filtering was in the way for the application. The first failed payload is a neat demonstration of why context matters: the same characters that would work in ordinary HTML do nothing inside a script.
Impact
The researcher's own assessment was that this looked like self-XSS at best. Self-XSS means the victim would have to type the malicious value into their own browser themselves, which is not much of an attack. Here the attacker has to control the victim's cookie header, and normally a website's cookies are set by the website, not by a stranger.
What raised his hopes of a reward was reading other reports in which hunters had shown Mail.ru that a man-in-the-middle attack vector could be used to deliver the attack to legitimate users, by taking advantage of vulnerable cookie parameters in the site's infrastructure. A man-in-the-middle is someone positioned on the network path between the victim and the website, for example on a shared Wi-Fi network, who can read and modify traffic that is not properly protected. If such a person can inject a cookie value, the reflected XSS turns from self-XSS into an attack on a real user.
The write-up points to a further Medium story by Max, "Сookie-based XSS exploitation | $2300 Bug Bounty story", for background on that delivery model. The final proof payload reads document.domain, while the earlier attempt read document.cookie.
Fix
The report does not describe the change that was made. The timeline records the issue as fixed on September 27, 2019, the day after the bounty was awarded.
Timeline
| Date | Event |
|---|---|
| September 7, 2019 | Reported |
| September 8, 2019 | Triaged |
| September 26, 2019 | Bounty awarded |
| September 27, 2019 | Issue fixed |
Triaged means the company's security team looked at the report, confirmed it was real and started handling it. The bounty was 1,000 USD, which gives the write-up its title.
Variants to test
- Run Param Miner (or any parameter brute-forcer) against a host and inspect the Burp issue tab for headers and cookies that are accepted and reflected. A positive result is a parameter whose value appears verbatim in the response body.
- For each reflected value, identify the surrounding context. If it lands inside an inline
<script>, try a payload that closes the element first, as here:
</script><script>alert(document.domain)</script>
Execution of the alert in a browser confirms the finding; a payload that only opens a new <script> tag will be inert in that context.
3. Test cookie-backed parameters specifically, since they are easy to overlook and, as other reports cited here show, can be set by an attacker positioned on the network path. A positive result is a cookie value that survives into the rendered page and executes.
4. When a payload fails, vary one character class at a time to map any filtering, as the author recommends, before concluding the parameter is not exploitable.
Glossary
- XSS (Cross-Site Scripting): a bug where an attacker gets their own code into a page other people load, so it runs in their browsers.
- Cookie: a small piece of text a website asks your browser to store and send back with every request to that site, often used to remember who you are.
- Session cookie: a cookie that identifies your logged-in session, like a coat-check ticket; stealing it can let someone else act as you.
- HTTP request header: an extra line of information attached to a request, such as the browser name or the cookies being sent.
- Parameter: a named value carried by a request, for example
?page=2in a URL orgp=...in a cookie. - Reflection: when a server copies something you sent straight back into the page it returns.
- Payload: the piece of text you send to try to trigger a bug.
- Burp Suite: a tool that sits between your browser and a website so you can inspect and modify requests and responses.
- Param Miner: a Burp extension that guesses hidden parameter names in bulk and reports which ones the server accepts.
- Brute-force: trying many possibilities automatically until one works.
- Web Application Firewall (WAF): a filter in front of a website that blocks requests that look malicious.
- Context: where exactly your input lands in a page (HTML text, inside a script, inside an attribute) and therefore which characters are dangerous there.
- Escaping: converting characters with special meaning into harmless equivalents so input is treated as text, not code.
<script>tag: the HTML tag that tells the browser the content until the closing tag is JavaScript to run.alert(): a browser function that shows a small dialog box with the value you give it.document.cookie: the browser's way of reading the cookies belonging to the current page.document.domain: the browser's way of reading the current page's domain name.- Self-XSS: a bug that only triggers if the victim enters the malicious value themselves, which limits its real-world impact.
- Man-in-the-middle: an attacker positioned on the network path between victim and website who can read or modify unprotected traffic.
- Triaged: the stage where a company's security team confirms a report is valid and starts handling it.
- Bounty: a reward, usually money, paid for a valid security report.