[accounts.reddit.com] Redirect parameter allows for XSS
The login page's destination parameter accepted a javascript: URL, so after signing in the browser ran attacker-supplied script in the site's origin. An attacker could trick a user into following a crafted link and, once the user logged in, execute script to steal cookies.
- Triaged in 4 hours
- Fixed in 2 days
- Paid in 2 days
- Disclosed after 22 days
Summary:
Hello team! I was tampering with the dest parameter in accounts.reddit.com and found out it is vulnerable to Cross Site Scripting once the victim performs the log in.
Steps To Reproduce:
- Enter to the following link:
https://accounts.reddit.com/?dest=javascript:alert(document.domain)
- If not signed in, the user will be promped to log in and after doing so XSS will excecute

- If user is logged into his account, following the link will also make the XSS pop up

Impact
An attacker could trick users into executing XSS, executing code and stealing their cookies only by them logging in.
What the report shows
The target is accounts.reddit.com, Reddit's account and login front end. The feature in question is the dest parameter, which the report describes as a redirect parameter: the value that tells the login flow where to send the user afterwards. The researcher was tampering with that parameter and found that it is vulnerable to Cross Site Scripting once the victim logs in.
The whole reproduction is a single URL:
https://accounts.reddit.com/?dest=javascript:alert(document.domain)
The report gives two paths through the flow, depending on the victim's session state:
- If the user is not signed in, following the link prompts them to log in. After they do so, the XSS executes.
- If the user is already signed into their account, following the link makes the XSS pop up straight away.


The outcome recorded for the report is a high severity rating, a weakness classified as generic Cross-site Scripting, and a bounty of 5,000 USD. The text does not describe a fix.
Root cause
A plausible explanation is that the dest value is carried through the login flow and then used as a navigation target without validating its scheme. A javascript: URI is not a web address in the usual sense: it is a script that the browser runs in the context of the page that navigates to it. If the application takes the attacker-supplied dest string and hands it to a redirect or location assignment after authentication, the browser treats the javascript: prefix as code rather than as a destination. The fact that the payload fires after login suggests the value is passed through the authentication step and consumed on the post-login redirect.
Impact
As the report puts it, an attacker could trick users into executing XSS, executing code and stealing their cookies, and the only action required from the victim is logging in. Because the script runs in the origin of accounts.reddit.com, it can act with that origin's privileges, including reaching session material that is not protected from script access. The report frames cookie theft as the goal.
How this kind of bug works
Redirect parameters exist so that an application can send a user somewhere useful after an action such as login. The safe way to use them is to treat the value as untrusted input and constrain it: allow only relative paths, or only absolute URLs whose scheme and host match an allowlist. When that constraint is missing, the value flows into a sink. The dangerous sinks are navigation APIs and markup that accept a URL, because browsers interpret some schemes as executable content. javascript: is the classic case: assigning it to location, passing it to window.open, or placing it in an href causes the browser to evaluate the remainder as script in the current origin.
The login flow adds a wrinkle. Many applications validate or normalise the destination at the point where the link is first received, but then persist it (in a hidden form field, a cookie, a server-side session, or a query string carried through the identity provider) and use it again after authentication. A check that happens on the first request does not help if the second use skips it. This is why a payload can appear inert when you test it while signed out and then fire once you complete the login.
The defences that stop this class are scheme and host allowlisting on every use of the value, not just the first; rejecting anything that is not a relative path or an approved absolute URL; and, as a backstop, a Content Security Policy that does not permit inline script execution. Output encoding helps where the value lands in HTML, but it does not help when the value is used as a navigation target, so validation at the sink is the primary control.
How to test for it
- Map every parameter that looks like a destination: names such as
dest,redirect,return,next,continue,url,callbackandreturnUrl. Look on login, logout, registration, password reset, email confirmation and OAuth flows. - For each one, first confirm the parameter is actually used: send a benign absolute URL to a host you control and see whether the browser is sent there after the flow completes.
- Then test scheme handling. Send a
javascript:value whose body is a harmless marker, such as an alert of the document domain, and complete the flow both while signed out (logging in) and while signed in. Watch whether the marker executes. - Test the same value at every stage: on the initial request, after any intermediate consent or identity-provider page, and on the final redirect. A value that is rejected early may still be consumed late.
- Try encoding variations of the scheme (mixed case, percent-encoding, leading whitespace or control characters) to see whether a filter is applied inconsistently between the check and the sink.
A positive result is script execution in the target origin, demonstrated by the marker firing. Common false positives are a value that is reflected into the page but never used for navigation, a redirect that only accepts relative paths and silently drops the rest, and a payload that fires only in your own browser because of an extension or a cached page. Confirm the execution happens in a clean profile and in the target's origin before reporting.
How it is fixed
- Validate the destination against an allowlist of schemes and hosts at the point of use, after login as well as before it. Prefer relative paths only.
- Reject or strip values that do not parse as an approved absolute URL, rather than trying to blocklist dangerous schemes.
- Do not persist the raw value across the authentication boundary without re-validating it when it is consumed.
- Add a Content Security Policy that disallows inline script as defence in depth.
Hunting notes
Destination parameters cluster around authentication and account lifecycle flows, because those flows need to return users to where they started. Identity-provider round trips are especially fertile: the value often travels through several systems, and each hop is a chance for validation to be dropped. Recon signals include login pages that echo a dest or return value in a hidden field, redirects that survive a full sign-in, and any flow where the final landing page differs based on a query parameter you supplied earlier.
To make a report land, show the full flow rather than a single request: the link you send, the login step, and the execution in the target origin. State which session state is required, since a payload that only fires after login is easy for a triager to miss. A screenshot or short recording of the marker firing, plus the exact URL, is usually enough to establish impact.
What happened, in plain words
Reddit has a separate website for logging in, at accounts.reddit.com. When you sign in there, the site needs to know where to send you afterwards. It keeps that destination in a part of the web address called the dest parameter. Think of it like a coat check ticket: you hand over a number, and later the staff fetch the coat that matches it. Here, the "coat" is the page you land on after logging in.
The researcher, dvorakxl, was tampering with the dest parameter and found it vulnerable to Cross Site Scripting once the victim logs in. JavaScript is the programming language that web pages run inside your browser. When a browser is told to go to a javascript: address, it does not travel to a new page: it runs whatever comes after the colon as code, in the context of the page that sent it there. That is the bug class called Cross Site Scripting, or XSS: getting your own code to run inside someone else's website, with that website's permissions.
The whole reproduction is one URL:
https://accounts.reddit.com/?dest=javascript:alert(document.domain)
Reading it piece by piece:
https://accounts.reddit.com/is the login site.?starts the list of parameters, the extra instructions attached to the address.dest=names the parameter and gives it a value.javascript:alert(document.domain)is the value.javascript:tells the browser this is code, not a place.alert(...)opens a small pop-up box.document.domainis the current site's name, so the pop-up proves which site the code is running on.
The report describes two situations, depending on whether the victim is already logged in:
- If the user is not signed in, opening the link shows them the login page. After they log in, the XSS runs.
- If the user is already signed in, opening the link makes the XSS pop up immediately.


Why does the login step matter? The report shows the code runs after the user logs in, which suggests the dest value is carried through the sign-in process and acted on when sending the user onward afterwards.
The impact is that an attacker could trick users into running the attacker's code, and stealing their cookies, with the only action required being a normal login. A cookie is a small piece of data a website asks your browser to store and send back with every request, and it is often what keeps you logged in. If code running on the login site can read a cookie, it can potentially take over the session. The report records a high severity rating, a weakness classified as generic Cross-site XSS, and a bounty of 5,000 USD.
In general, how this kind of bug works
Redirect parameters exist so a site can send you somewhere useful after an action such as logging in. The safe way to handle them is to treat the value as untrusted, because anyone can type anything into a URL. A site should allow only relative paths, or only full addresses whose scheme (the https part) and host (the domain name) are on an approved list.
When that check is missing, the value reaches a place where it is acted on. Browsers treat some schemes as executable content rather than as destinations, and javascript: is the classic example. Handing a javascript: value to a navigation function makes the browser run the rest as code on the current site.
The login flow makes this trickier. Many sites check the destination when the link first arrives, then store it (in a hidden form field, a cookie, or the session) and use it again after authentication. A check on the first request is useless if the second use skips it. That is why a payload can look harmless while you are signed out and then fire once you log in.
The defences are: check the destination against an allowlist of schemes and hosts every time it is used, not just the first; reject anything that is not a relative path or an approved address; and, as a backstop, use a Content Security Policy, a set of browser rules that can forbid inline script from running at all.
If you want to look for this yourself, here is a beginner-friendly approach:
- Look for parameters whose names suggest a destination:
dest,redirect,return,next,continue,url,callback,returnUrl. Check login, logout, registration, password reset and email confirmation pages. - Confirm the parameter is actually used: put in an ordinary address and see whether the browser really goes there after the flow finishes.
- Then try a
javascript:value with a harmless marker, such as the alert of the document domain used here, and complete the flow both signed out and signed in. Watch whether the marker runs. - Try the same value at every stage: the first request, any middle page, and the final redirect. A value rejected early may still be used late.
- Try variations of the scheme, such as different capitalisation or encoded characters, to see whether the filter is applied inconsistently.
A real finding is script running on the target's own site, shown by the marker firing. Common false alarms are a value that appears on the page but is never used to navigate, a redirect that only accepts relative paths and quietly drops the rest, and a pop-up that only appears in your own browser because of an extension or a cached page. Test in a clean browser profile before reporting.
Glossary
- Parameter: an extra instruction attached to a URL after a
?, written as a name and a value. - Redirect parameter: a parameter that tells a site where to send the user next.
- JavaScript: the programming language that runs inside web pages in your browser.
javascript:scheme: a URL form that makes the browser run the text after the colon as code instead of visiting a page.- Cross Site Scripting (XSS): getting attacker-written code to run inside another website, with that site's permissions.
- Origin: the combination of scheme, host and port that a browser uses to decide what a page is allowed to access.
- Cookie: a small piece of data a site asks the browser to store and send back with requests, often used to keep you logged in.
- Session: the logged-in state a site keeps for you, usually tied to a cookie or token.
- Token: a value used to prove identity or permission, often stored in a cookie or sent with requests.
- Sink: a place in code where a value is acted on, such as a navigation function, where dangerous input can do damage.
- Allowlist: a list of values that are explicitly permitted, with everything else rejected.
- Scheme: the first part of a URL, such as
httpsorjavascript, that says how to interpret the rest. - Host: the domain name part of a URL, such as
accounts.reddit.com. - Content Security Policy (CSP): browser rules set by a site that restrict what scripts may run.
- Payload: the crafted value an attacker sends to trigger a bug.
- Bounty: a reward paid by a company for a valid security report.