I Wasn’t Hunting an Email Bug. I Just Changed One Word (ATO).
The email-change endpoint lacked OTP verification and allowed assigning an email already registered to another account. By changing the operation word in the API path from 'password' to 'email', an attacker could reassign any existing email and impersonate privileged users, leading to account takeover.
medium.com
Published on medium.com
Cybersecurity
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 is a web application with an authenticated user profile API under /api/auth/v1/user-info/. The feature in scope is the account email-change workflow. As described, that workflow was designed to be secure: changing the email required OTP verification, and assigning an email address that already belonged to another account was blocked.
The author, Mahmoud Adel (El7xoot), was not auditing that workflow. He was testing password change, and the email-change weakness surfaced from the shape of the password endpoint.
Setup
The report does not describe the accounts, roles or tooling used, beyond inspection of the application's API traffic. The requests shown are sent to my.example.com with a Host header, and the user identifier appears in the path as <user_id>. No versions, frameworks or proxy tools are named.
Finding it
The password-change request looked like this:
PATCH /api/auth/v1/user-info/<user_id>/password
Host: my.example.com
{"oldPassword":"plapla","newPassword":"plapla","confirmPassword":"plapla"}
What drew attention was the structure rather than the parameters: the action itself, password, was a segment of the URL path. That raised a simple question: is password actually an operation name, and if so, which other operation names does the same route accept?
The email-change request shown in the report, by contrast, was a different shape entirely:
PATCH /api/auth/v1/user-info/
Host: my.example.com
{"email":"[redacted]"}
The email-change workflow required OTP verification and blocked addresses already tied to another account.
Exploitation
Step 1: swap the operation name in the path
Keeping the password-change request intact and changing only the final path segment from password to email:
PATCH /api/auth/v1/user-info/<user_id>/email
with the body:
{
"email": "[redacted]"
}
The server returned 200 OK. No OTP was requested, no email confirmation was involved, and the target address was already registered to another account, which the documented email-change workflow blocked. The alternate path performed the email change without the OTP check and without the duplicate-email check.
At this point the author had an email-change bypass.
Step 2: follow where the email is trusted
The more interesting question was where else the application trusts this email value. The answer was several sensitive workflows. The reassigned email was treated as the user's identity, which allowed crossing into privileged account functionality and ultimately reaching account takeover.
The chain, as the author lays it out:
/password
↓
/email
↓
OTP bypass
↓
Assign any existing email
↓
Identity impersonation
↓
Privileged/Admin identity
↓
Account Takeover
Root cause
The application enforced its security controls on the intended email-change endpoint but failed to enforce the same controls on an alternate operation exposed through the API path. The path segment appeared to act as an operation selector, and the alternate selector performed the change without the OTP check and without the duplicate-email check.
Compounding this, a mutable email address was being trusted as an identity boundary across sensitive workflows. Once the email could be reassigned to an address belonging to another account, downstream logic that keyed identity off that email treated the attacker as that identity. The report does not show the downstream code or the mechanism by which privileged functionality was reached.
Impact
The author lists the following impact:
- OTP verification bypass.
- Assigning any existing email address.
- Assigning privileged or admin-associated emails.
- Identity impersonation.
- Account takeover (ATO).
Fix
Based on the root cause, the controls applied to the intended email-change endpoint need to be enforced on every operation reachable through the same route, so that the path segment cannot select a handler that skips OTP verification and the duplicate-email check. Separately, mutable attributes such as email should not serve as an identity boundary for authorisation decisions; identity should be tied to an immutable account identifier.
Variants to test
- Operation-name substitution on REST paths. Take any endpoint of the form
/resource/<id>/<action>and swap<action>for sibling operations such asemail,phone,mfa,recovery,delete. A positive result is a 200 with the state change applied and no step-up verification. - Parallel endpoint shapes. Where one sensitive action uses a body parameter and another uses a path segment, try moving the value between them. A positive result is the same action succeeding through the less-guarded shape.
- Duplicate-value checks on alternate routes. Register an address already bound to another account through the alternate path. A positive result is acceptance where the documented endpoint rejects it.
- Downstream identity trust. After reassigning an email, exercise workflows that resolve the user by email (password reset, invitations, admin panels). A positive result is access to another account's context.
- Method and casing variations. Try
PUT,POSTand case variants of the operation segment against the same route. A positive result is a handler that responds successfully without the controls seen on the canonical endpoint.
What happened, in plain words
A security researcher was testing a normal feature on a website: changing a password. While looking at how the website's behind-the-scenes requests were built, he noticed something odd about the address (the URL) used for that request. One word in that address, password, looked like it was telling the server which action to perform. So he tried swapping that single word for another one, email, and sent the request again. The server accepted it and changed the account's email address, even though the normal email-change feature was supposed to require a one-time code and was supposed to refuse email addresses already used by other accounts.
Because the website trusted that email address as proof of who the user was in other parts of the system, being able to set it to someone else's address let him act as that person, up to and including taking over their account.
This article walks through the same steps for someone who has never done security testing before. Every request shown is copied exactly as it appeared in the write-up.
Background: the words you need first
Before the steps, a few everyday ideas. You do not need to memorise them; each one is used again later.
- Web application: a program you use through your browser. When you click a button, your browser sends a message to a server (a computer somewhere else), and the server sends back a reply.
- API: the set of message addresses and formats a web application uses behind its pages. Think of a restaurant: the menu page you see is the website, and the API is the waiter who carries your order to the kitchen in a fixed format. The kitchen only understands orders written in that format, not in the words you would use at the table.
- Endpoint: one specific address in that API, for example the one that handles password changes. Each endpoint is like one counter in a post office: you go to the right counter for the right job.
- HTTP method: the verb at the start of a request that says what kind of action you want.
GETmeans "give me something",POSTmeans "create something",PATCHmeans "change part of something". - URL path: the part of a web address after the site name, such as
/api/auth/v1/user-info/. It is like a folder path on your computer, and each segment between slashes is one step down. - Request body: the extra data sent along with a request, usually in a format called JSON, which looks like
{"name": "value"}. It is the contents of the envelope, while the URL is the address written on the front. Hostheader: a small line sent with every request that names the website you are talking to. One server can host many websites, so it needs to be told which one you mean.<user_id>: a placeholder for a number or code that identifies a particular user account. The angle brackets mean "put the real value here".- OTP (one-time password): a short code, often sent by email or text message, that you must type in to prove it is really you. It is like a temporary key that only works once.
- Authentication: proving who you are, usually by logging in. Authorisation is a separate question: what are you allowed to do once you are in.
- Account takeover (ATO): when an attacker gains control of someone else's account, for example by being able to log in as them or change their settings.
- Bypass: getting past a protection without satisfying it, the way you might get into a building through a side door that was left unlocked while the front door had a guard.
The feature that was supposed to be safe
The application had a workflow for changing the email address on an account. According to the write-up, that workflow was designed carefully:
- Changing the email required OTP verification, so you had to prove you controlled the account before the change went through.
- Assigning an email address that already belonged to another account was blocked, so you could not claim someone else's address.
Those two rules are the guard at the front door. Keep them in mind, because the whole story is about a side door that had no guard.
The researcher was not testing that feature at all. He was testing password change, a different feature. The email weakness surfaced from the shape of the password request.
The password request that started it
While inspecting the API traffic, he found the password-change request:
PATCH /api/auth/v1/user-info/<user_id>/password
Host: my.example.com
{"oldPassword":"plapla","newPassword":"plapla","confirmPassword":"plapla"}
Line by line:
PATCHis the method: "change part of an existing thing"./api/auth/v1/user-info/<user_id>/passwordis the path. Reading it left to right: this is the API (/api), the authentication area (/auth), version 1 of it (/v1), the user information area (/user-info), then a specific user (<user_id>), then the wordpassword.Host: my.example.comtells the server which website this request is for.- The blank line separates the address and headers from the body.
- The body is JSON with three fields: the current password, the new password, and a confirmation of the new password. The values
plaplaare just placeholder text.
What caught his attention was not the fields but the structure. The action itself, the word password, was part of the URL, not part of the body. That is unusual. Normally you would expect something like /user-info/<user_id> with a body saying what to change. Here the URL itself seemed to be naming the operation.
So he asked a simple question: is password actually an operation name? And if it is, what other operation names does the same route accept?
That question is the heart of the whole finding. It is like noticing that a shop's back door has a sign saying "deliveries" and wondering whether changing the sign to "staff" would let you in.
The email request, for comparison
The email-change request shown in the write-up had a different shape entirely:
PATCH /api/auth/v1/user-info/
Host: my.example.com
{"email":"[redacted]"}
Line by line:
- Same method,
PATCH, and sameHostheader. - The path stops at
/user-info/. There is no<user_id>and no action word at the end. - The body carries a single field,
email, with the new address.
This is the guarded front door. The email-change workflow required OTP verification and rejected addresses already tied to another account.
Step 1: change one word in the path
He kept the password-change request exactly as it was and changed only the final path segment, from password to email:
PATCH /api/auth/v1/user-info/<user_id>/email
with the body:
{
"email": "[redacted]"
}
Line by line:
- The method, the host, the user identifier and everything up to the last slash are unchanged.
- The last word is now
emailinstead ofpassword. - The body is JSON with one field,
email, set to the address[redacted].
Why do this? Because if the server treats the last word as "which operation to run", then email should run the email-change operation. The question was whether that route would apply the same protections as the documented email endpoint, or whether it would run the change with no checks at all.
The server returned 200 OK. In HTTP, 200 means "success, here is the result".
What that meant in practice:
- No OTP was requested.
- No email confirmation was involved.
- The target address was already registered to another account, which the documented workflow blocked.
So the alternate path performed the email change without the OTP check and without the duplicate-email check. At this point he had an email-change bypass: the protection existed, but a different route reached the same action without it.
Step 2: follow where the email is trusted
An email-change bypass on its own is already a problem, but he did not stop there. He asked the more interesting question: where else does the application trust this email value?
The answer, according to the write-up, was several sensitive workflows. The reassigned email was treated as the user's identity. That let him cross into privileged account functionality and ultimately reach account takeover.
The chain, as he lays it out:
/password
↓
/email
↓
OTP bypass
↓
Assign any existing email
↓
Identity impersonation
↓
Privileged/Admin identity
↓
Account Takeover
Reading the chain from top to bottom:
/password: the endpoint he was originally looking at./email: the same route with one word swapped.- OTP bypass: the one-time code check was skipped.
- Assign any existing email: he could set the account's email to an address already used by someone else.
- Identity impersonation: because the system treated the email as the identity, he was now treated as that other person.
- Privileged/Admin identity: that other person had elevated rights, so he inherited them.
- Account takeover: full control of the other account.
The everyday comparison: imagine a building where your name badge is checked at the front desk, but once inside, every door simply reads the name written on a sticky note on your chest. If you can rewrite the sticky note, every door opens for you.
Root cause
The application enforced its security controls on the intended email-change endpoint, but failed to enforce the same controls on an alternate operation exposed through the API path. The path segment acted as an operation selector, and the alternate selector reached the same handler without the OTP check and without the duplicate-email check.
In plain words: the guard was standing at one door, but the same room had a second door with no guard, and the URL was the thing that chose which door you used.
Compounding this, a mutable email address was being trusted as an identity boundary across sensitive workflows. "Mutable" means changeable. An email address can be edited by the user, so it is a poor thing to use as proof of identity. Once the email could be reassigned to an address belonging to another account, downstream logic that keyed identity off that email treated the attacker as that identity.
The write-up does not show the downstream code or the mechanism by which privileged functionality was reached.
Impact
The author lists the following impact:
- OTP verification bypass.
- Assigning any existing email address.
- Assigning privileged or admin-associated emails.
- Identity impersonation.
- Account takeover (ATO).
The write-up does not describe the specific privileged workflows reached.
Fix
Based on the root cause, the controls applied to the intended email-change endpoint need to be enforced on every operation reachable through the same route, so that the path segment cannot select a handler that skips OTP verification and the duplicate-email check. Separately, mutable attributes such as email should not serve as an identity boundary for authorisation decisions; identity should be tied to an immutable account identifier, meaning something that cannot be changed, such as an internal account number.
Variants to test
These are follow-up ideas for anyone testing similar applications.
- Operation-name substitution on REST paths. Take any endpoint of the form
/resource/<id>/<action>and swap<action>for sibling operations such asemail,phone,mfa,recovery,delete. A positive result is a 200 with the state change applied and no step-up verification. - Parallel endpoint shapes. Where one sensitive action uses a body parameter and another uses a path segment, try moving the value between them. A positive result is the same action succeeding through the less-guarded shape.
- Duplicate-value checks on alternate routes. Register an address already bound to another account through the alternate path. A positive result is acceptance where the documented endpoint rejects it.
- Downstream identity trust. After reassigning an email, exercise workflows that resolve the user by email (password reset, invitations, admin panels). A positive result is access to another account's context.
- Method and casing variations. Try
PUT,POSTand case variants of the operation segment against the same route. A positive result is a handler that responds successfully without the controls seen on the canonical endpoint.
Glossary
- API: the set of message addresses and formats a web application uses behind its pages, so programs can talk to it in a fixed way.
- Endpoint: one specific address in an API that performs one job, such as changing a password.
- HTTP method: the verb at the start of a request (
GET,POST,PATCH,PUT) that says what kind of action you want. - PATCH: an HTTP method meaning "change part of an existing thing".
- URL path: the part of a web address after the site name, made of segments separated by slashes.
- Path segment: one piece of a URL path between two slashes, such as
passwordor<user_id>. - Request body: the extra data sent with a request, often in JSON.
- JSON: a text format for structured data, written as
{"name": "value"}. Hostheader: a line sent with a request naming which website on the server you are talking to.<user_id>: a placeholder for the value that identifies a particular user account.- OTP (one-time password): a short code that proves it is really you and works only once.
- Authorisation: what you are allowed to do once you are logged in.
- Bypass: getting past a protection without satisfying it.
- Account takeover (ATO): gaining control of someone else's account.
- Identity impersonation: being treated by the system as another person.
- Mutable: able to be changed. An email address is mutable; an internal account number usually is not.
- Immutable identifier: a value that cannot be changed and is therefore safer to use as proof of identity.
- Root cause: the underlying reason a weakness exists, as opposed to its visible symptom.
- Handler: the piece of server code that actually performs an action when a request reaches it.
- 200 OK: the HTTP status code meaning the request succeeded.
- REST: a common style of designing APIs around addresses and standard HTTP methods.
- Step-up verification: asking for an extra proof, such as an OTP, before a sensitive action.
- Canonical endpoint: the documented, intended address for an action, as opposed to an alternate route that reaches the same code.