Skip to content
Account takeover Write-up Beginner

I Changed One “User_Id” and the API Said “Sure” — From Password Reset to Mass Account Takeover

The password-reset API endpoint accepted a client-supplied user identifier and new password without requiring any authentication, OTP, reset token, or current password. An attacker could change any user's password and then log in as that user, leading to account takeover.

infosecwriteups.com

Published on infosecwriteups.com

Bug Bounty

Rajdip Chavan, on infosecwriteups.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

The target was an application whose API was being tested during an authorised API penetration test. The feature in question is the password reset endpoint, which exists to let users who have forgotten their password set a new one. In this implementation the endpoint was reachable at:

HTTP
POST /users/resetPassword

The request body was small and entirely client-supplied:

JSON
{
    "User_Id": "3",
    "New_Password": "Password@123"
}

So the client told the API which user's password to change and what the new password should be. That design is only safe if the backend independently verifies that the caller is allowed to reset that particular account. The rest of the write-up is about what happened when that verification was tested.

Setup

The testing was done with Burp Suite, using Burp Repeater to replay and modify requests. The researcher used only authorised test accounts, both for the identifier manipulation and for the login check that proved impact. No special role, token or prior state is described as a precondition: the whole point of the exercise was to find out what, if anything, the endpoint required.

Finding it

While mapping the application's API endpoints, the researcher found POST /users/resetPassword and immediately noticed that the body contained both User_Id and New_Password. In plain terms the client was saying: here is the user whose password I want to change, and here is their new password. That is acceptable only if the backend checks that the caller is entitled to reset that account, so the obvious next question was what actually authorises the reset.

Exploitation

Step 1: Remove the security controls

The approach was to delete security controls until something broke. The usual suspects were considered:

Text
Authorization: Bearer <JWT>
resetToken=<token>
otp=123456
currentPassword=<password>
verificationToken=<token>

The first thing removed was the Authorization header. The request then looked essentially like this:

HTTP
POST /users/resetPassword HTTP/2
Host: target.example
Content-Type: application/json

{
    "User_Id": "3",
    "New_Password": "Password@123"
}

The expectation was a rejection, either:

HTTP
HTTP/2 401 Unauthorized

or a body such as:

JSON
{
    "error": "Authentication required"
}

What came back instead was:

HTTP
HTTP/2 200 OK

with the body:

JSON
{
    "Status": "Success",
    "Message": "New Password reset successfully"
}
From the original on infosecwriteups.com

Step 2: Confirm that nothing else was required

The researcher first assumed something had been missed, perhaps a server-side recovery state established earlier. On checking again, none of the following were present or required: an Authorization header, an OTP, a reset token, the current password, or a session cookie. The entire security decision appeared to depend on the body field:

JSON
{
    "User_Id": "3"
}

Step 3: Change the identifier

With an identifier supplied by the client in security-sensitive functionality, the natural question is what happens when it is changed. Using only authorised test accounts, the researcher modified it:

Text
- "User_Id": "3"
+ "User_Id": "4"

while keeping:

JSON
"New_Password": "Password@123"

The API again responded:

JSON
{
    "Status": "Success",
    "Message": "New Password reset successfully"
}

Externally, the backend logic looked equivalent to a handler that looks the user up by the submitted identifier, assigns the submitted password and saves:

JavaScript
const user = await User.findById(req.body.User_Id);
user.password = req.body.New_Password;
await user.save();
return "Success";

rather than something that first checks for a valid reset token:

JavaScript
if (!validResetToken) {
    return 401;
}

The actual source code was not visible; the comparison is inferred from the observed behaviour.

Step 4: Prove the takeover

A cheerful success message is not proof of impact, so the researcher logged in with an authorised test account using the password that had been supplied through the endpoint:

Text
Username: [redacted]
Password: Password@123

The login succeeded. The chain was therefore confirmed: a known user identifier, a request to POST /users/resetPassword with no authentication, no OTP and no reset token, an attacker-chosen new password, a password change, and finally a login as the victim account.

That moved the finding from "password reset endpoint missing authentication" to "unauthenticated arbitrary password reset leading to account takeover".

Root cause

The backend trusted the client to say whose password should be changed. The User_Id in the request body was used directly to select the account, and the New_Password in the same body was written to it, with no check that the caller was entitled to reset that account. None of the controls that would normally gate a reset, namely an Authorization header, an OTP, a reset token, the current password or a session cookie, was enforced. The design flaw is authorisation logic that depends on a client-controlled identifier.

Impact

An unauthenticated attacker who knows or can guess a user identifier can set that user's password to a value of their choosing and then log in as that user. The demonstrated request used a simple numeric identifier, and the researcher described the issue as potentially leading to mass account takeover. The researcher reported it to a private bug bounty program, where it was validated as a critical account takeover vulnerability and awarded a good bounty.

Fix

The report does not describe a fix that was applied. What the observed behaviour implies is that the endpoint should require a valid, single-use reset token (or an equivalent verified recovery flow) bound to the account being reset, and should reject requests without it before any password is written. The account to be reset should be derived from that verified token rather than taken from a client-supplied User_Id.

Variants to test

  1. Drop the Authorization header from other account-management endpoints (email change, MFA reset, profile update) and see whether they still return 200 OK with a success body.
  2. Swap the identifier in any request body that names a user, such as User_Id, userId or accountId, between two authorised test accounts and check whether the response reflects the other account.
  3. Remove each of resetToken, otp, currentPassword and verificationToken one at a time from a reset request; a positive result is a success response with the control absent.
  4. Replay a reset request with no session cookie at all; a positive result is a 200 OK and a working login with the supplied password.
  5. Try a sequential identifier sweep across authorised test accounts to see whether the endpoint accepts arbitrary identifiers without any binding to the caller.

See you Again

From the original on infosecwriteups.com

The closing image is the sign-off for the write-up.

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

What happened, in plain words

A website had a "forgot my password" feature. You know the kind: you click a link, type a new password, and the site lets you back into your account. This feature is normally careful. It wants proof that you really are the person whose account you are changing.

This one was not careful. It asked the website's API to change a password, and the API did it for anyone who asked, for any account number they named. No login, no code sent to your phone, no email link, nothing. The person testing the site changed one number in the request, from their own test account to another test account, and the API cheerfully changed that account's password too.

The account number in the request was a simple number, and the researcher noted this could potentially lead to mass account takeover. That is why this kind of bug is called a mass account takeover.

The tester reported it to a private bug bounty program, where it was confirmed as a critical account takeover vulnerability and paid a good bounty.

Below is the whole story, step by step, with every request explained in ordinary words.

Some words you will meet

Before we start, a few ideas come up again and again. I will explain each one properly when it first appears, but here is a quick map so nothing feels strange.

  • An API is the part of a website that the page in your browser talks to behind the scenes. When you click a button, your browser sends a small message to the API and the API sends an answer back. Think of a restaurant: the menu and the waiter are the website you see, and the kitchen is the API. You never walk into the kitchen yourself; you tell the waiter what you want.
  • A request is one of those messages your browser sends. It has a method (what kind of action), a path (which part of the site), some headers (extra labels) and often a body (the actual data).
  • A response is the message the API sends back. It starts with a status code, a three-digit number. 200 means "fine, done". 401 means "you are not allowed, prove who you are".
  • A token or cookie is a small piece of proof that you logged in. After you sign in, the site hands your browser a string of characters and your browser shows it on every later request, like a wristband at a festival. Without the wristband, staff should not let you into the backstage area.
  • An OTP is a one-time password, the short code sent by text message or email. It proves you control the phone or inbox linked to the account.
  • Burp Suite is a tool used by security testers. It sits between your browser and the website and lets you look at, pause, edit and resend requests. Burp Repeater is one part of it: you put a request in, press Send, and see the answer, then change something and send again. It is like being able to rewrite a letter before posting it, over and over.
  • Account takeover means someone else gets into your account and can do everything you can do. Mass account takeover means doing it to lots of accounts, not just one.

1. It started with a boring password reset

While mapping out the application's API endpoints, meaning making a list of all the addresses the site's API answers on, the tester found this one:

HTTP
POST /users/resetPassword

Line by line:

  • POST is the method. It means "I am sending some data and asking you to create or change something". A GET would mean "just show me something".
  • /users/resetPassword is the path, the address of that particular feature. Read it as: under users, the resetPassword action.
  • HTTP is simply the language browsers and servers speak.

The request body, the data sent along with it, was beautifully simple:

JSON
{
    "User_Id": "3",
    "New_Password": "Password@123"
}

Line by line:

  • The curly braces hold a list of named values. This format is called JSON, and it is just a way of writing data as name and value pairs.
  • "User_Id": "3" says: the user I want to act on is number 3.
  • "New_Password": "Password@123" says: and I want their password to become this.

My tester brain noticed something straight away. The client, meaning the browser or app on the user's side, was supplying both of these values. In other words, the request was saying:

Here is the user whose password I want to change, and here is their new password.

That is fine only if the backend, the server side that does the real work, checks that the person sending the request is actually allowed to reset that account. So the obvious next question was: what actually authorises this password reset? In other words, what proof does the server demand before it believes you?

2. Time to remove things until it breaks

One of my favourite approaches when testing login and account features is extremely sophisticated: delete security controls until something breaks.

The idea is simple. A well-built feature should refuse to work if you take away the proof of who you are. So you take away each piece of proof, one at a time, and watch. If it still works, that piece of proof was not really being checked.

I started looking for the usual suspects, the things a careful password reset would normally demand:

Text
Authorization: Bearer <JWT>
resetToken=<token>
otp=123456
currentPassword=<password>
verificationToken=<token>

Line by line:

  • Authorization: Bearer <JWT> is a header, an extra label attached to the request, carrying proof that you are logged in. The Bearer part just means "whoever holds this string is the owner". A JWT is a kind of token, a signed string that the server can check.
  • resetToken=<token> would be a special code created when you ask for a password reset, usually delivered by email, so only the person with access to that inbox has it.
  • otp=123456 would be the one-time code sent to your phone or email.
  • currentPassword=<password> would be your existing password, asked for as proof before changing it.
  • verificationToken=<token> is another name for the same idea: a code that proves the request is legitimate.

Surely at least one of these would be required. So I removed the Authorization header. The request became essentially:

HTTP
POST /users/resetPassword HTTP/2
Host: target.example
Content-Type: application/json

{
    "User_Id": "3",
    "New_Password": "Password@123"
}

Line by line:

  • POST /users/resetPassword HTTP/2 is the same action as before, now spoken in version 2 of the HTTP language.
  • Host: target.example tells the server which website name the request is for. One server can host many sites, so it needs to know which one you mean.
  • Content-Type: application/json tells the server "the data below is written in JSON", so it knows how to read it.
  • The blank line separates the labels from the body.
  • The body is the same two values as before: user 3, new password Password@123.

I hit Send in Burp Repeater. What did I expect? A rejection, either:

HTTP
HTTP/2 401 Unauthorized

or a body such as:

JSON
{
    "error": "Authentication required"
}

Line by line:

  • 401 Unauthorized is the standard status code for "you have not proved who you are". It is the bouncer saying no.
  • The JSON version is the same message in words: an error field saying authentication is required.

What came back instead was:

HTTP
HTTP/2 200 OK

with the body:

JSON
{
    "Status": "Success",
    "Message": "New Password reset successfully"
}

Line by line:

  • 200 OK is the standard status code for "done, no problem".
  • "Status": "Success" says the operation worked.
  • "Message": "New Password reset successfully" says the password really was changed.
From the original on infosecwriteups.com

So the server had just changed a password for a request that carried no proof of identity at all. That is like a bank teller changing the PIN on an account because someone walked in and asked nicely.

3. Wait, where is the identifier?

At this point I assumed I had missed something. Maybe the application had previously verified something and the backend was keeping some server-side recovery state, meaning the server remembered an earlier step in the reset process and was relying on that memory.

So I checked again. None of these were present or required:

  • No Authorization header
  • No OTP
  • No reset token
  • No current password
  • No session cookie

A session cookie is the small piece of data your browser stores after you log in and sends automatically with every request to that site. It is the wristband from earlier. Its absence means the server had no idea who was calling.

The entire security decision appeared to depend on the body field:

JSON
{
    "User_Id": "3"
}

In plain words: the only thing the server looked at to decide whose password to change was a number the caller typed in. That is the whole security model. That is when things became interesting.

4. The dangerous parameter: User_Id

A parameter is just a named value inside a request, like User_Id here. The request allowed the client to specify:

JSON
"User_Id": "3"

Whenever I see identifiers like this in security-sensitive functionality, I ask one question: what happens if I change it?

This is classic API testing. If the server trusts a number that the caller controls, then the caller can simply choose a different number. It is like a cloakroom ticket where you can write any number on it yourself.

Using only authorised test accounts, I modified the identifier. For example:

Text
- "User_Id": "3"
+ "User_Id": "4"

Line by line:

  • The line starting with - is the old value, user 3.
  • The line starting with + is the new value, user 4.

And I kept:

JSON
"New_Password": "Password@123"

Then I sent the request. The API responded:

JSON
{
    "Status": "Success",
    "Message": "New Password reset successfully"
}

Interesting. Very interesting. The server had just changed the password of a different account, because I asked it to, with no proof that I had any right to that account.

The backend logic was beginning to look suspiciously like this:

JavaScript
const user = await User.findById(req.body.User_Id);
user.password = req.body.New_Password;
await user.save();
return "Success";

Line by line:

  • const user = await User.findById(req.body.User_Id); means: look up the user whose number was sent in the request body. req.body is the data the caller sent. await means wait for the database to answer.
  • user.password = req.body.New_Password; means: set that user's password to whatever the caller sent.
  • await user.save(); means: save the change to the database.
  • return "Success"; means: tell the caller it worked.

Notice what is missing: any check that the caller is allowed to do this.

Instead of something closer to:

JavaScript
if (!validResetToken) {
    return 401;
}

Line by line:

  • if (!validResetToken) means: if there is no valid reset token, in other words if the caller has not proved they own the account.
  • return 401; means: refuse, with the "you are not allowed" status code.

Obviously, I could not see the actual source code. But from the outside, the behaviour looked exactly equivalent to the first version and nothing like the second.

5. Proving account takeover

Getting a message saying "New Password reset successfully" is nice. But a security finding should demonstrate impact, meaning it should show real harm, not just trust a cheerful API response. A message can lie; a login cannot.

So, using an authorised test account, I tried logging in with the password I had supplied:

Text
Username: [redacted]
Password: Password@123

Line by line:

  • Username is the account name, here a test email address.
  • Password is the new password I had just set through the reset endpoint.

Login successful. That is the proof. The password really had changed, and I could really get in.

At this point the vulnerability chain was confirmed:

Text
Known User ID
      │
      ▼
POST /users/resetPassword
      │
      ▼
No Authentication
      │
      ▼
No OTP
      │
      ▼
No Reset Token
      │
      ▼
Attacker chooses New_Password
      │
      ▼
Password Changed
      │
      ▼
Login as Victim
      │
      ▼
💀 ACCOUNT TAKEOVER

Read it top to bottom as a chain of events. You know a user number. You send a reset request. Nothing checks who you are. Nothing asks for a code. Nothing asks for a token. You pick the new password. The password changes. You log in as the other person. That is account takeover.

That changed the finding from "password reset endpoint missing authentication" to "unauthenticated arbitrary password reset leading to account takeover". In plain words: anyone, without logging in, can set any password they like on any account, and then use it. Much bigger problem.

6. Conclusion and reporting

I reported this vulnerability to a private bug bounty program, where it was validated as a critical account takeover vulnerability and awarded a good bounty.

A bug bounty program is an arrangement where an organisation invites security researchers to test its systems and pays for valid findings. A private program means only invited researchers can take part.

This finding was a good reminder that some of the most severe vulnerabilities do not always require complicated exploitation techniques. In this case, simply manipulating a client-controlled User_Id, a number the caller could type freely, allowed an attacker to reset another user's password without proper authentication or verification, potentially leading to mass account takeover.

7. See you again

From the original on infosecwriteups.com

The closing image is the sign-off for the write-up.

Glossary

  • API: the part of a website that the page in your browser talks to behind the scenes, receiving requests and sending answers.
  • Request: a message sent to a server asking it to do something, made of a method, a path, headers and often a body.
  • Response: the message a server sends back, starting with a status code.
  • Status code: a three-digit number in a response saying how it went, such as 200 for success or 401 for not allowed.
  • 200 OK: the standard status code meaning the request succeeded.
  • 401 Unauthorized: the standard status code meaning the caller has not proved who they are.
  • POST: an HTTP method meaning "I am sending data and asking you to create or change something".
  • GET: an HTTP method meaning "just show me something".
  • HTTP: the language browsers and servers use to exchange requests and responses.
  • HTTP/2: version 2 of that language.
  • Header: an extra label attached to a request or response, such as Host or Content-Type.
  • Host header: tells the server which website name the request is for.
  • Content-Type header: tells the server what format the body is written in, such as JSON.
  • Body: the actual data carried inside a request or response.
  • JSON: a simple way of writing data as name and value pairs inside curly braces.
  • Parameter: a named value inside a request, such as User_Id.
  • Endpoint: one specific address of an API that performs one specific action, such as POST /users/resetPassword.
  • Client: the browser or app on the user's side that sends requests.
  • Backend: the server side that does the real work, such as looking things up in a database.
  • Server-side state: information the server remembers between requests, such as an earlier step in a reset process.
  • Authentication: proving who you are, for example by logging in.
  • Authorisation: deciding whether a proven user is allowed to do a particular thing.
  • Token: a string of characters used as proof of identity or permission.
  • JWT: a kind of signed token the server can check.
  • Bearer token: a token where whoever holds the string is treated as its owner.
  • Authorization header: the header that carries proof you are logged in.
  • Session cookie: a small piece of data your browser stores after login and sends automatically with later requests to that site.
  • Cookie: a small piece of data a site asks your browser to store and send back later.
  • OTP: a one-time password, a short code sent by text message or email to prove you control the account.
  • Reset token: a special code created for a password reset, usually delivered by email, proving the requester owns the account.
  • Verification token: another name for a code that proves a request is legitimate.
  • Current password check: asking for your existing password as proof before changing it.
  • Password reset: the feature that lets someone who forgot their password set a new one.
  • Identifier: a value that names a particular record, such as a user number.
  • Client-controlled value: a value the caller can type freely, which the server must therefore not trust for security decisions.
  • Burp Suite: a tool security testers use to inspect, pause, edit and resend requests between a browser and a website.
  • Burp Repeater: the part of Burp Suite where you put in a request, press Send, see the answer, change something and send again.
  • Penetration test: an authorised exercise in which a tester tries to break into a system to find weaknesses before criminals do.
  • Bug bounty program: an arrangement where an organisation invites researchers to test its systems and pays for valid findings.
  • Private bug bounty program: a bug bounty program open only to invited researchers.
  • Bounty: the payment made for a valid finding.
  • Vulnerability: a weakness in a system that can be used to cause harm.
  • Account takeover: getting into someone else's account and being able to do everything they can do.
  • Mass account takeover: taking over many accounts, not just one.
  • Impact: the real harm a vulnerability can cause, as opposed to a message that merely claims success.
  • Root cause: the underlying mistake that makes a vulnerability possible.
  • Exploit chain: a series of steps that together achieve an attack.
  • Test account: an account set up for testing, which the tester is authorised to use.

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.