My First XSS
An OAuth login page accepted a loginUrl parameter that redirected to an arbitrary domain, and by injecting a javascript: scheme with encoded newlines the author achieved script execution that read document.cookie. An attacker could redirect users to a malicious site and potentially steal cookies via the crafted link.
Published on medium.com
Hey everyone, I am SYRINE. Cyber Security Enthusiast, eJPT Certified, and currently focusing on bug bounty.
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 the story of a first cross-site scripting finding, made on a private program on HackerOne. The program is referred to in the write-up as nooneknowsme.com, which the author states plainly is not its real name. The feature involved is an OAuth flow: a directory named oauth on the target, which returns an OAuth error page when the visitor is not logged in. That error page carries a loginUrl parameter in the URL, which normally tells the application where to send the user when they press the login button.

The author introduces themselves as Syrine, a cyber security enthusiast with the eJPT certification who is focusing on bug bounty work.
Setup
The only precondition described is access to the private program, which arrived as an invitation. No account, role or version information is given. The tools used were directory busting to discover the oauth directory and Burp Suite to try payloads. The author also used a payload list called XSS-through-open-redirection-payloads.txt, and suggests finding it by searching online rather than providing it.
Finding it
Directory busting turned up the oauth directory. Visiting it produced an OAuth error, because the page expects a logged-in user and the author was not logged in. The URL contained the parameter:
loginUrl=http://nooneknowsme.com/login
The first thing that came to mind was open redirection, so the value was changed to point at another domain:
loginUrl=http://evil.com
Pressing the login button then redirected the browser to evil.com. That confirmed the open redirect on its own.

Exploitation
Step 1: confirm the open redirect
With loginUrl set to an external domain, the login button sent the browser to that domain. The parameter is therefore used as a redirect destination without being restricted to the application's own origin.
Step 2: try to turn the redirect into script execution
Rather than submit the redirect alone, the author decided to raise the severity by attempting XSS through the open redirection. Burp was used together with the XSS-through-open-redirection-payloads.txt list. The author notes they were close to closing Burp after getting nothing, and then a payload worked:
java%0D%0Ascript%0D%0A%3aalert(document.cookie)

The payload is a javascript: scheme broken up with encoded carriage return and line feed characters (%0D%0A) and an encoded colon (%3A). Decoded, the scheme reads java, then CRLF, then script, then CRLF, then :alert(document.cookie). The payload splits the javascript: scheme with encoded line breaks and an encoded colon; the write-up does not explain why this form worked. Because the code is alert(document.cookie) rather than alert(1), the popup displays the victim's cookies, which demonstrates that the payload runs in the target's origin with access to its session data.
The author adds a tip: if you get XSS with alert(1) and are about to report it, stop, because there is probably XSS but it may not be impactful. Try alert(document.cookie) instead; if it shows your cookie, as it did here, the XSS is impactful.
Step 3: submit
The author expected a high bounty but the report came back as a duplicate. No bounty amount, severity rating or CVSS score is given.
Root cause
The loginUrl parameter is taken from the URL and used as the destination of the login redirect without being validated against the application's own origin, which is what allows an arbitrary external domain. The same value is then handed to the browser in a context where a javascript: URI is followed, so the redirect becomes script execution in the target's origin. The write-up does not describe any server-side check or explain why the encoded payload succeeded.
Impact
An attacker who can get a victim to open a crafted oauth URL and press the login button can run JavaScript in the target's origin and read the victim's cookies, as demonstrated by alert(document.cookie). The write-up does not go further into what an attacker could do with those cookies, which accounts are affected, or whether any interaction beyond clicking login is needed. The author decided to try for XSS through the open redirect to increase the severity.
Fix
The measures implied by the finding are to restrict loginUrl to relative paths or an allowlist of the application's own origins, and to reject or neutralise values that resolve to a javascript: URI after decoding, rather than matching on the raw string.
Variants to test
- Look for redirect parameters on login, logout and OAuth error pages (
loginUrl,returnUrl,redirect_uri,next) and point them at an external domain. A positive result is the browser leaving the site for that domain after the relevant button is pressed. - Feed the same parameters the split-scheme payload shown above, with
%0D%0Abetween the parts ofjavascriptand%3Afor the colon. A positive result is the code after the colon executing in the target's origin, best confirmed withalert(document.cookie)rather thanalert(1). - Try other encodings of the scheme, such as mixed case or extra whitespace and control characters, against the same parameter. A positive result is the same execution with the cookie value displayed.
- Where a redirect target is reflected into a page rather than used in a
Locationheader, test whether the value lands in an HTML or script context that allows direct injection. A positive result is script running without needing the redirect step at all.
A duplicate means the issue had already been reported, so it can be worth checking whether a redirect parameter has already been covered.
What happened, in plain words
A security researcher found a bug on a private bug bounty program on HackerOne. The program is called nooneknowsme.com in the write-up, but the author says clearly that this is not its real name. The bug was in a login feature that uses something called OAuth. When you visit a certain page without being logged in, the page shows an error and puts a web address in the URL bar. That address tells the site where to send you when you press the login button. The researcher changed that address to point at a different website, and the login button obediently sent the browser there. That is called an open redirect: the site will forward you to any address someone puts in the link, not just its own pages.
Then the researcher went further. Instead of a normal web address, they put a special piece of text into the same spot. When the browser followed it, it did not go to another website: it ran a small piece of JavaScript code on the target site. That code showed the visitor's cookies in a popup box. Cookies are small pieces of data a website stores in your browser, and they often include the thing that keeps you logged in. Showing them proves the code ran with the site's own permissions, which is what makes this kind of bug serious. This combination is called XSS, short for cross-site scripting, reached here through the open redirect.
The researcher submitted the report expecting a large reward, but it came back as a duplicate: somebody else had reported the same issue first. No reward amount, severity rating or score is given.

The author introduces themselves as Syrine, a cyber security enthusiast with the eJPT certification who is focusing on bug bounty work.
The pieces you need to know
Before the steps, a few everyday ideas. A URL is the address you see at the top of the browser, like http://example.com/page?name=value. The part after the question mark is the query string, and each name=value pair in it is a parameter. Parameters are how a link can carry instructions to a page: the page reads them and changes what it shows or does.
An OAuth flow is the standard way many sites let you log in with another account, or hand you over to a login page and then back again. Part of that flow is a parameter that says where to go after login. Here that parameter is called loginUrl, and normally it holds the site's own login address.
An open redirect is when a site takes such a destination from the URL and forwards you there without checking that it belongs to the site itself. It is like a receptionist who will walk you to any door in the building, including the street exit, just because the note in your hand says so.
XSS (cross-site scripting) is when an attacker manages to get their own JavaScript code to run inside a page of the target site, in the browser of whoever opens the crafted link. Because the code runs as if it came from the site, it can read things the site has stored in that browser, such as cookies.
A cookie is a small label the site sticks on your browser so it recognises you on the next request. The session cookie is effectively your logged-in badge. If someone else can read it, they may be able to act as you.
JavaScript is the programming language browsers run to make pages interactive. A javascript: address is a special kind of link: instead of going to a page, the browser runs the code written after the colon.
Burp Suite is a tool that sits between your browser and a website so you can look at and change the requests going back and forth. Directory busting means trying a list of common folder names against a site to see which ones exist, a bit like trying door handles along a corridor.
Setup
The only precondition described is access to the private program, which arrived as an invitation. No account, role or version information is given. The tools used were directory busting to discover the oauth directory and Burp Suite to try payloads. The author also used a payload list called XSS-through-open-redirection-payloads.txt, and suggests finding it by searching online rather than providing it.
Finding it
Directory busting turned up the oauth directory. Visiting it produced an OAuth error, because the page expects a logged-in user and the author was not logged in. The URL contained the parameter:
loginUrl=http://nooneknowsme.com/login
Line by line: loginUrl is the name of the parameter, the label on the instruction. The = separates the name from its value. http://nooneknowsme.com/login is the value, the site's own login page. In plain terms the URL is saying: when the login button is pressed, send the visitor to this address. The researcher's first thought was open redirection, because a parameter that holds a destination is exactly the kind of thing a site might fail to check. So the value was changed to point at another domain:
loginUrl=http://evil.com
Here only the value changed: http://evil.com is a domain that has nothing to do with the target. If the site still sends the browser there, it is not checking where the destination points. Pressing the login button then redirected the browser to evil.com. That confirmed the open redirect on its own.

Exploitation
Step 1: confirm the open redirect
With loginUrl set to an external domain, the login button sent the browser to that domain. The parameter is therefore used as a redirect destination without being restricted to the application's own origin. In everyday terms: the receptionist walked the visitor out to a stranger's building because the note said so.
Step 2: try to turn the redirect into script execution
Rather than submit the redirect alone, the author decided to raise the severity by attempting XSS through the open redirection. The reasoning: a redirect to another site is annoying, but code running on the target site can read the visitor's data, which is a bigger problem. Burp was used together with the XSS-through-open-redirection-payloads.txt list. The author notes they were close to closing Burp after getting nothing, and then a payload worked:
java%0D%0Ascript%0D%0A%3aalert(document.cookie)
Line by line, this is one value meant to be placed where the destination address goes. %0D and %0A are encoded control characters: %0D is a carriage return and %0A is a line feed, the two characters that together make a new line. %3A is an encoded colon. So the raw text is java, then a line break, then script, then a line break, then :alert(document.cookie). When the browser reads it, it reassembles the pieces into javascript: followed by the code alert(document.cookie). alert is the browser instruction that opens a popup box showing whatever is inside the brackets, and document.cookie means the cookies belonging to the current page. The popup therefore shows the visitor's cookies.
The payload splits the javascript: scheme with encoded line breaks and an encoded colon; the write-up does not explain why this form worked. The comparison: a guard reads the note and looks for the word javascript, but the note has the word split across two lines, so the guard does not recognise it, while the browser tidies the note up and reads it correctly. Because the code is alert(document.cookie) rather than alert(1), the popup displays the victim's cookies, which demonstrates that the payload runs in the target's origin with access to its session data.
The author adds a tip: if you get XSS with alert(1) and are about to report it, stop, because there is probably XSS but it may not be impactful. Try alert(document.cookie) instead; if it shows your cookie, as it did here, the XSS is impactful. The point is that alert(1) only proves a box can be opened; showing the cookie proves the code can reach the data that matters.

Step 3: submit
The author expected a high bounty but the report came back as a duplicate. No bounty amount, severity rating or CVSS score is given. A duplicate means someone else had already reported the same issue.
Root cause
The loginUrl parameter is taken from the URL and used as the destination of the login redirect without being validated against the application's own origin, which is what allows an arbitrary external domain. The same value is then handed to the browser in a context where a javascript: URI is followed, so the redirect becomes script execution in the target's origin. The write-up does not describe any server-side check or explain why the encoded payload succeeded.
Impact
An attacker who can get a victim to open a crafted oauth URL and press the login button can run JavaScript in the target's origin and read the victim's cookies, as demonstrated by alert(document.cookie). The write-up does not go further into what an attacker could do with those cookies, which accounts are affected, or whether any interaction beyond clicking login is needed. The author decided to try for XSS through the open redirect to increase the severity.
Fix
The measures implied by the finding are to restrict loginUrl to relative paths or an allowlist of the application's own origins, and to reject or neutralise values that resolve to a javascript: URI after decoding, rather than matching on the raw string. In plain terms: only accept destinations that are pages on your own site, and decode the value before checking it, so a split-up word cannot sneak past.
Variants to test
- Look for redirect parameters on login, logout and OAuth error pages (
loginUrl,returnUrl,redirect_uri,next) and point them at an external domain. A positive result is the browser leaving the site for that domain after the relevant button is pressed. - Feed the same parameters the split-scheme payload shown above, with
%0D%0Abetween the parts ofjavascriptand%3Afor the colon. A positive result is the code after the colon executing in the target's origin, best confirmed withalert(document.cookie)rather thanalert(1). - Try other encodings of the scheme, such as mixed case or extra whitespace and control characters, against the same parameter. A positive result is the same execution with the cookie value displayed.
- Where a redirect target is reflected into a page rather than used in a
Locationheader, test whether the value lands in an HTML or script context that allows direct injection. A positive result is script running without needing the redirect step at all.
A duplicate means the issue had already been reported, so it can be worth checking whether a redirect parameter has already been covered.
Glossary
- Bug bounty program: a scheme where a company invites researchers to report security bugs and may reward them.
- Private program: a bug bounty program that only invited researchers can see and report to.
- HackerOne: a platform that hosts bug bounty programs and their reports.
- eJPT: an entry-level penetration testing certification.
- URL: the address of a page in the browser.
- Query string: the part of a URL after the question mark, carrying parameters.
- Parameter: a
name=valuepair in a URL that passes an instruction to the page. - OAuth: a standard flow for logging in or handing a user to a login page and back.
- Open redirect: a bug where a site forwards the browser to any destination supplied in a parameter, without checking it.
- XSS (cross-site scripting): a bug where an attacker's JavaScript runs inside a page of the target site in a victim's browser.
- JavaScript: the programming language browsers run to make pages interactive.
javascript:URI: a link whose destination is code to run rather than a page to load.- Cookie: a small piece of data a site stores in the browser, often used to keep you logged in.
- Session cookie: the cookie that acts as your logged-in badge.
document.cookie: the browser expression that reads the current page's cookies.alert(): the browser instruction that opens a popup box showing its contents.- Payload: the crafted value an attacker sends to trigger a bug.
- Payload list: a file of ready-made payloads to try in turn.
- Burp Suite: a tool that sits between browser and website so requests can be inspected and changed.
- Directory busting: trying a list of common folder names against a site to find ones that exist.
- CRLF: carriage return plus line feed, the pair of characters that makes a new line.
- URL encoding: writing special characters as
%followed by a code, such as%0Dfor carriage return. - Decoding: turning encoded characters back into their real form.
- Normalise: tidying a value into one standard form before checking it.
- Origin: the combination of scheme, host and port that a page belongs to; code running in an origin can read that origin's data.
- Allowlist: a list of values that are explicitly permitted, with everything else rejected.
- Relative path: a destination on the same site, such as
/login, rather than a full address elsewhere. Locationheader: the part of a server response that tells the browser to go to another address.- Duplicate: a report for a bug that someone else already reported.
- Severity: how serious a bug is judged to be.
- CVSS: a standard scoring system for the severity of a vulnerability.
- Bounty: the reward a program pays for a valid report.