Skip to content
Account takeover Write-up Intermediate

Pre Account Takeover via Missing Email Verification on Update Email && Missing Session Invalidation after Password Change

The change-email function did not verify that the user owned the new address, and sessions were never invalidated after logout or a password change. An attacker could set a victim's email on their own account, reset the password, and stay logged in alongside the victim even after the victim changed their password.

v01d19 Follow

Published on medium.com

Bug Bounty

v01d19, 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. 5 min read.

Context

This is a write-up of a chained finding on a bug bounty program the author joined, described as a pre account takeover built from two separate developer mistakes. The report does not name the program, the product or the application, and it shows no requests, responses, endpoints or parameters. What it does describe is the behaviour of two features that most authenticated web applications have: the change email function and the session handling around logout and password change.

Normally, a change email function should confirm that the user controls the address being added, usually by sending a link with a token to the new address before the change takes effect. Separately, a session should stop being valid once the user logs out or changes their password, so that anyone holding a copy of the old session cookie loses access.

Setup

The author had just signed up for the program and created an account, referred to in the reproduction steps as Account A (Attacker). No specific tools, versions or special preconditions are mentioned. The only precondition that matters is the ability to register an account and to hold on to a session cookie.

Finding it

The first thing the author noticed was that registration did require email verification: the server sent a link containing a token to prove ownership of the address. Attempts to bypass that verification failed, so the author moved on.

The habit that led to the finding is a routine the author applies on every new target: save the current session, log out, log in again, then replay the old saved session. On this target the replay worked. The author then extended the test: log out, change the password, log in again, and replay the old session once more. That also worked.

The obvious question was whether the old session only survived briefly, so the author waited about a day and tried the same old session again. It still worked.

From the original on medium.com

On Bugcrowd, the author notes, a session that is not invalidated is rated P4 on its own, so the decision was to find a way to demonstrate real impact rather than report it in isolation.

Exploitation

Step 1: change the email without verification

The author went to the change email function and tried to change the account email. There was no verification of the new address, so any address could be set as the account email.

The first attempt was to change the email to an address that already existed on the target. That did not work. The second attempt used an address that did not exist on the target, and it succeeded. This is the point where the two bugs combine.

Step 2: sign in as the new address

With the account now carrying an address that does not exist on the target, the author tried to sign in with that address. The server responded that the email already exists. The author then used the forgot password function for that address, changed the password, and logged in. At this point the attacker and the victim are in the same account.

From the original on medium.com

Step 3: confirm the attacker cannot be removed

Because the old session is never invalidated, the attacker stays logged in even when the victim changes the password, and keeps staying logged in through repeated password changes. The author never gets logged out.

From the original on medium.com

The two screenshots are labelled in the report as the attacker session and the victim session.

Steps to reproduce, as given in the report

  1. Sign into Account A (Attacker).
  2. Change the email to an email that doesn't exist, let's call it Email B.
  3. Now try to sign in with Email B (Victim).
  4. Notice that the email already exists, so use the forgot password function.
  5. Change the password and log into Account B.
  6. Now both the attacker and the victim are using the same account in the application.
  7. Notice that even after changing Account B's password, the attacker is still logged in and is never kicked out.

Root cause

The author identifies two problems:

  • The change email function does not check whether the user owns the new email address being set.
  • There is no session expiration after logging out or after changing the password.

The registration flow did have email verification, so the missing check is specific to the update email path. The session problem is independent: a session cookie that survives logout and password change means the server does not invalidate the session record, so a copy of the cookie still worked after about a day.. The report does not describe the server-side implementation, so the exact mechanism is not shown.

Impact

An attacker who registers an account can set its email to an address that does not exist on the target, then use the forgot password flow to take over that address within the application. Because the attacker's original session is never invalidated, the attacker keeps access even after the victim changes the password, repeatedly. The author describes this as a pre account takeover: the account is shared between attacker and victim, and the victim has no way to kick the attacker out.

Fix

The author's recommendations:

  • Always verify the email that the user updates to.
  • Never let a session work in all conditions; expire it after any critical action such as logout or a password change.

The reward

The submission was a duplicate. The author notes learning a lot from it.

From the original on medium.com

Variants to test

  • Change email without verification on other targets: set the account email to an address that does not exist on the target, then use forgot password. A positive result is being able to log in to the account through the reset flow for the new address.
  • Session replay after logout: save the session cookie, log out, and replay the cookie. A positive result is an authenticated response instead of a redirect to login.
  • Session replay after password change: change the password and replay the old cookie. A positive result is the old session still being accepted.
  • Session replay after a delay: wait a day or more and replay the saved cookie, to distinguish a short-lived cache from a session that is never invalidated.
  • Change email to an address that already exists on the target: the report says this did not work here, so it is worth testing on other targets to see whether the check is present or whether it fails differently.
  • Registration verification bypass: the author tried and failed here, but the same token flow is worth testing on other targets, since the update path may be weaker than registration.
From the original on medium.com

The closing advice is to chain small findings into real impact and to keep hunting.

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 joined a bug bounty program. A bug bounty program is a scheme where a company invites people to test its website and pays them for finding security problems, so the company can fix them before criminals find them. The researcher created a normal account on the website and started poking at how it works.

Two separate mistakes by the developers combined into one serious problem. The first mistake: when you change the email address on your account, the website does not check that the new address really belongs to you. The second mistake: when you log out or change your password, the website does not actually end your login session. A session is the state of being logged in: the website gives your browser a small piece of data, often called a cookie, and your browser sends it back with every request so the website knows who you are. If that piece of data keeps working after logout and after a password change, then anyone who copied it stays logged in.

Put together, the researcher could take an account, attach an email address to it that did not exist on the website, then use the website's own "forgot password" feature to set a password for that address and log in. Now two people, the attacker and the victim, are inside the same account. The victim can change the password as many times as they like, and the attacker is never thrown out. The researcher calls this a pre account takeover: a takeover of an account that is shared rather than fully stolen.

The report does not name the program, the product or the application, and it shows no requests, responses, endpoints or parameters. What it does describe is the behaviour of two features that most websites with logins have: the change email function and the session handling around logout and password change.

The two features involved

Before the story, it helps to know what these two features normally do.

Change email. Your account is identified by an email address. If you can change that address to one you do not control, you can hand your account to someone else, or take over an address that someone else will later use. So a careful website sends a confirmation link, containing a secret token, to the new address. A token here is a long random string that acts like a one-time key: only someone who can read the email can click the link and prove they own the address. Until that link is clicked, the change should not take effect.

Sessions. When you log in, the server creates a session record and gives your browser a cookie that points to it. Every later request carries that cookie, and the server looks it up to decide who you are. When you log out, or when you change your password, the server should delete that session record. If it does not, the cookie is still a valid key to your account, even in the hands of someone else. Think of it like a hotel key card: when you check out, the front desk should deactivate the card. If it does not, anyone who kept a copy can still open your room.

Setting up

The researcher had just signed up for the program and created an account, called Account A (Attacker) in the reproduction steps. No specific tools, versions or special preconditions are mentioned. The only precondition that matters is being able to register an account and to keep a copy of the session cookie.

Finding it

The first thing the researcher noticed was that registration did require email verification: the server sent a link containing a token to prove ownership of the address. Attempts to bypass that verification failed, so the researcher moved on.

The habit that led to the finding is a routine the researcher applies on every new target: save the current session, log out, log in again, then replay the old saved session. Replaying means sending the old cookie again, as if you had never logged out. On this target the replay worked. The researcher then extended the test: log out, change the password, log in again, and replay the old session once more. That also worked.

The obvious question was whether the old session only survived briefly, so the researcher waited about a day and tried the same old session again. It still worked.

From the original on medium.com

On Bugcrowd, the researcher notes, a session that is not invalidated is rated P4 on its own. Bugcrowd is a bug bounty platform, and P4 is its lowest severity rating, meaning low impact. So the decision was to find a way to demonstrate real impact rather than report it in isolation.

Exploitation

Step 1: change the email without verification

The researcher went to the change email function and tried to change the account email. There was no verification of the new address, so any address could be set as the account email.

The first attempt was to change the email to an address that already existed on the target. That did not work. The second attempt used an address that did not exist on the target, and it succeeded. This is the point where the two bugs combine.

Why does the distinction matter? If the address already exists on the website, the website probably refuses the change because two accounts cannot share one address. If the address does not exist on the website, the website accepts it, and now the account carries an address that nobody on the website has claimed yet. That is the gap the researcher walks through.

Step 2: sign in as the new address

With the account now carrying an address that does not exist on the target, the researcher tried to sign in with that address. The server responded that the email already exists. The researcher then used the forgot password function for that address, changed the password, and logged in. At this point the attacker and the victim are in the same account.

Why does this work? The forgot password feature is designed to let the owner of an address reset the password. It sends a reset link to that address, or otherwise lets whoever can receive mail at that address set a new password. Because the account now carries that address, the reset flow treats the person using it as the owner. The attacker and the victim end up sharing one account.

From the original on medium.com

Step 3: confirm the attacker cannot be removed

Because the old session is never invalidated, the attacker stays logged in even when the victim changes the password, and keeps staying logged in through repeated password changes. The researcher never gets logged out.

From the original on medium.com

The two screenshots are labelled in the report as the attacker session and the victim session.

Steps to reproduce, as given in the report

  1. Sign into Account A (Attacker).
  2. Change the email to an email that doesn't exist, let's call it Email B.
  3. Now try to sign in with Email B (Victim).
  4. Notice that the email already exists, so use the forgot password function.
  5. Change the password and log into Account B.
  6. Now both the attacker and the victim are using the same account in the application.
  7. Notice that even after changing Account B's password, the attacker is still logged in and is never kicked out.

Root cause

The researcher identifies two problems:

  • The change email function does not check whether the user owns the new email address being set.
  • There is no session expiration after logging out or after changing the password.

The registration flow did have email verification, so the missing check is specific to the update email path. The session problem is independent: a session cookie that survives logout and password change means the server does not invalidate the session record, so a copy of the cookie still worked after about a day.. The report does not describe the server-side implementation, so the exact mechanism is not shown.

Impact

An attacker who registers an account can set its email to an address that does not exist on the target, then use the forgot password flow to take over that address within the application. Because the attacker's original session is never invalidated, the attacker keeps access even after the victim changes the password, repeatedly. The researcher describes this as a pre account takeover: the account is shared between attacker and victim, and the victim has no way to kick the attacker out.

Fix

The researcher's recommendations:

  • Always verify the email that the user updates to.
  • Never let a session work in all conditions; expire it after any critical action such as logout or a password change.

The reward

The submission was a duplicate, meaning someone else had already reported the same problem. The researcher notes learning a lot from it.

From the original on medium.com

Variants to test

These are the same ideas applied to other websites, to see whether the same mistakes exist elsewhere.

  • Change email without verification on other targets: set the account email to an address that does not exist on the target, then use forgot password. A positive result is being able to log in to the account through the reset flow for the new address.
  • Session replay after logout: save the session cookie, log out, and replay the cookie. A positive result is an authenticated response instead of a redirect to login.
  • Session replay after password change: change the password and replay the old cookie. A positive result is the old session still being accepted.
  • Session replay after a delay: wait a day or more and replay the saved cookie, to distinguish a short-lived cache from a session that is never invalidated.
  • Change email to an address that already exists on the target: the report says this did not work here, so it is worth testing on other targets to see whether the check is present or whether it fails differently.
  • Registration verification bypass: the researcher tried and failed here, but the same token flow is worth testing on other targets, since the update path may be weaker than registration.
From the original on medium.com

The closing advice is to chain small findings into real impact and to keep hunting.

Glossary

  • Bug bounty program: a scheme where a company invites people to test its website and pays them for reporting security problems.
  • Account takeover: a situation where someone else gains control of your account.
  • Pre account takeover: a takeover where the account ends up shared between attacker and victim rather than fully stolen.
  • Session: the state of being logged in, tracked by the server so it knows who you are on each request.
  • Cookie: a small piece of data a website stores in your browser and your browser sends back with each request.
  • Session cookie: the cookie that points to your session record on the server; whoever holds it can act as you.
  • Session invalidation: deleting the session record on the server so the cookie stops working.
  • Replay: sending an old cookie again, as if you had never logged out.
  • Token: a long random string used as a one-time key, for example in a verification link.
  • Email verification: proving you own an email address, usually by clicking a link sent to it.
  • Change email function: the feature that lets you change the address on your account.
  • Forgot password function: the feature that lets you reset your password, usually by proving you can receive mail at the account address.
  • Endpoint: a specific address on a server that a request can be sent to.
  • Parameter: a named value sent with a request, such as an email address.
  • API: a way for programs to talk to a server, sending requests and receiving responses.
  • P4: the lowest severity rating on Bugcrowd, meaning low impact.
  • Duplicate: a report of a problem that someone else has already reported.
  • Root cause: the underlying mistake in the code or configuration that makes the problem possible.
  • Impact: the real harm a problem can cause.
  • Cache: a temporary store that keeps something for a short time; here, the idea that the old session might only work briefly.
  • Authenticated response: a response from the server that only a logged-in user would get.

More by v01d19

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.