Skip to content
Account takeover Write-up Intermediate

How I could have compromised any account on one of the biggest startup based in California

The password reset link contained a user ID and two tokens, one of which was a base64-encoded email address. By crafting a reset request with a victim's user ID, a base64-encoded email, and a self-generated 16-character token, an attacker could reset any user's password without interaction, leading to full account takeover.

Prateek Tiwari Follow

Published on medium.com

This blog is about a severe vulnerability which was being discovered on one of the biggest startup based in California. Since I’m not authorized to reveal the companies name so I’ll just try and keep the name as Private Company here!

Prateek Tiwari, 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. 6 min read.

Context

The target was a web application belonging to what the author describes as one of the biggest startups based in California. The company is not named in the write-up, so it is referred to throughout as Private Company. The author notes that the company did not run a bug bounty programme at the time, and that he found the application through advertising that Facebook kept showing him.

The feature in question is the standard forgotten-password flow. A user who has forgotten their password visits the forgot-password page, enters their email address, and the application emails them a link to set a new password. The author's general point is that password recovery is often bolted on without the same care as authentication itself, and that the recovery flow can undermine the protection the rest of the application provides.

Setup

No special tooling, versions or roles are described. The author signed up for an ordinary account, browsed the application for 10 to 15 minutes, and signed out. The attack requires the ability to request a password reset for an account whose email address you control, plus the victim's user ID and email address.

To avoid touching a real user's account, the author created a second account of his own and used it as the victim for testing. He also notes that user IDs and email addresses were easy to obtain: they were not encrypted, and they were passed in GET requests, so visiting another user's profile revealed both the user ID and the email address.

Finding it

On the way out, the author looked at the reset-password link in the email. It had the following shape:

Text
https://www.domain.com/authentication/resetpas/userID?key=<token>&auth=<token>

The user ID sits directly in the path of the reset link, and two tokens follow it as query parameters. The immediate reaction, in the author's words, was that changing the user ID to any other user's ID might be enough to reset that user's password.

From the original on medium.com

The screenshot accompanies the reset link, with the user ID in the path and the key and auth parameters in the query string, which prompted the idea of swapping the user ID.

Exploitation

Step 1: swap the user ID in the reset link

With a second account created and its user ID known, the author changed the user ID in the reset link to that of the second account and submitted the request for a new password. The application answered with a success message.

That success was misleading. When he tried to log in to the second account with the new password, the login failed. The password that had actually changed was the one belonging to the account that originally requested the reset. In other words, the application generated a user ID for the link but did not use it to decide whose password to change. The author's conclusion was that the user ID in the URL was decorative.

Step 2: examine the tokens

The next target was key=<token>. The author tried to decrypt it many times without success. It was a 16-character string, and his first guess, that it was base64, was wrong. The second parameter, auth=<token>, was also a 16-character string, but because the first token had resisted his attempts he left this one alone at this stage, a decision he later calls foolish.

Step 3: request a fresh link and look at auth

He requested another reset link, this time for a newly created account, and noticed that the auth value ended with an equals sign, which is characteristic of base64 padding. Decoding it produced an email address, the address of the person who had requested the reset. The auth parameter was therefore a base64-encoded email, not an opaque token.

Step 4: combine the pieces and fail

The key value still would not decode. The author tried reusing the same key while replacing auth with the base64 encoding of a newly created account's email and changing the user ID as well. The request did not succeed. He then tried removing the key parameter from the POST request altogether, and again there was no success.

Step 5: forge a key

He requested four or five more password resets and observed the key values. Each was a different string but always in the same format. He then generated a 16-character string of his own in that same format and submitted it together with the other values. This time the application returned success, and the password of the victim account really did change.

From the original on medium.com

The screenshot accompanies the final attempt, after which the message was SUCCESS and the victim account's password had been changed.

Step 6: lock the owner out

Once the password was changed, the attacker could log in immediately. The application also allowed the email address on the account to be changed from inside the account. Changing the email meant the original owner could no longer log in and could no longer reset the password, because a reset request for their old address would be rejected as an unknown username. The author describes this as full compromise, with access to basic details, payment and bank details, and private chats.

Root cause

The reset flow trusted values supplied by the client rather than binding the reset to server-side state. The user ID in the path was generated but not used to select the account, so it could be changed freely. The auth parameter was simply base64 of the requester's email, which is trivially forgeable. A self-generated 16-character string in the same format as observed key values was accepted, so the key provided no integrity guarantee. An attacker who could produce values in the right shapes could reset another account, as the author demonstrated. The report does not describe the server-side implementation, so the exact check that accepted the forged key is not stated.

Impact

Any user's account could be taken over without any interaction from the victim, provided the attacker knew or could obtain the victim's user ID and email address, which the author says were exposed in GET requests and on profile pages. The attacker would then have access to all of the account's data, including payment and bank details and private messages, and could change the account's email address to lock the owner out. The author frames this as a severe vulnerability affecting any account on the service.

Fix

The company took the password reset feature down within 20 minutes of the report, on 25 January 2017, after reproducing the bug. On 27 January 2017 the bug was fixed and the author confirmed the fix. The report does not describe the code change that was made. A correct fix would bind the reset to a server-side record created when the reset was requested, use an unguessable token rather than a formatted string, and ignore any user ID or email supplied by the client when deciding whose password to change.

Variants to test

  1. Change the user ID in a reset link's path while keeping the tokens. A positive result is that the password of the account matching the new user ID changes, or that the response differs in a way that shows the ID is used.
  2. Base64-decode every parameter in a reset link. A positive result is readable data such as an email address or username, which can then be re-encoded with a different value.
  3. Replace a token with a value of the same length and character set. A positive result is that the reset succeeds, showing the token is checked for format only.
  4. Remove individual parameters from the reset POST request. A positive result is that the request still succeeds without one of them, showing it is not validated.
  5. Request several resets and compare the tokens. A positive result is a predictable pattern, such as a fixed length with a changing but guessable component.
  6. After a successful reset, try changing the account's email address. A positive result is that the change is accepted without further verification, which turns a password reset into a permanent lockout.

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

What happened, in plain words

A security researcher found a way to take over any user account on a large company's website, without the victim doing anything at all. The company is not named in the write-up, so it is called Private Company throughout. The researcher found the site through advertising that Facebook kept showing him, and he notes that the company did not run a bug bounty programme at the time, meaning there was no official scheme paying people for finding bugs.

The weak spot was the "forgot my password" feature, the one almost every website has. You click a link, type your email address, and the site emails you a link that lets you set a new password. The researcher found that the link contained values he could change or fake, and that the site trusted those values. By editing them, he could make the site reset the password of a different account, one he did not own.

To understand why this matters, it helps to know what a password reset link is for. It is a proof of identity: it says "whoever holds this link controls this email address, so let them set a new password". If an attacker can build or edit such a link so that it points at someone else's account, the whole protection collapses. The researcher's broader point is that companies often build the login screen carefully and then bolt on password recovery without the same care, and the recovery flow ends up undermining everything else.

The setup

The write-up describes no special tools, software versions or user roles. The researcher signed up for an ordinary account, browsed the site for 10 to 15 minutes, and signed out. That is the entire preparation. The attack requires the ability to request a password reset for an account whose email address you control, plus the victim's user ID and email address.

To avoid touching a real person's account, he created a second account of his own and used that as the "victim" for testing. This is a standard safety habit: prove the bug on data you own before going anywhere near someone else's.

He also noticed something that made the attack easier. User IDs and email addresses were easy to obtain: they were not encrypted, and they were passed in GET requests. A GET request is the ordinary kind of request your browser makes when you open a page or click a link; its details, including any values after a question mark in the URL, are visible in the address bar and in the page's network traffic. So simply visiting another user's profile page revealed both that user's ID and their email address.

Finding it

On his way out, the researcher looked at the reset-password link in the email. It had this shape:

Text
https://www.domain.com/authentication/resetpas/userID?key=<token>&auth=<token>

Line by line:

  • https://www.domain.com/authentication/resetpas/ is the address of the page that handles the reset. domain.com stands in for the real company's domain.
  • userID sits in the path, the part of the URL that names which page or resource you want. Here it names which user the reset is for.
  • ? marks the start of the query string, a set of extra values attached to the URL.
  • key=<token> is the first of those values. A token here means a short string of characters the site generates, meant to act like a temporary pass or ticket proving the link is genuine.
  • & separates one query value from the next.
  • auth=<token> is the second value, another short string.

The user ID sits directly in the path of the reset link, and two tokens follow it. The researcher's immediate reaction, in his own words, was that changing the user ID to any other user's ID might be enough to reset that user's password.

From the original on medium.com

The screenshot accompanies the reset link, with the user ID in the path and the key and auth parameters in the query string. Seeing the user ID sitting there in plain sight is what prompted the idea of swapping it.

Exploitation

Step 1: swap the user ID in the reset link

With a second account created and its user ID known, the researcher changed the user ID in the reset link to that of the second account and submitted the request for a new password. The application answered with a success message.

That success was misleading. When he tried to log in to the second account with the new password, the login failed. The password that had actually changed was the one belonging to the account that originally requested the reset. In other words, the application generated a user ID for the link but did not use it to decide whose password to change. The researcher's conclusion was that the user ID in the URL was decorative: it looked meaningful but had no effect.

This is a useful lesson for anyone testing a site. A success message is not proof that the thing you intended happened. Always check the actual outcome, here by trying to log in.

Step 2: examine the tokens

The next target was key=<token>. The researcher tried to decrypt it many times without success. It was a 16-character string, and his first guess, that it was base64, was wrong.

Base64 is a way of writing data using only letters, digits and a couple of symbols, so it can travel safely inside URLs and emails. It is not encryption: anyone can decode it. The researcher's guess was reasonable because base64 strings often look like random characters, but decoding this one did not produce anything readable.

The second parameter, auth=<token>, was also a 16-character string, but because the first token had resisted his attempts he left this one alone at this stage, a decision he later calls foolish.

Step 3: request a fresh link and look at auth

He requested another reset link, this time for a newly created account, and noticed that the auth value ended with an equals sign. In base64, an equals sign at the end is padding: it fills out the string to the right length. Seeing it is a strong hint that the value is base64-encoded data.

Decoding it produced an email address, the address of the person who had requested the reset. The auth parameter was therefore a base64-encoded email, not an opaque token. "Opaque" means a value whose contents mean nothing to an outsider; this one was the opposite, readable once decoded.

Step 4: combine the pieces and fail

The key value still would not decode. The researcher tried reusing the same key while replacing auth with the base64 encoding of a newly created account's email and changing the user ID as well. The request did not succeed. He then tried removing the key parameter from the POST request altogether, and again there was no success.

A POST request is the kind your browser sends when you submit a form, such as the form where you type a new password. Unlike a GET request, its contents are not shown in the address bar, but they can still be seen and edited with browser developer tools or an intercepting proxy, a program that sits between your browser and the site and lets you change requests before they are sent.

Step 5: forge a key

He requested four or five more password resets and observed the key values. Each was a different string but always in the same format. He then generated a 16-character string of his own in that same format and submitted it together with the other values. This time the application returned success, and the password of the victim account really did change.

This is the heart of the bug. The site was checking only that the key looked right, not that it was one it had actually issued. A real token should be impossible to guess and should be stored on the server so it can be checked against the record of the reset request. A string that merely has the right shape proves nothing.

From the original on medium.com

The screenshot accompanies the final attempt, after which the message was SUCCESS and the victim account's password had been changed.

Step 6: lock the owner out

Once the password was changed, the attacker could log in immediately. The application also allowed the email address on the account to be changed from inside the account. Changing the email meant the original owner could no longer log in and could no longer reset the password, because a reset request for their old address would be rejected as an unknown username. The researcher describes this as full compromise, with access to basic details, payment and bank details, and private chats.

Root cause

The reset flow trusted values supplied by the client rather than binding the reset to server-side state. "Client" means the browser, which the attacker controls; "server-side state" means a record kept on the company's own computers. The user ID in the path was generated but not used to select the account, so it could be changed freely. The auth parameter was simply base64 of the requester's email, which is trivially forgeable. A self-generated 16-character string in the same format as observed key values was accepted, so the key provided no integrity guarantee. An attacker who could produce values in the right shapes could reset another account, as the researcher demonstrated. The report does not describe the server-side implementation, so the exact check that accepted the forged key is not stated.

Impact

Any user's account could be taken over without any interaction from the victim, provided the attacker knew or could obtain the victim's user ID and email address, which the researcher says were exposed in GET requests and on profile pages. The attacker would then have access to all of the account's data, including payment and bank details and private messages, and could change the account's email address to lock the owner out. The researcher frames this as a severe vulnerability affecting any account on the service.

Fix

The company took the password reset feature down within 20 minutes of the report, on 25 January 2017, after reproducing the bug. On 27 January 2017 the bug was fixed and the researcher confirmed the fix. The report does not describe the code change that was made. A correct fix would bind the reset to a server-side record created when the reset was requested, use an unguessable token rather than a formatted string, and ignore any user ID or email supplied by the client when deciding whose password to change.

Variants to test

If you ever look at a password reset flow yourself, these are the things worth trying, in plain terms:

  1. Change the user ID in a reset link's path while keeping the tokens. A positive result is that the password of the account matching the new user ID changes, or that the response differs in a way that shows the ID is used.
  2. Base64-decode every parameter in a reset link. A positive result is readable data such as an email address or username, which can then be re-encoded with a different value.
  3. Replace a token with a value of the same length and character set. A positive result is that the reset succeeds, showing the token is checked for format only.
  4. Remove individual parameters from the reset POST request. A positive result is that the request still succeeds without one of them, showing it is not validated.
  5. Request several resets and compare the tokens. A positive result is a predictable pattern, such as a fixed length with a changing but guessable component.
  6. After a successful reset, try changing the account's email address. A positive result is that the change is accepted without further verification, which turns a password reset into a permanent lockout.

Glossary

  • Account takeover: gaining control of someone else's account, usually by changing their password or email so the real owner is locked out.
  • API: a way for one piece of software to talk to another, here the set of addresses and requests the website uses behind the scenes.
  • Base64: a way of writing data using only letters, digits and a few symbols so it can travel safely in URLs and emails. It is encoding, not encryption; anyone can decode it.
  • Bug bounty programme: an official scheme where a company pays researchers for reporting security bugs.
  • Client: the browser or program on the user's side, which the attacker controls.
  • Cookie: a small piece of data a site stores in your browser to remember who you are between requests.
  • Decrypt: turn scrambled data back into readable form. Strictly, base64 is decoded rather than decrypted, but the write-up uses the word loosely.
  • Developer tools: the built-in panel in a browser that lets you inspect and edit requests and responses.
  • Forgot-password / reset-password flow: the feature that emails you a link so you can set a new password when you cannot log in.
  • GET request: the ordinary request a browser makes when you open a page or click a link; its values appear in the URL.
  • IDOR (Insecure Direct Object Reference): a bug where a site lets you access someone else's data just by changing an identifier such as a user ID in a request.
  • Integrity: the guarantee that data has not been altered or forged.
  • Intercepting proxy: a program that sits between your browser and a site and lets you view and change requests before they are sent.
  • Opaque token: a value whose contents mean nothing to an outsider, so it cannot be guessed or edited meaningfully.
  • Padding: extra characters added to the end of encoded data to make it the right length; in base64 it is usually one or two equals signs.
  • Password reset: the process of setting a new password when you have forgotten the old one.
  • POST request: the request a browser sends when you submit a form; its contents are not shown in the address bar but can still be edited.
  • Query string: the part of a URL after the question mark, made of name=value pairs separated by ampersands.
  • Server-side state: information the company's own computers keep about a request, which the user cannot edit.
  • Token: a short string a site generates to act as a temporary pass or ticket, meant to prove a request is genuine.
  • User ID: the number or string that identifies a particular account.
  • Vulnerability: a weakness in software that an attacker can use to do something the owner did not intend.

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.