Account of the CEO Takeover via Password Reset | by Vlad
The password reset confirmation page accepted a user identifier taken from the URL and did not verify that it belonged to the person resetting the password. An attacker could change that identifier to another user's value and set a new password, taking over the account, including the CEO's.
Published on cristivlad.medium.com
In a web app pentest for a client, I found this interesting account takeover and I thought of sharing my findings with the infosec community.
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
During a web application penetration test for a client, I came across an account takeover that is worth writing up because of how little it took to find. The application had an authentication flow with a "Forgot Password" feature, and as usual I spent time on every authentication-related function before moving on. The feature does what you would expect: it emails the user a link that lets them set a new password.
Setup
There were no special tools involved. The work was manual: request the reset, read the email, follow the link, and then look closely at the URL the application sent me to. To confirm the issue I created a second account of my own (myaccount2) in a different browser session, so that I could test whether a reset link issued for one account could be used against another. The second account's ID was visible in the Account Settings section, which gave me a known-good value to compare against.
Finding it
The flow started in the usual way:
Click on "Forgot Password" ⇒ Enter Email ⇒ Submit ⇒ Check your email.
I immediately received an email with a password reset link that looked something like this:
https://email.mail.redactedexample.com/c/verylongENCRYPTEDstring
That first link is on a separate mail domain and carries an encrypted string, so nothing obviously wrong there. The interesting part came after clicking it. I was redirected to:
https://redactedexample.com/someendpoint/confirm.php?u=551234911&t=<132bitUnknownHashType>&x=2913117
The reset page now had three parameters in the URL: u, which looked like a numerical user ID, t, a 132-bit hash of an unknown type, and x, a number whose purpose was not yet clear. The page itself rendered as:
Your email is <myemail>Create new password:********************Confirm password:********************<Submit button>
Handing the user identifier to the browser as a plain, sequential number is the kind of thing that makes you stop and try the obvious. My first thought was that it could not be that simple, but it costs nothing to check.
Exploitation
Step 1: remove the x parameter
The first thing I did was remove the x parameter and refresh the page to see whether it made any difference. It did not. The reset page still worked without it.
Step 2: increment u
Since u looked like a numerical ID, I incremented it by one and hit enter. The page came back as:
Your email is <anotheruser'semail>Create new password:********************Confirm password:********************<Submit button>
The form now belonged to a different user. The email address shown on the page changed to that user's address, which confirmed that the application was loading the reset context purely from the u value in the URL.
Step 3: confirm with an account I controlled
Even at that point I was unsure whether the reset would actually complete, so I created a second account (myaccount2) in a different browser session. Its ID was exposed in the Account Settings section. I copied that ID and pasted it into the URL:
I created and confirmed a new password, hit Submit, and was immediately logged into myaccount2's account. The takeover was real: a reset link issued for one account could be pointed at another account simply by changing u.
Step 4: walk the ID space to the CEO
To take it a step further, I played with the numerical ID and decremented it until I found the account of the CEO. My account was (supposedly) 551234911, and the CEO's account was not 1 or 000000001, but somewhere at 551003010. Sequential identifiers made the target reachable by walking the range.
Step 5: the x parameter and link expiry
I also noticed that the point of the x parameter was to invalidate the reset link after some time. Removing it also removed that entire logic, which allowed me to use and abuse the reset URL days later.
Root cause
The developers probably thought the link in the email was safe because the string in it was encrypted rather than encoded. But encryption at the first step is pointless if the next step hands control of the URL parameters to the end user. The confirmation endpoint trusts the u parameter supplied by the browser to decide whose password is being reset.
The expiry control lived in the x parameter, and removing it removed that logic, so the reset URL could be used days later. In my opinion this is bad logic: the security decisions were made in parameters the user controls.
Impact
An attacker who can reach the confirmation endpoint can reset the password of any account whose ID they can guess or obtain, and then log in as that user. Because the IDs are sequential, walking the range is enough to reach a chosen target; in this case it led to the CEO's account. The removal of x extends the window: a reset URL can be used days after it was issued.
Fix
The report does not say what the client changed. What the logic should do is stop trusting client-supplied parameters for identity: the confirmation step should derive the account from the token that was issued for that reset, not from a u value in the URL, and the expiry check should not depend on a parameter the user can remove. More generally, do not give the end user more permissions than necessary.
Variants to test
-
Numeric or sequential identifiers in reset links. Request a reset for your own account, then change the user identifier in the confirmation URL to a neighbouring value. A positive result is the page rendering another user's email address, or a completed reset that logs you into that account.
-
Removable parameters. Delete each parameter in the confirmation URL one at a time and resubmit. A positive result is the flow completing without the parameter that was supposed to enforce expiry or bind the token.
-
Delayed reuse. Keep a reset URL and use it days later, with and without the expiry parameter. A positive result is the link still working after its intended lifetime.
-
IDs exposed elsewhere. Check profile and settings pages for the same identifier used in reset URLs, as the Account Settings section exposed it here; a match gives you a reliable value to substitute.
The bottom line for the red team is to look closer and focus on manual testing, because tools and automation will not put you in front of this type of vulnerability. For the blue team, implement solid logic and do not give more permissions than necessary to the end user.
What happened, in plain words
A security tester was hired by a company to try to break into its website on purpose, so the company could fix the problems before a real attacker found them. This kind of job is called a penetration test. While testing the part of the site where people log in, the tester looked at the "Forgot Password" feature, the button you click when you cannot remember your password.
That feature normally works like this: you type your email address, the site sends you an email with a special link, and clicking that link lets you choose a new password. What the tester found was that the link, once you clicked it, contained a number that identified which account was being reset. That number was a simple, predictable value, and the site trusted whatever number the browser sent. By changing that number, the tester could make the site reset the password of a completely different person, including the company's CEO. The tester could then log in as that person.
This kind of flaw is called an account takeover: someone else ends up in control of your account. The specific mistake, trusting a value that the user can edit, is called an IDOR (Insecure Direct Object Reference). The report was written by Cristi Vlad (@CristiVlad25).
Background ideas you need first
Before walking through the steps, here are a few everyday ideas that the rest of the article relies on.
- A web application is a program that runs on a company's computer (the server) and that you use through your browser. When you click a button, your browser sends a request to the server, and the server sends back a page.
- A URL is the address in your browser's address bar, like
https://example.com/page. The part after a?is called the query string, and it is made of parameters: little name-and-value pairs such as?colour=blue&size=large. The server reads these to decide what to show you. Crucially, you can edit them by hand in the address bar. - A user ID is a number or code that the site uses internally to tell one account apart from another. Think of it like a customer number on a loyalty card: it is not secret in itself, but it should not let anyone else spend your points.
- A token is a long, hard-to-guess string that a site gives you to prove you are allowed to do something, a bit like a cloakroom ticket. If you have the ticket, you get the coat. A good token is random and tied to one specific action.
- Encryption is scrambling information so that only someone with the right key can read it. Encoding is a different thing: it changes how information is written (for example, turning spaces into
%20) without hiding it. Encoded text can be read by anyone who knows the format; encrypted text cannot. - A hash is a fingerprint of some data: a fixed-length string produced by a one-way mathematical function. You cannot turn a hash back into the original data, but the same input always gives the same hash. The report mentions a "132-bit hash" of an unknown type, meaning the tester could see it was a hash but not which algorithm made it.
- A session is the period during which a site remembers that you are logged in, usually by storing a small piece of data in your browser called a cookie. Opening a second browser, or a private window, gives you a separate session, which is useful when you want to be logged in as two different people at once.
Setting up the test
The tester used no special tools. Everything was done by hand: request the password reset, open the email, click the link, and then look very carefully at the address the site sent the browser to. That last part is the key habit. Most people click a link and never look at the address bar; a tester reads it.
To prove the problem safely, the tester created a second account of their own, called myaccount2, in a different browser session. Having two accounts you control is the standard way to test whether one account's link can be used against another. The second account's ID was visible in the Account Settings section of the site, which gave the tester a known, correct value to compare against.
Finding it
The flow started in the usual way:
Click on "Forgot Password" ⇒ Enter Email ⇒ Submit ⇒ Check your email.
In plain words: the tester clicked the forgot-password button, typed their own email address, pressed submit, and then opened their inbox. The site immediately sent an email with a password reset link that looked something like this:
https://email.mail.redactedexample.com/c/verylongENCRYPTEDstring
Line by line: this is a web address. The first part, https://email.mail.redactedexample.com, is the domain, and it is a mail domain, separate from the main site. The /c/ is a path on that server, and verylongENCRYPTEDstring is a long scrambled value. Because it is encrypted, a casual observer cannot read anything useful out of it. Nothing looks obviously wrong at this stage, and that is the point: the first link is not where the flaw lives.
The interesting part came after clicking it. The browser was redirected to:
https://redactedexample.com/someendpoint/confirm.php?u=551234911&t=<132bitUnknownHashType>&x=2913117
Line by line: https://redactedexample.com is the main site. /someendpoint/confirm.php is the page that handles the confirmation step. Everything after the ? is the query string, and it holds three parameters separated by &:
u=551234911:ulooks like a numerical user ID, a plain number identifying an account.t=<132bitUnknownHashType>:tis a hash, described as 132-bit and of an unknown type.tis a hash, described as 132-bit and of an unknown type.x=2913117:xis another number whose purpose was not yet clear.
The page itself rendered as:
Your email is <myemail>Create new password:********************Confirm password:********************<Submit button>
Line by line: the page shows the email address of the account being reset (<myemail> is a placeholder for the tester's own address), two password boxes (the asterisks stand for hidden characters), and a submit button. In other words, this is the form where you choose your new password.
Handing the user identifier to the browser as a plain, sequential number is exactly the kind of thing that makes a tester stop and try the obvious. The tester's first thought was that it could not be that simple, but checking costs nothing.
Exploitation
Step 1: remove the x parameter
The first thing the tester did was remove the x parameter from the address and refresh the page, to see whether it made any difference. It did not: the reset page still worked without it.
Why this matters: x was there to make the link expire after some time. If the page works without it, the expiry logic can be removed by the client. Removing it is like taking the "best before" sticker off a carton and finding the shop still sells it.
Step 2: increment u
Since u looked like a numerical ID, the tester incremented it by one (added 1) and pressed enter. The page came back as:
Your email is <anotheruser'semail>Create new password:********************Confirm password:********************<Submit button>
Line by line: the same form, but now the email address shown is a different person's (<anotheruser'semail> is a placeholder). The form now belonged to another user. That single change confirmed that the application was loading the reset context purely from the u value in the address, with no check that the person holding the link was entitled to that account.
Step 3: confirm with an account I controlled
Even at that point the tester was unsure whether the reset would actually complete, so they created a second account (myaccount2) in a different browser session. Its ID was exposed in the Account Settings section. The tester copied that ID and pasted it into the address:
Line by line: this is the same confirmation page, but u now holds the ID of the tester's own second account, and the x parameter is gone. The t hash is still present, unchanged from the original link.
The tester then created and confirmed a new password, hit Submit, and was immediately logged into myaccount2's account. The takeover was real: a reset link issued for one account could be pointed at another account simply by changing u.
Why use your own second account? Because it proves the attack works end to end without harming a real person. You know the password you set, you know the account is yours, and you can see with your own eyes that you are now logged in as that account.
Step 4: walk the ID space to the CEO
To take it a step further, the tester played with the numerical ID and decremented it (subtracted 1 repeatedly) until finding the account of the CEO. The tester's own account was (supposedly) 551234911, and the CEO's account was not 1 or 000000001, but somewhere at 551003010.
Why this matters: because the IDs are sequential, you do not need to guess a random secret. You can simply walk the range, one number at a time, like trying every house number on a long street until you find the one you want. The CEO's account being around 551003010 rather than 1 just means the numbering started somewhere else; it does not make the account harder to reach.
Step 5: the x parameter and link expiry
The tester also noticed that the point of the x parameter was to invalidate the reset link after some time. Removing it also removed that entire logic, which allowed the reset URL to be used and abused days later.
In plain words: a reset link is supposed to be a one-time, short-lived thing, like a temporary door code that stops working after an hour. Here, the "stop working" part was controlled by a value in the address bar, so deleting that value meant the link never stopped working.
Root cause
The developers probably thought the link in the email was safe because the string in it was encrypted rather than encoded. But encryption at the first step is pointless if the next step hands control of the URL parameters to the end user. The confirmation endpoint trusts the u parameter supplied by the browser to decide whose password is being reset.
The expiry control lived in the x parameter, and removing it removed that logic, so the reset URL could be used days later. In the tester's opinion this is bad logic: the security decisions were made in parameters the user controls.
A useful comparison: imagine a hotel where the key card is encrypted, but the room number is written on the card in plain sight and the door opens for whatever room number you write on it. The encryption of the card does not help if the door trusts the number you scribbled on it.
Impact
An attacker who can reach the confirmation endpoint can reset the password of any account whose ID they can guess or obtain, and then log in as that user. Because the IDs are sequential, walking the range is enough to reach a chosen target; in this case it led to the CEO's account. The removal of x extends the window: a reset URL can be used days after it was issued.
Fix
The report does not say what the client changed. What the logic should do is stop trusting client-supplied parameters for identity: the confirmation step should derive the account from the token that was issued for that reset, not from a u value in the URL, and the expiry check should not depend on a parameter the user can remove. More generally, do not give the end user more permissions than necessary.
In everyday terms: the door should open based on the cloakroom ticket the hotel actually issued, checked against its own records, not based on the room number the guest writes on a scrap of paper.
Variants to test
If you ever test a similar feature, these are the variations worth trying. Each one is a small, safe experiment on accounts you control.
-
Numeric or sequential identifiers in reset links. Request a reset for your own account, then change the user identifier in the confirmation URL to a neighbouring value. A positive result is the page rendering another user's email address, or a completed reset that logs you into that account.
-
Removable parameters. Delete each parameter in the confirmation URL one at a time and resubmit. A positive result is the flow completing without the parameter that was supposed to enforce expiry or bind the token.
-
Delayed reuse. Keep a reset URL and use it days later, with and without the expiry parameter. A positive result is the link still working after its intended lifetime.
-
IDs exposed elsewhere. Check profile and settings pages for the same identifier used in reset URLs, as the Account Settings section exposed it here; a match gives you a reliable value to substitute.
The bottom line for the red team is to look closer and focus on manual testing, because tools and automation will not put you in front of this type of vulnerability. For the blue team, implement solid logic and do not give more permissions than necessary to the end user.
Glossary
- Account takeover: a situation where an attacker gains control of someone else's account, usually by changing its password or session.
- Authentication: the process of proving who you are, typically by logging in with an email and password.
- Cookie: a small piece of data a website stores in your browser so it can remember you between page loads, for example that you are logged in.
- Encoding: rewriting data in a different format (such as turning spaces into
%20) without hiding it; anyone who knows the format can read it. - Encryption: scrambling data with a key so that only someone with the key can read it.
- Hash: a fixed-length fingerprint produced from data by a one-way function; you cannot reverse it, but the same input always gives the same output.
- IDOR (Insecure Direct Object Reference): a flaw where a site lets you access an object (such as an account) by changing an identifier in a request, without checking that you are allowed to access it.
- Parameter: a name-and-value pair in a URL's query string, such as
u=551234911; the server reads it to decide what to do, and the user can edit it. - Penetration test: an authorised, simulated attack on a system, carried out to find and fix security problems before real attackers do.
- Query string: the part of a URL after the
?, made up of parameters separated by&. - Redirect: when a server tells your browser to go to a different address automatically.
- Sequential identifier: an ID that increases by a predictable step (1, 2, 3...), so that neighbouring values can be guessed easily.
- Session: the period during which a site remembers you are logged in, usually tracked with a cookie.
- Token: a long, hard-to-guess string issued by a site to prove you are allowed to perform a specific action, like a cloakroom ticket.
- URL: the address of a page or resource on the web, shown in your browser's address bar.
- User ID: a number or code a site uses internally to tell one account apart from another.
- Web application: a program that runs on a server and that you use through your browser.