Skip to content
Open redirect Write-up Beginner

Uncovering an Open Redirect Using Wayback

An endpoint took a returnUrl parameter and redirected the browser to whatever external address was supplied, without validating it. An attacker could craft a link on the trusted domain that sends victims to an arbitrary site, which aids phishing.

MaMad Follow

Published on medium.com

Open Redirect

MaMad, 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. 4 min read.

Context

The target was a web application on www.redacted.com, and the endpoint /Home/RetreiveLocalHostRegion takes a returnUrl parameter and redirected the browser to the address supplied in it. Parameters that carry a destination like this exist so that a site can send a visitor back to where they came from after an action, and they are only safe when the destination is validated against an allowlist or restricted to relative paths.

The report does not describe the wider product or what the endpoint does beyond the redirect itself.

Setup

No accounts, roles or special tooling were needed. The Wayback Machine was used, through its CDX API, to enumerate historical URLs for the domain.

Finding it

Reconnaissance started with the Wayback Machine, which indexes URLs that have been archived over time. The researcher ran a CDX query to pull historical URLs and their parameters for the target domain:

Text
https://web.archive.org/cdx/search/cdx?url=*.redacted.com/*&fl=original&collapse=urlkey

The query asks the CDX index for every archived URL matching the wildcard pattern *.redacted.com/*, returns only the original field (the archived URL itself), and uses collapse=urlkey to remove duplicate entries that share the same URL key. The goal was simply to collect historical URLs and their parameters for further investigation.

Among the results was an endpoint carrying a returnUrl parameter:

Text
https://www.redacted.com/Home/RetreiveLocalHostRegion?returnUrl=

The name returnUrl stood out because parameters that return or redirect users are sometimes validated improperly. That made it the first candidate to test.

Exploitation

Step 1: Supply an external destination

The value of returnUrl was replaced with an external URL, using a protocol-relative form:

Text
https://www.redacted.com/Home/RetreiveLocalHostRegion?returnUrl=//google.com

The value //google.com has no scheme of its own, so a browser resolves it against the scheme of the current page, producing https://google.com.

Step 2: Observe the redirect

The application redirected to:

Text
https://google.com

No additional interaction or validation was required. The redirect happened straight away.

From the original on medium.com

Steps to reproduce

  1. Open the following URL: https://www.redacted.com/Home/RetreiveLocalHostRegion?returnUrl=//google.com
  2. The application redirects the user based on the returnUrl parameter.
  3. The browser is redirected to https://google.com.

Root cause

The endpoint takes the destination from user input and uses it for the redirect without properly validating it. The report does not show the server-side code, so the exact check that was missing, or the check that was present and bypassed, is not stated. What the test demonstrates is that a protocol-relative value pointing at an external host is accepted and acted on.

Impact

An attacker can build a link that appears to originate from the trusted domain but sends the victim to an arbitrary external site. The report gives this example:

Because the initial URL belongs to the trusted domain, the link can be used in phishing and social-engineering attacks. The impact could be greater if the vulnerable endpoint is used within sensitive authentication or redirect flows.

Fix

The behaviour it documents is that the parameter was not properly validated and could redirect users to arbitrary external websites.

Variants to test

When a returnUrl-style parameter turns up in historical URLs, the same test can be repeated with other encodings of an external destination. A positive result is any response that sends the browser off the target domain.

  1. Protocol-relative values: //attacker.com, as in this report. Positive result: the browser resolves the value against the current scheme and lands on the external host.
  2. Absolute URLs: https://attacker.com. Positive result: a redirect to the external host with no validation error.
  3. Backslash and mixed-slash forms such as /\attacker.com or \\attacker.com, which some parsers normalise into a host. Positive result: the browser ends up on the external host despite the value not looking like a normal URL.
  4. Userinfo tricks such as https://[redacted]. Positive result: a check that only looks for the trusted hostname in the string passes, but the browser navigates to attacker.com.
  5. Subdomain and suffix tricks such as https://redacted.com.attacker.com or https://attacker.com/?redacted.com. Positive result: a substring or suffix check is satisfied while the real destination is external.
  6. Encoded and double-encoded values, for example %2f%2fattacker.com or %252f%252fattacker.com. Positive result: the value is decoded once by the validator and again by the redirect logic, ending at the external host.
  7. Relative paths that climb out of the intended location, such as /Home/../..//attacker.com. Positive result: normalisation produces an external destination.
  8. Chained redirects: point returnUrl at another endpoint on the same domain that itself redirects, so the first hop passes validation. Positive result: the final response leaves the trusted domain.

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

What happened, in plain words

A security researcher was looking at a website, www.redacted.com, to see whether it could be tricked into sending visitors somewhere it should not. The website had a page at /Home/RetreiveLocalHostRegion that reads a value called returnUrl from the web address and redirected the browser to the address that value contained.

Features like this are common and useful. Imagine a shop that asks you to log in before you can see your order: after you log in, the site wants to send you back to the order page you were trying to reach. To do that, it stores the destination in a parameter such as returnUrl. The feature is only safe if the site checks the destination first, for example by allowing only addresses on its own domain. If it does not check, anyone can put any address in there, and the trusted site becomes a launchpad to somewhere else. That is called an open redirect.

The researcher found this endpoint by searching an archive of old web addresses, the Wayback Machine, rather than by guessing. Then they replaced the value of returnUrl with an external address and watched the browser leave the site. It worked immediately, with no extra steps. The rest of this article walks through exactly how that was done, what each piece of the request means, and why it matters.

Background: the ideas you need

Before the steps, here are the few concepts the report relies on, explained from scratch.

A URL and its parameters. A URL is a web address, like https://www.example.com/page. Everything after a ? is called the query string, and it is made of parameters: pairs of a name and a value joined by =, with several pairs separated by &. In ?returnUrl=//google.com, the parameter name is returnUrl and its value is //google.com. Parameters are just text the browser sends to the server; the server decides what to do with them.

A redirect. When you visit a page, the server can answer with a special instruction that means "do not show this page, go to this other address instead". Your browser follows it automatically, usually so fast you do not notice. This is how a site sends you from an old page to a new one, or back to where you came from after logging in.

An endpoint. An endpoint is one specific address on a server that does one specific job, like a counter in a shop that handles one kind of request. /Home/RetreiveLocalHostRegion is the endpoint in this report.

An API. An API is a way for one piece of software to ask another piece of software to do something, using agreed addresses and formats. You do not need to write code to use one: a URL that returns data when you open it in a browser is also an API in action. The Wayback Machine query below is an example.

The Wayback Machine and its CDX API. The Wayback Machine is a public archive that has been saving copies of web pages for years. Because it keeps the addresses it has seen, it is also a record of pages that may no longer be linked anywhere but might still exist on the live site. The CDX API is the part of the archive you can query with a URL to get a list of those saved addresses. Think of it as an old guest book for a building: even if a room is no longer on the directory, the guest book may still mention it.

Reconnaissance. Reconnaissance (often shortened to recon) is the information-gathering phase: finding out what addresses, pages and features a site has before testing anything. It is the equivalent of walking around a building and reading the signs before trying any doors.

Protocol-relative URL. A normal web address starts with a scheme such as https://. An address that starts with // has no scheme of its own. When a browser sees one, it borrows the scheme of the page it is currently on. So on an https page, //google.com means https://google.com. This matters because a check that only looks for the text http at the start of a value will not notice a value that begins with //.

Phishing and social engineering. Phishing is tricking someone into trusting a link or a page so they hand over information or run something harmful. Social engineering is the broader idea of manipulating people rather than machines. A link that starts with a familiar, trusted domain is much easier to get someone to click.

Setup

The Wayback Machine was used, queried through its CDX API, to list historical addresses for the domain.

Finding it

The first step was reconnaissance with the Wayback Machine. The researcher ran this CDX query:

Text
https://web.archive.org/cdx/search/cdx?url=*.redacted.com/*&fl=original&collapse=urlkey

Line by line, in plain words:

  • https://web.archive.org/cdx/search/cdx is the address of the archive's search service. Opening it with the right parameters returns a list rather than a web page.
  • ? starts the parameters, exactly as described above.
  • url=*.redacted.com/* is the pattern to search for. The * is a wildcard meaning "anything". So this asks for any archived address whose host ends in redacted.com and whose path is anything. In everyday terms: "show me every address you have ever saved for this site".
  • & separates this parameter from the next one.
  • fl=original means "fields list: give me only the original field", which is the archived address itself. Without it, the archive would return extra columns; with it, the answer is a clean list of addresses.
  • collapse=urlkey removes duplicates. Many archived addresses differ only in small ways and would otherwise appear many times; this option keeps one entry per unique address key so the list is shorter and easier to read.

The purpose was simply to collect historical addresses and their parameters so they could be examined. Old addresses are interesting because they are easy to forget: a page that is no longer linked from the menu may still be live on the server.

Among the results was an endpoint carrying a returnUrl parameter:

Text
https://www.redacted.com/Home/RetreiveLocalHostRegion?returnUrl=

In this line, https://www.redacted.com is the site, /Home/RetreiveLocalHostRegion is the endpoint, and ?returnUrl= is a parameter named returnUrl with an empty value. The name stood out immediately. A parameter whose name suggests "where to return the user" is exactly the kind of thing that has to be checked carefully, because if it is not, it becomes a way to send people anywhere. That made it the first candidate to test.

Exploitation

Step 1: Supply an external destination

The value of returnUrl was replaced with an external address, written in protocol-relative form:

Text
https://www.redacted.com/Home/RetreiveLocalHostRegion?returnUrl=//google.com

What each part does:

  • https://www.redacted.com/Home/RetreiveLocalHostRegion is the same trusted endpoint as before, unchanged.
  • ?returnUrl= is the same parameter, still named returnUrl.
  • //google.com is the new value. It has no https:// of its own, so the browser fills in the scheme of the current page, which is https, and treats it as https://google.com.

The value was written in protocol-relative form, with no scheme of its own, so the browser fills in the scheme of the current page.

Step 2: Observe the redirect

The application redirected to:

Text
https://google.com

That is the whole result: the browser left the trusted site and arrived at the external one. No extra click, no confirmation, no validation step was required. The redirect happened straight away.

From the original on medium.com

Steps to reproduce

  1. Open the following URL: https://www.redacted.com/Home/RetreiveLocalHostRegion?returnUrl=//google.com
  2. The application redirects the user based on the returnUrl parameter.
  3. The browser is redirected to https://google.com.

In plain words: paste the address into the browser's address bar, press Enter, and watch where you end up. If you end up on the external site, the endpoint is redirecting wherever it is told.

Root cause

The endpoint takes the destination straight from what the user typed into the address and uses it for the redirect without properly checking it. The report does not show the server-side code, so the exact check that was missing, or the check that was present and bypassed, is not stated. What the test demonstrates is that a protocol-relative value pointing at an external host is accepted and acted on.

A useful comparison: a receptionist who forwards your call to any number you give them, without asking whether it is an internal extension, is doing exactly what this endpoint does. The fix in real life would be a list of allowed numbers; here, the equivalent would be an allowlist of destinations or a restriction to paths on the same site.

Impact

An attacker can build a link that appears to come from the trusted domain but sends the victim to an arbitrary external site. The report gives this example:

Reading it the same way as before: the trusted site and endpoint are unchanged, and only the value after returnUrl= is swapped for the attacker's address. Because the beginning of the link belongs to the trusted domain, a victim glancing at it sees a familiar name. That is what makes it useful in phishing and social-engineering attacks: the link itself does the persuading.

The impact could be greater if the vulnerable endpoint is used within sensitive authentication or redirect flows. In other words, if this same parameter is involved in logging users in or sending them between protected pages, the redirect could be part of a more damaging chain.

Fix

The report does not describe a fix or a change made by the application owner. What it documents is the behaviour: the parameter was not properly validated and could redirect users to arbitrary external websites.

Variants to test

When a returnUrl-style parameter turns up in historical addresses, the same test can be repeated with other ways of writing an external destination. A positive result is any response that sends the browser off the target domain. These are the variants worth trying, each with what a positive result looks like:

  1. Protocol-relative values: //attacker.com, as in this report. Positive result: the browser resolves the value against the current scheme and lands on the external host.
  2. Absolute URLs: https://attacker.com. Positive result: a redirect to the external host with no validation error.
  3. Backslash and mixed-slash forms such as /\attacker.com or \\attacker.com, which some parsers normalise into a host. Positive result: the browser ends up on the external host even though the value does not look like a normal address.
  4. Userinfo tricks such as https://[redacted]. Positive result: a check that only looks for the trusted hostname in the text passes, but the browser navigates to attacker.com. The part before the @ is treated as a username, not as the destination.
  5. Subdomain and suffix tricks such as https://redacted.com.attacker.com or https://attacker.com/?redacted.com. Positive result: a substring or suffix check is satisfied while the real destination is external.
  6. Encoded and double-encoded values, for example %2f%2fattacker.com or %252f%252fattacker.com. Positive result: the value is decoded once by the validator and again by the redirect logic, ending at the external host. %2f is simply another way of writing a forward slash.
  7. Relative paths that climb out of the intended location, such as /Home/../..//attacker.com. Positive result: normalisation produces an external destination. .. means "go up one level", so enough of them can walk out of the intended folder.
  8. Chained redirects: point returnUrl at another endpoint on the same domain that itself redirects, so the first hop passes validation. Positive result: the final response leaves the trusted domain.

Glossary

  • API: a way for one piece of software to ask another to do something, using agreed addresses and formats; a URL that returns data when opened in a browser is an API in action.
  • CDX API: the Wayback Machine's query service that returns a list of archived addresses matching a pattern.
  • Endpoint: one specific address on a server that performs one specific job.
  • Open redirect: a flaw where a site takes a destination from user input and sends the browser there without properly checking it, so the trusted site can be used to point at any other site.
  • Parameter: a named value in a URL's query string, written as name=value after a ? and separated by &.
  • Phishing: tricking someone into trusting a link or page so they give away information or run something harmful.
  • Protocol-relative URL: an address starting with // that borrows the scheme (such as https) of the page it appears on.
  • Query string: the part of a URL after the ?, made of parameters.
  • Reconnaissance: the information-gathering phase of testing, finding out what addresses and features a site has.
  • Redirect: a server instruction telling the browser to go to a different address instead of showing the requested page.
  • Scheme: the first part of a URL, such as https, that says how to fetch it.
  • Social engineering: manipulating people, rather than machines, to get them to do something.
  • URL: a web address.
  • Wayback Machine: a public archive that has saved copies of web pages and the addresses it has seen over time.
  • Wildcard: a * character in a pattern that stands for "anything".

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.