Jumping Over The Fence
A website's anti-open-redirect mechanism allowed redirects to any of its own subdomains without an access token, provided the referrer was the same site. By chaining a same-domain redirect with an open redirect on a mail subdomain, an attacker could redirect users to any third-party site.
Published on medium.com
Cybersecurity
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 case study is about open redirects and, more specifically, about defeating the mechanisms that sites put in place to prevent them. The author calls these mechanisms AOR, for Anti Open Redirects.
The example used throughout is Facebook's linkshim system, which the author describes as a great example of a good AOR. Linkshim attaches an access token to every URL posted on Facebook. That token is personal, so only the user who is viewing the link can click it and be redirected to the destination; others cannot. The mechanism also checks the destination for the user and prevents the user from being redirected to a malicious website.
The article was originally published on 13/09/2016 on FogMarks.com and later republished on Medium on 5 February 2019.

Setup
The author does not describe any accounts, roles, tools or versions beyond one: a domain enumeration software, which was used to detect a subdomain of the target. The target is described only as "a very popular designs website", whose name the author says he cannot reveal.
The relevant precondition is the design of the site's AOR mechanism. The site allowed "inner links" to be redirected without any access token or validation, but required the referrer to be the same domain. The AOR mechanism allowed any inner link to be redirected, as long as its domain was one of that company's domains or subdomains.
Finding it
The starting observation is about how most websites that use an AOR manage posted links: they do so only if those links point to third party websites. If a user on x.com posts a link to y.com, the link appears as:
x.com/out?url=y.com&access_token=1asd2ad6fdC
But if the user posts a link to the same domain (posting x.com/blabla on x.com), the link appears as is:
x.com/blabla
The reason, as the author explains it, is that websites usually trust themselves to redirect users within themselves. They consider it safe and pointless to attach an access token to a link that redirects the user to the same domain. The author has heard the argument "if a certain page is vulnerable to an open redirect there is no reason to check redirection to it" countless times, and sets out to change that view.
The target site had exactly this vulnerability. Inner links were redirected without any access token or validation, but the referrer had to be the same domain. The AOR mechanism allowed any inner link to be redirected as long as its domain was one of the company's domains or subdomains.
Using a domain enumeration software, the author detected a subdomain of the website that contained a mail service for the company's employees. That mail service had an open redirect vulnerability on its logout page. Even if the user was not logged in, when the logout page was accessed with a "redirect after" GET parameter, the user was redirected to any other page, including a third party website. The mail service, the author notes, does not consider this behaviour to be an open redirect vulnerability.
Exploitation
With an open redirect on a subdomain page, the remaining problem was reaching it from the main domain. The AOR mechanism allowed a link to be redirected to a subdomain, but only if the referrer was the same website.
Step 1: Identify the two vulnerable pages
The author models the situation with two pages:
Vulnerable mail service: http://mail.x.com/out?url=y.com
'Vulnerable' page within the domain: http://x.com/redirect?to=mail.x.com/out?url=y.com
The first is the mail service's logout page, which redirects to whatever its 'redirect after' GET parameter contains. The second is a page within the main domain that redirects to the value of its to parameter, and requires the referrer header to be from x.com, in the author's example.
Step 2: Redirect to the same page, then again
The author's solution was to redirect the user to the same page, and then have them redirected again. Because the second page requires the referrer to be from x.com, the author issued the following URL:
http://x.com/redirect?to=x.com/redirect?to=mail.x.com/out?url=y.com
That is the whole chain: the logic flaw of the AOR mechanism is used to redirect the user to the subdomain, and from there to the third party site.

Root cause
The flaw is a logic flaw in the AOR mechanism. The mechanism trusts any link whose domain is one of the company's domains or subdomains, on the assumption that the company's own pages are safe destinations. It also skips the access token and validation for inner links, on the assumption that redirecting within the same domain is harmless. Neither assumption holds once any page on any company subdomain has an open redirect of its own.
Impact
An attacker can craft a link on the trusted main domain that ultimately redirects a victim to an arbitrary third party site. The mail service's logout page redirects even when the user is not logged in, so no session is needed. The author frames this as a way to abuse the trust users place in the AOR mechanism, which is supposed to protect them from being redirected to malicious websites. The report does not describe any further use of the redirect, such as phishing or token theft, and does not give a bounty or severity.
Fix
The report does not say what was changed or how the issue was fixed.
What happened, in plain words
Imagine a large shopping centre with a strict security guard at the main entrance. The guard checks every visitor who wants to leave through the back door to make sure they are not being sent somewhere dangerous. But the guard has a rule: if someone is only walking from one shop to another inside the same centre, there is no need to check them. That seems sensible, because everyone inside the centre is already trusted.
Now imagine that one of the shops inside the centre has its own back door that opens directly onto the street, with no guard at all. Anyone who walks into that shop and out its back door ends up outside, on any street they like. The main guard never noticed, because the person never left through the main entrance: they left through a shop that the guard trusted.
That is exactly the kind of problem described in this case study. A website had a safety mechanism designed to stop users being sent to dangerous external websites. The mechanism trusted links that pointed to the company's own pages and subdomains, and did not check them. But one of those trusted pages, a mail service for employees, had its own flaw that let it send visitors anywhere. By chaining the trusted page and the flawed page together, the author could send a visitor from the trusted main website all the way out to an arbitrary third party site.
The author calls the safety mechanism AOR, short for Anti Open Redirects. The whole article is about how a mechanism like that can be defeated by a logic flaw.
The article was first published on 13/09/2016 on FogMarks.com and was republished on Medium on 5 February 2019.

First, the concepts
Before the walkthrough, here are the ideas you need. Each one is explained from zero.
What an open redirect is
When you click a link, your browser asks a web server for a page. Sometimes the server does not send the page itself. Instead it sends back a short message saying "the page you want is over there, go to this other address instead". Your browser then automatically goes to that other address. This is called a redirect, and it is completely normal: it is how sites move you from an old address to a new one, or send you to a login page after you click something.
An open redirect is when a website lets anybody decide where that "other address" points, including addresses on completely different websites. The website takes a value from the link you clicked and uses it as the destination without checking it. So a link on the trusted site can quietly send you to any site on the internet.
Why does that matter? Because the link starts on a website you trust. You see the trusted domain in the address bar, you click, and you end up somewhere else. Attackers use this to make phishing links look legitimate, since the first part of the link is a real, trusted company.
What an AOR mechanism is
Because open redirects are a known problem, many large websites add a protective layer. Instead of letting a posted link point straight at its destination, the site wraps the link in its own address and adds checks. The author calls this kind of protection AOR, for Anti Open Redirects.
The example used throughout the article is Facebook's linkshim system, which the author describes as a great example of a good AOR. Here is how it works, in the author's description:
- Every URL posted on Facebook gets an access token attached to it.
- That token is personal. Only the user who is viewing the link can click it and be redirected to the destination. Other people cannot.
- The mechanism also checks the destination for the user and prevents the user from being redirected to a malicious website.
What an access token is
A token is a short string of characters that acts like a ticket. When a website gives you a token, it is saying "this ticket belongs to you, and when you show it back to me I will know it is you". It is similar to a cloakroom ticket: the number on the ticket is meaningless to anyone else, but the cloakroom recognises it and hands you your coat. In the linkshim example, the token is attached to the link so that only the person who was shown the link can use it.
What a referrer is
When your browser asks a server for a page, it can include a small note saying which page you were on when you clicked the link. This note is called the referrer. It is like a visitor signing a guestbook at the door: the guestbook says where you came from. Websites use it to check that you arrived from a page they expect. It is not a security guarantee on its own, because it is just information the browser sends, but sites often rely on it as one extra check.
What a subdomain is
A domain is the main name of a website, like x.com. A subdomain is a name that sits in front of it, like mail.x.com. Think of the domain as a building and the subdomains as different departments inside it: mail.x.com is the mail department, shop.x.com might be the shop department. They are all part of the same company and share the same main name, but they can be separate systems run by different teams.
What a GET parameter is
A URL can carry extra pieces of information after a question mark. In x.com/out?url=y.com, the part after the ? is a parameter called url with the value y.com. When you fill in a search box and press enter, the search term often appears in the address bar in exactly this form. A GET parameter is simply a value passed in the address itself, visible to anyone who looks at the link.
What domain enumeration is
Companies own many subdomains, and not all of them are linked from the main website. Domain enumeration is the practice of systematically trying common subdomain names (like mail, blog, shop, dev) against a domain to discover which ones exist. It is like walking around a building trying every door to see which ones open. Using a domain enumeration software, the author detected one particular subdomain.
The setup
The author does not describe any accounts, roles, tools or versions beyond one: a domain enumeration software, which was used to detect a subdomain of the target. The target is described only as "a very popular designs website", whose name the author says he cannot reveal.
The important precondition is how the site's AOR mechanism was designed. The site allowed "inner links" to be redirected without any access token or validation, but required the referrer to be the same domain. The AOR mechanism allowed any inner link to be redirected, as long as its domain was one of that company's domains or subdomains.
- Links pointing to other companies' websites get the full protection: a token and a check.
- Links pointing to the company's own pages, including its subdomains, get no token and no check, as long as the browser says it came from the same site.
Rule 2 is the assumption that will be broken.
Finding it
The starting observation is about how most websites that use an AOR manage posted links: they do so only if those links point to third party websites. If a user on x.com posts a link to y.com, the link appears as:
x.com/out?url=y.com&access_token=1asd2ad6fdC
Line by line:
x.com/outis a page on the trusted site whose job is to send you onwards. The nameoutsuggests "exit".?url=y.comtells that page where to send you. Here the destination isy.com, a different website.&access_token=1asd2ad6fdCattaches the personal ticket. The&separates the two parameters. The token value shown is the example from the article.
Because the destination is a third party site, the site wraps it and adds the token. The token means only the person who was shown the link can use it, and the destination gets checked.
But if the user posts a link to the same domain (posting x.com/blabla on x.com), the link appears as is:
x.com/blabla
Line by line:
- There is no
outpage, nourlparameter and no token. The link is just the plain address of a page on the same site.
The reason, as the author explains it, is that websites usually trust themselves to redirect users within themselves. They consider it safe and pointless to attach an access token to a link that redirects the user to the same domain. The author has heard the argument "if a certain page is vulnerable to an open redirect there is no reason to check redirection to it" countless times, and sets out to change that view.
Think of it this way: a company does not put a passport check between two rooms of its own office. Everyone inside is already staff. The flaw is that one of those rooms has a door to the street.
The target site had exactly this vulnerability. Inner links were redirected without any access token or validation, but the referrer had to be the same domain. The AOR mechanism allowed any inner link to be redirected as long as its domain was one of the company's domains or subdomains.
So the site's rule was: if the link points at one of our own names, and the browser says it came from our site, let it through. That is a reasonable-sounding rule. It assumes every page on every company subdomain is safe.
Using a domain enumeration software, the author detected a subdomain of the website that contained a mail service for the company's employees. That mail service had an open redirect vulnerability on its logout page. Even if the user was not logged in, when the logout page was accessed with a "redirect after" GET parameter, the user was redirected to any other page, including a third party website. The mail service, the author notes, does not consider this behaviour to be an open redirect vulnerability.
In plain words: the author went looking for doors in the building and found one. The mail service for employees had a logout page. Normally a logout page sends you back to the home page after logging you out. This one let the address in the link decide where you go next, through a parameter that says "redirect after". And it did this even if you were never logged in, so no account was needed. The team running the mail service did not consider this a vulnerability, which the author notes with some frustration.
That single door is enough to break the whole building's security, because the main site's guard trusts everything inside the building.
Exploitation
With an open redirect on a subdomain page, the remaining problem was reaching it from the main domain. The AOR mechanism allowed a link to be redirected to a subdomain, but only if the referrer was the same website.
So there were two obstacles, and they had to be solved together:
- The main site will send you to a subdomain, but only if the browser says you came from the main site.
- The subdomain's mail service will send you anywhere, but you have to reach it first.
Step 1: Identify the two vulnerable pages
The author models the situation with two pages:
Vulnerable mail service: http://mail.x.com/out?url=y.com
'Vulnerable' page within the domain: http://x.com/redirect?to=mail.x.com/out?url=y.com
Line by line, the second address:
http://x.com/redirectis a page on the main domain whose job is to send you onwards.?to=mail.x.com/out?url=y.comis its parameter, calledto. The value is the mail service address from the first line, including its ownurlparameter.
Why model it this way? Because the author is showing the two pieces separately before joining them. The first piece is the exit door. The second piece is the trusted corridor that leads to it.
Step 2: Redirect to the same page, then again
The author's solution was to redirect the user to the same page, and then have them redirected again. Because the second page requires the referrer to be from x.com, the author issued the following URL:
http://x.com/redirect?to=x.com/redirect?to=mail.x.com/out?url=y.com
Line by line:
http://x.com/redirectis the first stop. This is the trusted redirect page on the main domain.?to=is its parameter, telling it where to send you next.x.com/redirect?to=mail.x.com/out?url=y.comis the value of that parameter. Notice that it is the same redirect page again, with its owntoparameter inside.mail.x.com/out?url=y.comis the innermost value, the mail service logout page with its ownurlparameter.
It is like a guard who asks "did you come from inside the building?" and you answer by walking out of one room and back in through another, so the answer is always yes.
That is the whole chain: the logic flaw of the AOR mechanism is used to redirect the user to the subdomain, and from there to the third party site.

Why it works: the root cause
The flaw is a logic flaw in the AOR mechanism. The mechanism trusts any link whose domain is one of the company's domains or subdomains, on the assumption that the company's own pages are safe destinations. It also skips the access token and validation for inner links, on the assumption that redirecting within the same domain is harmless. Neither assumption holds once any page on any company subdomain has an open redirect of its own.
In everyday terms: the guard trusted everyone already inside the building. But one room inside the building had a door to the street. The guard's rule was fine only as long as every room was sealed. The moment one room is not sealed, the rule becomes a way out.
What an attacker could do with it
An attacker can craft a link on the trusted main domain that ultimately redirects a victim to an arbitrary third party site. The mail service's logout page redirects even when the user is not logged in, so no session is needed. The author frames this as a way to abuse the trust users place in the AOR mechanism, which is supposed to protect them from being redirected to malicious websites. The report does not describe any further use of the redirect, such as phishing or token theft, and does not give a bounty or severity.
In plain words: the attacker does not need an account, does not need the victim to be logged in, and does not need to break any encryption. They only need to send a link. The link starts with the trusted company's name, which is exactly what makes it convincing. The protection that was supposed to stop this is the thing being used to enable it.
How it should have been fixed
The report does not say what was changed or how the issue was fixed.
In everyday terms: the guard should check the final destination of every visitor, not just the ones leaving through the front door. And the room with the street door should be locked, or at least have its own guard.
A note on the Location header mentioned in point 2: when a server redirects you, it sends back a response with a header called Location that contains the address to go to next. If that address is on an external domain, the redirect is open.
Glossary
- AOR (Anti Open Redirects): a protective mechanism that wraps links and checks where they point, to stop users being sent to dangerous external sites.
- Access token: a short string attached to a link or request that identifies who is allowed to use it, like a cloakroom ticket.
- Domain: the main name of a website, such as
x.com. - Subdomain: a name in front of a domain, such as
mail.x.com, usually a separate system belonging to the same company. - Domain enumeration: systematically trying common subdomain names to discover which ones exist.
- Open redirect: a flaw where a website lets anyone choose the destination of a redirect, including external websites.
- Redirect: a server telling the browser to go to a different address instead of showing the requested page.
- Referrer: a note the browser sends saying which page you came from when you clicked a link.
- GET parameter: a value passed in the URL after a question mark, such as
?url=y.com. - Logic flaw: a mistake in the rules or reasoning of a system, rather than in the code that runs it.
- Linkshim: Facebook's system that wraps posted links with a personal access token and checks the destination.
- Location header: the part of a server's redirect response that contains the address the browser should go to next.
- Session: the state of being logged in to a website, usually kept alive by a cookie.
- Cookie: a small piece of data a website stores in your browser so it can recognise you on later requests.
- Phishing: tricking someone into visiting a fake or malicious site, often by making the link look trustworthy.
- Third party website: a website belonging to a different company from the one you are on.
- Logout page: the page a website shows after you log out, often with a link back to the home page.
- Redirect after parameter: a parameter on a page that tells it where to send you once its action is done.
urlparameter: in this report, the parameter on the mail service's logout page that holds the destination address.toparameter: in this report, the parameter on the main domain's redirect page that holds the destination address.access_tokenparameter: in this report, the parameter that carries the personal token on wrapped links.