Skip to content
Open redirect Write-up Beginner

Transforming a Domain into the Matrix (an open redirect story)

The login endpoint's return_to parameter appended the user-supplied string directly to the domain, so a value like 'pany' produced a redirect to redacted.company. An attacker could register that domain and redirect logged-in users to it.

ak1t4 Follow

Published on medium.com

Security

Ak1T4, on medium.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. 3 min read.

Context

The target is a bug bounty program that the author keeps private and refers to throughout as [redacted.com]. The feature in question is the login endpoint, which accepts a return_to parameter:

The endpoint accepts a return_to parameter. The author found the endpoint about a year before writing the post, while starting out with bounties.

Setup

The only precondition that matters for the behaviour described is that the user is logged in. The author does not describe any tools, accounts or versions beyond that.

Finding it

The author first treated return_to as a classic open redirect candidate and tried a series of payloads:

Text
return_to=http://evil.com -> rejected
return_to=http://[redacted.com].evil.com -> rejected
return_to=//google.com -> rejected
return_to=//[redacted] -> rejected
return_to=//google.com/redacted.com -> rejected

All of them were rejected, and the author notes the list of attempts was quite large. The reaction to the failures:

The truth sometimes hurts :( From the original on medium.com

The image is captioned The truth sometimes hurts :(.

While working through those attempts the author noticed something strange, and describes the moment as the Twilight Zone music starting. The inspiration arrived as a message:

From the original on medium.com

Exploitation

Step 1: any string after return_to

The author tried putting an arbitrary string in the parameter while logged in:

Text
/login?return_to=anythinghere

With the user logged in, the domain becomes https://redacted.comanythinghere. The author's reaction to this behaviour:

(shit happens) From the original on medium.com

The image is captioned (shit happens).

Step 2: turning the concatenation into a domain

The author asked what happens with the following request:

When the user is logged in, they are redirected directly to https://[redacted.company].

Step 3: checking whether the resulting domain was free

The author looked up whether the domain formed by the concatenation was available, and found that it was:

YES! AVAILABLE! From the original on medium.com

The image is captioned YES! AVAILABLE!. The author's reaction at that point:

From the original on medium.com

Root cause

The report does not include the server-side code, so the mechanism has to be read from the behaviour. The report does not include the server-side code, so the mechanism has to be read from the behaviour: return_to=anythinghere yields https://redacted.comanythinghere and return_to=pany yields https://redacted.company. The redirect target is therefore partly attacker-controlled at the hostname level, not just at the path or query level.

This is why the conventional payloads failed. Values such as http://evil.com, //google.com or //[redacted] were rejected, Values such as http://evil.com, //google.com or //[redacted] were rejected.. The concatenation trick does not look like a URL at all: it is a bare string that only becomes a different host once the server glues it onto its own domain. The author links a resource on the parsing gap where //host.com is treated as a relative-path URL by server-side libraries while Chrome and Firefox violate the RFC and load it as a host:

From the original on medium.com

Impact

The result is a redirect: a logged-in user who follows a crafted /login?return_to=... link is sent to the concatenated domain. The author notes the same trick can be used in many scenarios where a whitelisted URL or domain is handled, including CORS and OAuth. The report does not describe a specific attack chain, victim population or bounty amount.

Fix

The report does not say what the program changed. Based on the behaviour, the fix is to stop concatenating the parameter onto the host: parse return_to as a URL, resolve it against a fixed base, and only redirect when the resulting host matches an allowlist exactly, rather than checking the raw string for the usual open redirect patterns.

Variants to test

  1. Send a bare string that completes the hostname into a domain you control, as in return_to=pany against a host ending in .com. A positive result is a redirect to https://<target-host><your-string>, i.e. to a domain you own.
  2. Send a short arbitrary string and observe the resulting Location. A positive result is the host with your string appended, showing concatenation rather than URL resolution.
  3. Try the same parameter on other redirect-style endpoints (post-login, post-logout, OAuth callbacks, CORS origin reflection) where a whitelist is applied to a supplied URL. A positive result is any redirect or reflected origin whose host is influenced by your input despite the whitelist.
  4. Check whether the resulting domain is unregistered before reporting, since the impact depends on an attacker being able to own it. A positive result is an available domain matching the concatenated host.

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.

What happened, in plain words

A security researcher was testing a website's login page. The login page took a parameter called return_to in its address. The researcher tried the usual tricks to make that link point at a website he controlled, and every one of them was blocked. Then he noticed something odd: if he typed a random word into that spot, the website glued the word onto its own domain name and sent him to a made-up address. By choosing the right word, he could turn the website's own domain into a completely different domain, which turned out to be available. That is an open redirect: a way to make a trusted site send its users somewhere else.

This article walks through the whole story from scratch, explaining each idea as it comes up.

The target and the feature

The researcher was working on a bug bounty program. A bug bounty program is an arrangement where a company invites outside people to look for security problems in its systems and pays them for reporting what they find. The researcher keeps the company's name private and calls it [redacted.com] throughout.

The feature he looked at is the login page. When you log in to a website, the site often wants to send you back to the page you were trying to reach before it asked you to sign in. To remember that page, the site puts it in the web address as a parameter. A parameter is the part of a web address after a question mark, made of a name, an equals sign and a value, like ?colour=blue. Here the parameter is called return_to and it is meant to hold the address to return to:

Line by line:

  • https:// is the protocol, the set of rules browsers and servers use to talk to each other securely.
  • [redacted.com] is the website's domain name, the human-readable name that stands in for a server's numeric address.
  • /login is the path, the specific page on that site.
  • ?return_to=[url] is the parameter: the name return_to with a placeholder [url] where the address to return to would go.

The researcher found this endpoint about a year before writing his post, when he was just starting out with bug bounties.

What he was looking for

An open redirect is a weakness where a website takes an address from the user and sends the browser there without checking that the address belongs to the site. Attackers abuse it because the link starts with the trusted site's name, so victims click it without suspicion, and then land on a fake page that might ask for a password or install malware. A simple everyday comparison: it is like a receptionist at a trusted office who will forward your call to any number you name, so a scammer can say "call the office, they will put you through to me".

The researcher tried open redirect payloads against return_to.

The first attempts

He tried a series of classic open redirect payloads. A payload is the specific piece of input you send to test a weakness. Each line below shows what he put in return_to and what happened:

Text
return_to=http://evil.com -> rejected
return_to=http://[redacted.com].evil.com -> rejected
return_to=//google.com -> rejected
return_to=//[redacted] -> rejected
return_to=//google.com/redacted.com -> rejected

Line by line:

  • return_to=http://evil.com is the simplest attempt: just point at a domain the attacker controls. It was rejected, meaning the site refused to use it.
  • return_to=http://[redacted.com].evil.com tries to look trustworthy by starting with the real site's name, but the actual domain is still evil.com because domain names are read from right to left. Rejected.
  • return_to=//google.com uses a protocol-relative address. When a web address starts with // and no https:, the browser fills in the same protocol as the current page, so this means https://google.com. Rejected.
  • return_to=//[redacted] uses the @ trick. In a web address, anything before an @ is treated as a username for logging in, and the real destination is what comes after the @. So this actually points at evil.com. Rejected.
  • return_to=//google.com/redacted.com puts the trusted name in the path, hoping a naive check would see it and allow the address, while the real destination is still google.com. Rejected.

All of them were rejected, and the researcher notes the list of attempts was quite large. His reaction to the failures:

The truth sometimes hurts :( From the original on medium.com

The image is captioned The truth sometimes hurts :(.

The strange behaviour

While working through those attempts, the researcher noticed something odd. He describes the moment as the Twilight Zone music starting, a reference to a television show known for eerie, unexplained events. The inspiration arrived as a message:

From the original on medium.com

Step 1: any string after return_to

He tried putting an arbitrary string in the parameter while logged in:

Text
/login?return_to=anythinghere

Line by line:

  • /login is the login page.
  • ?return_to=anythinghere sets the parameter to the plain word anythinghere, which is not a web address at all, just a string of letters.

With the user logged in, the domain becomes https://redacted.comanythinghere. In other words, the site took its own domain name and stuck the word straight onto the end of it, with no dot and no slash in between. The result is not a real address, but it shows the site is not treating the value as a proper web address. His reaction to this behaviour:

(shit happens) From the original on medium.com

The image is captioned (shit happens).

Step 2: turning the concatenation into a domain

Concatenation means joining two pieces of text end to end. The researcher realised that if the site glues his input onto its own domain, he could choose input that completes the domain name into a different, real domain. He asked what happens with the following request:

Line by line:

  • https://[redacted.com]/login is the same login page.
  • ?return_to=pany sets the parameter to the four letters pany.

When the user is logged in, they are redirected directly to https://[redacted.company]. Gluing pany onto the site's domain produces [redacted.company]. In other words, the string supplied in return_to is appended to the host, so a value that completes the hostname into a different registered domain produces a redirect to that domain. The host is the part of a web address that names the server, like example.com in https://example.com/page.

Step 3: checking whether the resulting domain was free

The researcher looked up whether the domain formed by the concatenation was available, and found that it was:

YES! AVAILABLE! From the original on medium.com

The image is captioned YES! AVAILABLE!. His reaction at that point:

From the original on medium.com

Why the usual payloads failed

The report does not include the server-side code, so the mechanism has to be read from the behaviour. The report does not include the server-side code, so the mechanism has to be read from the behaviour: return_to=anythinghere yields https://redacted.comanythinghere and return_to=pany yields https://redacted.company. The redirect target is therefore partly attacker-controlled at the hostname level, not just at the path or query level.

This is why the conventional payloads failed. Values such as http://evil.com, //google.com or //[redacted] were rejected, Values such as http://evil.com, //google.com or //[redacted] were rejected.. An absolute address is a full web address with a protocol and a domain, like https://example.com. A protocol-relative address is one that starts with // and borrows the current page's protocol. The concatenation trick does not look like a URL at all: it is a bare string that only becomes a different host once the server glues it onto its own domain. The author links a resource on the parsing gap where //host.com is treated as a relative-path URL by server-side libraries while Chrome and Firefox violate the RFC and load it as a host. An RFC is a formal document that defines how internet standards should work. A relative-path URL is one that points to a page on the same site, like /about, rather than to a different site.

From the original on medium.com

What the impact is

The result is a redirect: a logged-in user who follows a crafted /login?return_to=... link is sent to the concatenated domain. The author notes the same trick can be used in many scenarios where a whitelisted URL or domain is handled, including CORS and OAuth. A whitelist is a list of values that are explicitly allowed. CORS, Cross-Origin Resource Sharing, is a browser rule that lets one website ask another for data, and it relies on the second site naming which origins are allowed. OAuth is a common way to log in to one site using an account from another, and it also relies on redirect addresses being checked. The report does not describe a specific attack chain, victim population or bounty amount.

How it should be fixed

The report does not say what the program changed. Based on the behaviour, the fix is to stop concatenating the parameter onto the host: parse return_to as a URL, resolve it against a fixed base, and only redirect when the resulting host matches an allowlist exactly, rather than checking the raw string for the usual open redirect patterns. Parsing means breaking the text down into its parts, such as protocol, host and path, so the site can inspect each one properly.

Variants to test

  1. Send a bare string that completes the hostname into a domain you control, as in return_to=pany against a host ending in .com. A positive result is a redirect to https://<target-host><your-string>, i.e. to a domain you own.
  2. Send a short arbitrary string and observe the resulting Location. The Location header is the part of a server's reply that tells the browser where to go next. A positive result is the host with your string appended, showing concatenation rather than URL resolution.
  3. Try the same parameter on other redirect-style endpoints (post-login, post-logout, OAuth callbacks, CORS origin reflection) where a whitelist is applied to a supplied URL. A positive result is any redirect or reflected origin whose host is influenced by your input despite the whitelist.
  4. Check whether the resulting domain is unregistered before reporting, since the impact depends on an attacker being able to own it. A positive result is an available domain matching the concatenated host.

Glossary

  • Bug bounty program: an arrangement where a company invites outside researchers to find security problems and pays them for valid reports.
  • Endpoint: a specific address on a website that accepts requests, such as a login page.
  • Parameter: a named value in a web address after the question mark, like return_to=....
  • Domain name: the human-readable name of a server, like example.com.
  • Host: the part of a web address that names the server.
  • Path: the part of a web address after the domain that names a page, like /login.
  • Protocol: the rules two computers use to talk, such as https.
  • Open redirect: a weakness where a site sends users to an address supplied by the user without checking it belongs to the site.
  • Payload: the specific input you send to test for a weakness.
  • Protocol-relative address: a web address starting with // that borrows the current page's protocol.
  • Absolute address: a full web address with protocol and domain.
  • Relative-path URL: an address pointing to a page on the same site, like /about.
  • Concatenation: joining two pieces of text end to end.
  • Validation: checking that input meets expected rules before using it.
  • Whitelist / allowlist: a list of values that are explicitly permitted.
  • CORS: a browser rule that lets one site request data from another, based on which origins the second site allows.
  • OAuth: a common way to log in to one site using an account from another, relying on checked redirect addresses.
  • RFC: a formal document defining how an internet standard should work.
  • Location header: the part of a server reply that tells the browser where to go next.
  • Redirect: a server reply that sends the browser to a different address.

More by ak1t4

View all

8 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.