Skip to content
XSS Write-up Beginner

Reflected XSS on a Public Program

A reflected cross-site scripting flaw existed in the OAuth login endpoint of account.my.games, where an extra parameter containing a script tag was reflected in the HTTP response. An attacker could craft a link that executes script in the victim's browser, though the text notes no access token was reflected at the time.

Naveen J Follow

Published on thevillagehacker.medium.com

Hi all, My name is Naveen J AKA thevillagehacker and this is my very first write-up and I thought I should contribute some resources to the community.

Naveen J, on thevillagehacker.medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

This is a first write-up by Naveen J (@thevillagehackr), describing a reflected XSS he found while hunting on a public HackerOne program. The target was https://lootdog.io/, chosen from the mailru program on HackerOne, which the author describes as having a large scope.

Lootdog uses https://account.my.games as its OAuth service. When a user clicks login on lootdog.io, they are redirected to account.my.games, which lets them authenticate if they have a legitimate account. The login URL carries a continue parameter whose value is itself an OAuth authorisation URL on account.my.games, containing a nested redirect_uri pointing back to https://lootdog.io/social/complete/o2mygames/, along with client_id=lootdog_io, response_type=code and the social signup options.

Setup

The author does not describe any special accounts or roles. The work was done by intercepting the login request from lootdog.io, sending it to a repeater tool, and observing how the OAuth flow behaves. The request shown carries a Firefox 73 user agent on Linux x86_64, which is the only version information in the report.

Finding it

After about an hour of recon, the author found what he calls an unintended behaviour in the OAuth request and decided to explore it. The stated goal was to check for reflected XSS or open redirect issues that could be used to grab the OAuth token and take over a user's account.

Exploitation

Step 1: add a parameter to the login request

The author appended an extra parameter at the end of the keyed value on the request:

Text
&Set-Cookie: <script>alert(“Hacked By Deathstroke”)</script>

This is a parameter named Set-Cookie whose value is a script tag. The name mimics a response header, but here it is simply part of the query string being sent to the OAuth login endpoint.

Step 2: build the crafted URL

The resulting URL, as given in the report, is:

Text
https://account.my.games//oauth2/login/?continue=https%3A%2F%2Faccount.my.games%2Foauth2%2F%3Fredirect_uri%3Dhttps%253A%252F%252Flootdog.io%252Fsocial%252Fcomplete%252Fo2mygames%252F%26client_id%3Dlootdog_io%26response_type%3Dcode%26signup_social%3Dmailru%2Cfb%2Cok%2Cvk%2Cg%2Ctwitch%2Ctw%26signup_method%3Demail%252Cphone%26lang%3DEN&client_id=lootdog_io&lang=EN&signup_method=email%2Cphone&signup_social=mailru%2Cfb%2Cok%2Cvk%2Cg%2Ctwitch%2Ctw&Set-Cookie: <script>alert("Hacked By Deathstroke")</script>

The continue parameter is double-encoded and wraps the whole OAuth authorisation URL for account.my.games, which in turn carries the lootdog.io redirect_uri and the client parameters. The payload sits at the very end, after the legitimate client_id, lang, signup_method and signup_social parameters.

Step 3: send the request

The request was sent as follows:

HTTP
GET /oauth2/login/?continue=https%3A%2F%2Faccount.my.games%2Foauth2%2F%3Fredirect_uri%3Dhttps%253A%252F%252Flootdog.io%252Fsocial%252Fcomplete%252Fo2mygames%252F%26client_id%3Dlootdog_io%26response_type%3Dcode%26signup_social%3Dmailru%2Cfb%2Cok%2Cvk%2Cg%2Ctwitch%2Ctw%26signup_method%3Demail%252Cphone%26lang%3DEN&client_id=lootdog_io&lang=EN&signup_method=email%2Cphone&signup_social=mailru%2Cfb%2Cok%2Cvk%2Cg%2Ctwitch%2Ctw&Set-Cookie: <script>alert("Hacked By Deathstroke")</script> HTTP/1.1 Host: account.my.games User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: https://lootdog.io/ Connection: close

The request goes to account.my.games on the /oauth2/login/ path, with the Referer set to lootdog.io, matching a user who started the login from the lootdog site.

Step 4: observe the response

The response came back as:

HTTP
<script>alert("Hacked By Deathstroke")</script> HTTP/1.0 200 OK Content-Type: text/html; charset=utf-8 X-Frame-Options: SAMEORIGIN Content-Length: 3982 Vary: Origin

The payload appears reflected at the start of the response body, ahead of the status line as the report presents it, with a 200 status and an HTML content type. The author notes that no access token was reflected in the response at that time, but reported the issue anyway because it could lead to other security threats.

Step 5: proof of concept

The report includes two screenshots as proof. The first shows the payload reflected in the HTTP response:

The second shows the report as it was submitted to HackerOne:

Root cause

The report does not analyse the server-side code. What it shows is that the value supplied in the request is echoed back in the HTML response, so a script tag placed in the query string appears in the response. The X-Frame-Options: SAMEORIGIN header on the response addresses framing, not reflection, so it has no bearing on the reflected payload. The exact encoding or filtering mistake is not described.

Impact

The author's original aim was to obtain an OAuth token and take over a user's account, but no access token was reflected in the response at the time of testing. The demonstrated effect is the payload reflected in the HTML response from the OAuth login page, which the author reported on the basis that it may cause other security threats. The report does not establish account takeover.

Fix

The report does not say what change was made. It states that the HackerOne analyst verified the vulnerability, the report was triaged after some discussion, the issue was resolved, and the author received a hall of fame entry.

Variants to test

  1. Put a script payload in the continue parameter of an OAuth login endpoint and check whether it is reflected unencoded in the returned HTML. A positive result is the payload appearing verbatim in the response body with an HTML content type.
  2. Try the same on nested redirect parameters such as redirect_uri, including double-encoded values, since these are often decoded and re-emitted. A positive result is the decoded payload appearing in the page rather than staying percent-encoded.
  3. Add unexpected parameter names that resemble headers, as done here with Set-Cookie, and see whether the server echoes unknown parameters into the response. A positive result is the parameter value rendered into the HTML.
  4. Test whether the reflection lands inside an attribute, a script block or plain HTML, since that determines which payload form executes. A positive result is execution confirmed in a browser, not just reflection in the raw response.
  5. Check whether the OAuth flow reflects the token or code anywhere in the page, which would raise the impact from script execution to token theft. A positive result is a token or code visible in the response body.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 15 min read.

What happened, in plain words

A security researcher called Naveen J (@thevillagehackr) was learning how to hunt for bugs. He picked a public program on HackerOne, a website where companies invite people to test their systems and report problems. The target he chose was https://lootdog.io/, a site belonging to the mailru program, which he describes as having a large scope. Scope means the list of things a company says you are allowed to test.

Lootdog lets people log in through another service, https://account.my.games. This is called OAuth: instead of giving lootdog your password, lootdog sends you to account.my.games, you log in there, and account.my.games sends you back to lootdog with proof that you logged in. A useful comparison is a members' club that accepts a guest pass issued by a partner hotel: the club never sees your hotel password, only the pass.

While looking at how that login hand-off worked, Naveen found that the login page would repeat back, in its response, text that he put into the address. If that repeated text is a script and the page does not neutralise it, the browser runs it. That is reflected cross-site scripting, or reflected XSS: a page reflects input from the request back to the user without neutralising it, and a script hidden in the input executes as if the site itself had written it.

He reported it, a HackerOne analyst verified it, the report was triaged after some discussion, the issue was resolved, and he received a hall of fame entry. This was his first write-up and his first vulnerability.

The pieces involved

Before following the steps, here are the parts of the picture, explained from zero.

  • A URL and its query string. A web address can carry extra information after a ?, in the form name=value pairs joined by &. For example, ?lang=EN tells the page the language is English. This part is called the query string, and each name=value pair is a parameter.
  • Percent-encoding. Some characters cannot appear literally in a URL, so they are written as a percent sign and two hex digits. A space becomes %20, a colon becomes %3A, a slash becomes %2F. When a value is encoded twice, the percent signs themselves get encoded, so %3A becomes %253A. This is called double encoding, and it matters here because the continue parameter is double-encoded.
  • An HTTP request and response. Your browser sends a request to a server and the server sends back a response. The request has a method (here GET, meaning give me this page), a path, headers (extra lines of information such as which browser you use), and sometimes a body. The response has a status code (200 means OK), headers, and a body, which for a web page is HTML.
  • A cookie and a token. A cookie is a small piece of data a site asks your browser to store and send back on later requests, so the site can recognise you. A token is a string that stands in for your logged-in session or grants access, a bit like a cloakroom ticket: whoever holds it can collect the coat. Stealing a token often means taking over the account.
  • An OAuth token and authorisation code. In OAuth, after you log in at the identity provider (here account.my.games), it hands the application (here lootdog.io) a short-lived code or token that proves you authenticated. The response_type=code parameter in the URLs below asks for that code.
  • A redirect. A server can answer a request by telling the browser to go somewhere else. An open redirect is when a site will send you to any address an attacker supplies, which can be abused for phishing or for leaking tokens.
  • A repeater tool. A tool that lets you capture a request your browser made, edit it, and send it again as many times as you like, then read the raw response. It is like being able to rewrite a letter before posting it and read the reply in full.
  • A reflected XSS. The site takes something from your request and prints it into the page it returns. If the printed text is a <script> tag, the browser treats it as code and runs it. The script runs with the site's own privileges, in the site's origin, so it can read what the site can read.

Motivation and target

Naveen says he wanted to become a good hunter, so he started with low-hanging fruit, meaning the easier classes of bug, and chose to look for XSS on a public HackerOne program. He picked https://lootdog.io/ from the mailru program because of its large scope. After about an hour of reconnaissance (looking around, mapping how the site works), he noticed what he calls an unintended behaviour in the OAuth request and decided to explore it.

How the login flow works

He intercepted the login request from https://lootdog.io/ and sent it to a repeater, then watched how the OAuth flow behaved. Lootdog uses https://account.my.games as its OAuth service: when you click login on lootdog, you are redirected to account.my.games, which lets you log in if you have a legitimate account there.

The login URL carries a continue parameter whose value is itself an OAuth authorisation URL on account.my.games. In this case that address is itself an OAuth authorisation URL on account.my.games, and inside it sits a redirect_uri pointing back to https://lootdog.io/social/complete/o2mygames/, together with client_id=lootdog_io, response_type=code and the social signup options. So the URL is nested: a return address that contains another return address.

His stated goal was to check for reflected XSS or open redirect issues that could be used to grab the OAuth token and take over a user's account. In other words, his aim was to make the login page run his script, or make it send the token somewhere he controlled, so that he could end up with someone else's session.

Step 1: add an extra parameter to the login request

He appended an extra parameter at the end of the keyed value on the request:

Text
&Set-Cookie: <script>alert(“Hacked By Deathstroke”)</script>

Line by line:

  • The leading & joins this new piece onto the query string that is already there, the same way &lang=EN joins parameters in a normal URL.
  • Set-Cookie: is the name part of the parameter. It is deliberately chosen to look like an HTTP response header, the kind of line a server uses to set a cookie. Here it is not a header at all: it is just text in the query string being sent to the OAuth login endpoint. The idea is to see whether the server echoes unknown or header-like parameter names back into the page.
  • <script>alert(“Hacked By Deathstroke”)</script> is the value. <script> opens a script block in HTML, alert(...) asks the browser to show a pop-up box with the text inside the quotes, and </script> closes the block. If this text lands in the returned HTML unescaped, the browser runs it and the pop-up appears. The pop-up is the classic harmless proof that script execution happened.

Why this step: the goal was to see whether the login page would repeat back a value he supplied. A pop-up is the simplest visible signal that it did.

Step 2: build the crafted URL

The resulting URL, as given in the report, is:

Text
https://account.my.games//oauth2/login/?continue=https%3A%2F%2Faccount.my.games%2Foauth2%2F%3Fredirect_uri%3Dhttps%253A%252F%252Flootdog.io%252Fsocial%252Fcomplete%252Fo2mygames%252F%26client_id%3Dlootdog_io%26response_type%3Dcode%26signup_social%3Dmailru%2Cfb%2Cok%2Cvk%2Cg%2Ctwitch%2Ctw%26signup_method%3Demail%252Cphone%26lang%3DEN&client_id=lootdog_io&lang=EN&signup_method=email%2Cphone&signup_social=mailru%2Cfb%2Cok%2Cvk%2Cg%2Ctwitch%2Ctw&Set-Cookie: <script>alert("Hacked By Deathstroke")</script>

Reading it in pieces:

  • https://account.my.games//oauth2/login/? is the address of the login page on the identity provider, followed by the ? that starts the query string. Note the double slash after the host name, exactly as in the report.
  • continue= starts the return-address parameter. Its value is percent-encoded, so the inner URL's : and / appear as %3A and %2F.
  • Inside that encoded value, redirect_uri%3Dhttps%253A%252F%252Flootdog.io%252Fsocial%252Fcomplete%252Fo2mygames%252F is the inner return address pointing back to lootdog. The %253A and %252F are double-encoded colons and slashes, because this value is nested one level deeper.
  • client_id%3Dlootdog_io identifies which application is asking, here lootdog.
  • response_type%3Dcode asks for an authorisation code rather than a token directly.
  • signup_social%3Dmailru%2Cfb%2Cok%2Cvk%2Cg%2Ctwitch%2Ctw lists the social signup options, separated by encoded commas (%2C).
  • signup_method%3Demail%252Cphone lists the signup methods, again double-encoded.
  • lang%3DEN sets the language to English.
  • After the encoded continue value ends, the URL repeats the same parameters unencoded at the top level: &client_id=lootdog_io&lang=EN&signup_method=email%2Cphone&signup_social=mailru%2Cfb%2Cok%2Cvk%2Cg%2Ctwitch%2Ctw.
  • Finally &Set-Cookie: <script>alert("Hacked By Deathstroke")</script> is the payload, sitting at the very end, after all the legitimate parameters.

Why this step: this is the exact address that, when opened or requested, carries the payload into the login page. Building it by hand makes it easy to see where the payload sits relative to the legitimate parameters.

Step 3: send the request

The request was sent as follows:

HTTP
GET /oauth2/login/?continue=https%3A%2F%2Faccount.my.games%2Foauth2%2F%3Fredirect_uri%3Dhttps%253A%252F%252Flootdog.io%252Fsocial%252Fcomplete%252Fo2mygames%252F%26client_id%3Dlootdog_io%26response_type%3Dcode%26signup_social%3Dmailru%2Cfb%2Cok%2Cvk%2Cg%2Ctwitch%2Ctw%26signup_method%3Demail%252Cphone%26lang%3DEN&client_id=lootdog_io&lang=EN&signup_method=email%2Cphone&signup_social=mailru%2Cfb%2Cok%2Cvk%2Cg%2Ctwitch%2Ctw&Set-Cookie: <script>alert("Hacked By Deathstroke")</script> HTTP/1.1 Host: account.my.games User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: https://lootdog.io/ Connection: close

Line by line:

  • GET /oauth2/login/?... is the request line: the method GET, the path /oauth2/login/ on the server, and the full query string including the payload. GET means "give me this page".
  • HTTP/1.1 states the version of the protocol being used.
  • Host: account.my.games tells the server which site name the request is for. One server can host many sites, so this line picks the right one.
  • User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0 identifies the browser and system that made the request: Firefox 73 on 64-bit Linux. This is the only version information in the report.
  • Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 says which content types the client will accept, with rough preferences.
  • Accept-Language: en-US,en;q=0.5 says the client prefers US English.
  • Accept-Encoding: gzip, deflate says the client can accept compressed responses.
  • Referer: https://lootdog.io/ says the request was started from the lootdog site, matching a user who clicked login there. (The header name is spelled Referer in the protocol, a long-standing misspelling of "referrer".)
  • Connection: close asks the server to close the connection after this response.

Why this step: sending the request exactly as a browser would, with the same headers, shows how the server behaves for a real visitor who followed the crafted link, not just for a bare tool.

Step 4: observe the response

The response came back as:

HTTP
<script>alert("Hacked By Deathstroke")</script> HTTP/1.0 200 OK Content-Type: text/html; charset=utf-8 X-Frame-Options: SAMEORIGIN Content-Length: 3982 Vary: Origin

Line by line:

  • <script>alert("Hacked By Deathstroke")</script> appears at the start of the response as the report presents it, ahead of the status line. That is the payload reflected back: the server printed the value from the request into the response body.
  • HTTP/1.0 200 OK is the status line: the server speaks HTTP/1.0 and the request succeeded (200 means OK).
  • Content-Type: text/html; charset=utf-8 says the body is an HTML page encoded in UTF-8. This matters because a browser only runs a <script> tag when it treats the content as HTML.
  • X-Frame-Options: SAMEORIGIN is a header that controls whether other sites may embed this page in a frame. It addresses framing, not reflection, so it has no bearing on the reflected payload.
  • Content-Length: 3982 gives the size of the body in bytes.
  • Vary: Origin tells caches that the response can differ depending on the Origin request header.

The author notes that no access token was reflected in the response at that time, but he reported the issue anyway because it could lead to other security threats. In plain terms: the payload was reflected in the response, but the bigger prize he was after, a token that would let him take over an account, did not appear in this response.

Step 5: proof of concept

The report includes two screenshots as proof. The first shows the payload reflected in the HTTP response:

Seems that the payload worked, which is reflected on the HTTP response.

The second shows the report as it was submitted to HackerOne:

He says it was his first vulnerability, so he quickly created a report and sent it to HackerOne. The HackerOne analyst verified the vulnerability and triaged the report after some discussions, the issue was resolved, and he was rewarded a hall of fame entry.

Why it worked

The report does not analyse the server-side code. What it shows is that the value supplied in the request is echoed back in the HTML response, so a script tag placed in the query string appears in the response. Neutralising, in this context, means turning characters like < and > into harmless text so the browser displays them instead of treating them as markup. The exact encoding or filtering mistake is not described.

What the impact was, and was not

The author's original aim was to obtain an OAuth token and take over a user's account, but no access token was reflected in the response at the time of testing. The demonstrated effect is the payload reflected in the HTML response from the OAuth login page, which he reported on the basis that it may cause other security threats. The report does not establish account takeover.

How it was fixed

The report does not say what change was made. It states that the HackerOne analyst verified the vulnerability, the report was triaged after some discussion, the issue was resolved, and the author received a hall of fame entry.

Variants to test

If you want to look for similar issues on programs you are allowed to test, these are the directions the technical version lists:

  1. Put a script payload in the continue parameter of an OAuth login endpoint and check whether it is reflected unencoded in the returned HTML. A positive result is the payload appearing verbatim in the response body with an HTML content type.
  2. Try the same on nested redirect parameters such as redirect_uri, including double-encoded values, since these are often decoded and re-emitted. A positive result is the decoded payload appearing in the page rather than staying percent-encoded.
  3. Add unexpected parameter names that resemble headers, as done here with Set-Cookie, and see whether the server echoes unknown parameters into the response. A positive result is the parameter value rendered into the HTML.
  4. Test whether the reflection lands inside an attribute, a script block or plain HTML, since that determines which payload form executes. A positive result is execution confirmed in a browser, not just reflection in the raw response.
  5. Check whether the OAuth flow reflects the token or code anywhere in the page, which would raise the impact from script execution to token theft. A positive result is a token or code visible in the response body.

Glossary

  • API: a defined way for one piece of software to talk to another, like a service counter with set questions and answers.
  • Authorisation code: a short-lived value an OAuth identity provider gives an application to prove the user logged in.
  • Client ID: a public identifier for an application in OAuth, here lootdog_io.
  • Cookie: a small piece of data a site stores in your browser and receives back on later requests, used to recognise you.
  • Double encoding: percent-encoding a value that is already percent-encoded, so %3A becomes %253A.
  • GET: an HTTP method meaning "give me this resource".
  • HackerOne: a platform where companies run bug bounty and vulnerability disclosure programs and researchers report issues.
  • Hall of fame (HOF): a public list of researchers a company thanks for their reports.
  • Header: an extra line in an HTTP request or response carrying information such as content type or browser identity.
  • HTML: the markup language web pages are written in; <script> tags in it contain code the browser runs.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • Identity provider: the service that checks your login on behalf of another site, here account.my.games.
  • OAuth: a way to log in to one site using an account at another, without sharing your password with the first site.
  • Open redirect: a bug where a site will send a visitor to any address an attacker supplies.
  • Origin: the combination of scheme, host and port that a browser uses to decide which pages may access each other's data.
  • Parameter: a name=value pair in a URL's query string.
  • Payload: the piece of input an attacker supplies to trigger a bug, here the script tag.
  • Percent-encoding: writing characters in a URL as % plus two hex digits.
  • Query string: the part of a URL after ?, made of parameters joined by &.
  • Reconnaissance: exploring a target to map its features before testing.
  • Redirect: a server telling the browser to go to a different address.
  • Redirect URI: the address an OAuth provider sends the user back to after login.
  • Reflected XSS: XSS where the payload comes back in the immediate response to the request that carried it.
  • Repeater: a tool for capturing, editing and resending HTTP requests and reading the raw responses.
  • Request: the message a browser sends to a server asking for something.
  • Response: the message a server sends back, with a status code, headers and a body.
  • Scope: the list of systems and features a program allows researchers to test.
  • Script: code a browser executes, usually written in JavaScript and placed in a <script> tag.
  • Session: the state of being logged in, usually represented by a cookie or token.
  • Status code: a number in an HTTP response saying how the request went, such as 200 for OK.
  • Token: a string that stands in for a session or grants access; stealing one can mean account takeover.
  • Triaged: a report that a program has reviewed and accepted as a valid issue.
  • User-Agent: a request header identifying the browser and system that made the request.
  • UTF-8: a character encoding for text used widely on the web.
  • Vary: a response header telling caches which request headers change the response.
  • X-Frame-Options: a response header controlling whether a page may be embedded in a frame by other sites.

More by Naveen J

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.