Skip to content
IDOR Write-up Beginner

Full Account takeover (ATO) — a tale of two bugs

An API endpoint returned other users' account data when the numeric user ID in the request body was changed, and the client-side session object also trusted that same ID. By swapping in the victim's ID, the attacker gained full access to the victim's account and changed their password.

Kwadwo Amoako Follow

Published on medium.com

Hi everyone, I hope we’re all having a swell day. Before I jump into today's bug report, I’d like to express my sincerest gratitude for the engagement my previous write-up received.

Kwadwo Amoako, 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 write-up covers a chained attack against a target the author refers to as www.xyz.com. The program cannot be named because of an NDA, so everything below is described against that placeholder host. The two bugs are an API-based IDOR and a client-side session object that the application trusts when it asks its API services for data. Chained together, they produced full account takeover (ATO).

The author defines ATO as an attacker gaining access to the data and privileges associated with a compromised account, and notes that whether it is achievable depends on the bugs present in the application and on the creativity of the hacker.

The feature involved is the "User Account" page. In normal use, the page holds a copy of the current user's session in the browser. That session contains the user's Id, rights and permission, and those values are subsequently sent back to the API services for data, in the name of the current user.

Setup

  • Two identities are used: the attacker, who goes by the name Shaibu Abudu, and the victim, Eric.
  • The tool used for interception and modification is Burp Suite.
  • The first bug is reached through an API endpoint that returns user data, referenced in the report as POST /xyz.com/Account?handler=GetUserData.
  • The second bug is reached by reloading the "User Account" page and intercepting that request.
  • No versions, accounts setup details or preconditions beyond these are given in the report.

Finding it

The first finding is an API-based Insecure Direct Object Reference (IDOR). The author describes IDOR as occurring when an application exposes a reference to an internal implementation object, or, in plain terms, when part of an application allows you to request and receive information that you are not authorised to see.

The second finding came from a block of code the author found on the "User Account" page. The author's point is that if you have not been taking static code analysis seriously, you have probably missed out on juicy bugs. Looking at the block of code found on the "User Account" page, shown in figure 2, the next line of action becomes apparent.

Figure 2 From the original on medium.com

Figure 2

In figure 2 there is a copy of the current user's session on the browser. The session contains the user's Id, rights and permission. These values are subsequently sent back to the API services for data, in the name of the current user. That is the design weakness: the identity and privilege data used to fetch data server-side lives in a client-side object that the client sends back.

Exploitation

Step 1: IDOR in the user data endpoint

The author intercepted the request to the user data endpoint and changed his own ID in the body of the POST request using Burp Suite. The endpoint as given in the report is:

HTTP
POST /xyz.com/Account?handler=GetUserData

The author changed his own ID in the body of the POST request. After sending the modified request, the response contained the data of the victim, as seen in figure 1.

figure 1 From the original on medium.com

figure 1

The author notes that the bug was important but deliberately shelved it for a while, because a chained attack is more interesting.

Step 2: Reading the client-side session object

On the "User Account" page, the code in figure 2 shows the current user's session copied into the browser. That object carries the user's Id, rights and permission, and those values are sent back to the API services so that data is returned in the name of the current user.

Step 3: Swapping identities on the page request

Leveraging the information from the first bug, the author reloaded the "User Account" page, intercepted the request, and modified his IDs to the victim's IDs. The result was full access to the victim's account.

Figure 3 From the original on medium.com

Figure 3

Step 4: Demonstrating impact

To show impact, the author changed the victim's password.

Root cause

The first bug is an IDOR: changing the ID in the POST body returned the victim's data. The second bug is a trust problem: the session object holding the user's Id, rights and permission is kept in the browser and sent back to the API services, which then serve data in the name of the current user based on those client-supplied values. The report does not describe the server-side validation, so the exact check that was missing is not stated;

Impact

An attacker who can reach the user data endpoint can read another user's data by changing the ID in the request body. By then modifying the IDs in the "User Account" page request to the victim's IDs, the attacker obtains full access to the victim's account. In the demonstration this was enough to change the victim's password. The report does not state any authentication requirements beyond the two accounts used.

Fix

Based on the two weaknesses, the fixes would be: on the API side, derive the caller's identity and permissions from a server-side session rather than from client-supplied values, and on the GetUserData handler, verify that the requested object belongs to the caller before returning it.

Variants to test

  1. Body-based IDOR on API handlers. Take any POST endpoint that takes an object identifier in the body, such as a user, order or document ID, and swap it for another account's identifier. A positive result is a response containing the other account's data.
  2. Client-side session objects. Inspect the "User Account" or profile page for a session object containing Id, rights or permission fields, then modify those fields in the intercepted request. A positive result is the application serving data or actions as the other user.
  3. Chained identity swap. Combine a leaked identifier from one endpoint with a page request that carries identity fields, and change both to the victim's values. A positive result is full access to the victim's account, for example the ability to change their password.
  4. Static code analysis on account pages. Review the JavaScript behind account pages for session data being copied into the browser and sent back to APIs. A positive result is a request whose identity or permission fields are taken directly from the client.

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

What happened, in plain words

A security researcher found two separate weaknesses in a website and joined them together to take over another person's account completely. Neither weakness on its own was dramatic. The first let him read another user's data by changing his ID in a request. The second was a design flaw: the website kept a copy of the logged-in user's identity and permissions inside the browser, and then trusted whatever the browser sent back. Put together, the two let him act as another person, and he proved it by changing that person's password.

The target cannot be named because of an NDA (a non-disclosure agreement, a contract promising not to reveal details). The researcher calls it www.xyz.com. Throughout this article, two made-up identities are used: the attacker is called Shaibu Abudu and the victim is called Eric.

Before the details, a few words that come up constantly.

  • An API (Application Programming Interface) is the part of a website that serves data to the pages rather than drawing screens for people. A useful comparison is a restaurant: the web page is the dining room you sit in, and the API is the kitchen door where orders go in and plates come out. You never walk into the kitchen yourself; the page asks on your behalf.
  • A request is the message your browser sends to a server asking for something, and a response is the message that comes back. Every click, every page load, every button press is one or more of these.
  • A session is the server's memory of who you are while you are logged in. Because the web has no natural memory between one request and the next, something has to carry your identity along with each request. That something is usually a cookie or a token: a small piece of data the browser stores and sends back automatically, like a cloakroom ticket. The ticket does not contain your coat, it just proves the coat is yours.
  • An ID is simply a unique label for a record, usually a number. Your account has one, an order has one, a document has one. If the labels are guessable, the question becomes whether the server checks that the record you asked for actually belongs to you.
  • Account takeover (ATO) is when an attacker gains access to the data and privileges of someone else's account. Whether it is possible depends on the bugs in the application and on the creativity of the hacker, as the researcher puts it.
  • Burp Suite is a tool that sits between your browser and the website and lets you pause a request, look at it, edit it, and then send it on. Think of it as being able to open an envelope, change the letter inside, and seal it again before it reaches the recipient.
  • Static code analysis means reading the code a website ships to the browser, without running it, looking for something interesting. It is the difference between watching a machine work and reading its blueprint.

The feature at the centre of everything is the "User Account" page. In normal use, that page holds a copy of the current user's session in the browser. That copy contains the user's Id, rights and permission, and those values are then sent back to the API services so that data is returned in the name of the current user. Hold on to that sentence; it is the whole second bug in one line.

Setup

  1. Two accounts are used: the attacker's, going by the name Shaibu Abudu, and the victim's, Eric.
  2. The tool used to intercept and modify traffic is Burp Suite.
  3. The first bug is reached through an API endpoint that returns user data, written in the report as POST /xyz.com/Account?handler=GetUserData.
  4. The second bug is reached by reloading the "User Account" page and intercepting that request.

The report gives no versions, no account setup details and no preconditions beyond these.

Finding it

The first finding is an API-based Insecure Direct Object Reference (IDOR). The researcher defines IDOR as occurring when an application exposes a reference to an internal implementation object. In plain English, it is when part of an application lets you request and receive information you are not authorised to see. The everyday comparison is a hotel: room numbers are not secret, but the door should still only open for the guest who holds that room's key. If the door opens for anyone who says the number out loud, the number was never the protection.

The second finding came from a block of code found on the "User Account" page. The researcher's point is blunt: if you have not been taking static code analysis seriously, you have probably missed out on juicy bugs. Looking at the block of code found on the "User Account" page, shown in figure 2, the next line of action becomes apparent.

Figure 2 From the original on medium.com

Figure 2

In figure 2 there is a copy of the current user's session on the browser. The session contains the user's Id, rights and permission. These values are subsequently sent back to the API services for data, in the name of the current user. That is the design weakness: the identity and privilege data used to fetch data on the server lives in an object on the client side, and the client sends it back. The browser is under the user's control, so anything the browser sends is under the user's control too.

Exploitation

Step 1: IDOR in the user data endpoint

The researcher intercepted the request to the user data endpoint and changed his own ID in the body of the POST request using Burp Suite. The endpoint as given in the report is:

HTTP
POST /xyz.com/Account?handler=GetUserData

Line by line:

  • POST is the type of request. It is used when the browser is sending data to the server rather than just asking for a page. A search form or a login form typically uses POST.
  • /xyz.com/Account is the path, the address of the feature on the server. Here it is the account feature.
  • ?handler=GetUserData is the query string, the part after the question mark. It tells the account feature which of its internal routines to run. GetUserData means "give me the data for a user".

The author changed his own ID in the body of the POST request. The researcher did not need to find a new endpoint or guess a new address; he only changed the value inside the envelope.

After sending the modified request, the response contained the data of the victim, as seen in figure 1.

figure 1 From the original on medium.com

figure 1

The researcher notes that the bug was important but deliberately shelved it for a while, because a chained attack is more interesting. That is a choice about storytelling as much as about testing: a single data leak is a finding, but two findings joined together show what an attacker could really do.

Step 2: Reading the client-side session object

On the "User Account" page, the code in figure 2 shows the current user's session copied into the browser. That object carries the user's Id, rights and permission, and those values are sent back to the API services so that data is returned in the name of the current user. Because the values live on the client side, whoever controls the browser controls what is sent.

Step 3: Swapping identities on the page request

Leveraging the information from the first bug, the researcher reloaded the "User Account" page, intercepted the request, and modified his IDs to the victim's IDs. The result was full access to the victim's account.

Figure 3 From the original on medium.com

Figure 3

Why this step works: the page accepted the victim's IDs from the intercepted request. The second bug meant the page would accept that identifier from the browser and act on it. Neither piece is enough alone. The leak gives you a name; the trust flaw lets you wear it.

Step 4: Demonstrating impact

To show impact, the researcher changed the victim's password. Changing a password is a strong demonstration because it is an action, not just a read: it shows the attacker was not merely looking at Eric's data but acting as Eric, and

Root cause

The first bug is an IDOR: changing the ID in the POST body returned the victim's data. The second bug is a trust problem: the session object holding the user's Id, rights and permission is kept in the browser and sent back to the API services, which then serve data in the name of the current user based on those client-supplied values. The report does not describe the server-side validation, so the exact check that was missing is not stated;

Impact

An attacker who can reach the user data endpoint can read another user's data by changing the ID in the request body. By then modifying the IDs in the "User Account" page request to the victim's IDs, the attacker obtains full access to the victim's account. In the demonstration this was enough to change the victim's password. The report does not state any authentication requirements beyond the two accounts used.

Fix

Based on the two weaknesses, the fixes would be: on the API side, derive the caller's identity and permissions from a server-side session rather than from client-supplied values, and on the GetUserData handler, verify that the requested object belongs to the caller before returning it. In the hotel comparison: the door should check the key against the guest list kept at reception, not against whatever room number the visitor writes on a form.

Variants to test

  1. Body-based IDOR on API handlers. Take any POST endpoint that takes an object identifier in the body, such as a user, order or document ID, and swap it for another account's identifier. A positive result is a response containing the other account's data.
  2. Client-side session objects. Inspect the "User Account" or profile page for a session object containing Id, rights or permission fields, then modify those fields in the intercepted request. A positive result is the application serving data or actions as the other user.
  3. Chained identity swap. Combine a leaked identifier from one endpoint with a page request that carries identity fields, and change both to the victim's values. A positive result is full access to the victim's account, for example the ability to change their password.
  4. Static code analysis on account pages. Review the JavaScript behind account pages for session data being copied into the browser and sent back to APIs. A positive result is a request whose identity or permission fields are taken directly from the client.

Glossary

  • Account takeover (ATO): when an attacker gains access to the data and privileges of someone else's account.
  • API (Application Programming Interface): the part of a website that serves data to pages and other software, rather than drawing screens for people.
  • API-based IDOR: an IDOR that occurs in an API endpoint rather than in a normal web page.
  • Body (of a request): the part of a request that carries data being sent to the server, as opposed to the address and query string.
  • Burp Suite: a tool that sits between the browser and the website so requests can be paused, inspected and edited before being sent on.
  • Client side: anything happening in, or stored in, the user's browser, which the user controls.
  • Cookie: a small piece of data a website stores in the browser and which the browser sends back automatically with later requests, often used to carry a session.
  • Endpoint: a specific address on a server that performs a specific job, such as returning user data.
  • Handler: the named internal routine an endpoint runs, selected here by the handler value in the query string.
  • ID: a unique label, usually a number, that identifies a record such as a user or an order.
  • IDOR (Insecure Direct Object Reference): a flaw where an application lets you request and receive information you are not authorised to see, because it exposes a reference to an internal object without checking that it belongs to you.
  • NDA (non-disclosure agreement): a contract promising not to reveal details, which is why the target is called www.xyz.com here.
  • POST: a type of request used when the browser sends data to the server, rather than simply asking for a page.
  • Query string: the part of a URL after the question mark, carrying values that tell the server what to do.
  • Request: the message a browser sends to a server asking for something.
  • Response: the message a server sends back.
  • Server side: anything happening on, or stored on, the server, which the user does not control.
  • Session: the server's memory of who you are while you are logged in, usually carried between requests by a cookie or token.
  • Static code analysis: reading code without running it, looking for weaknesses or interesting behaviour.
  • Token: a piece of data, similar in role to a cookie, that proves who you are to a server.
  • User Account page: the page in this report that holds a copy of the current user's session in the browser, including the user's Id, rights and permission.

More by Kwadwo Amoako

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Insecure direct object reference (IDOR)

The lesson behind this report.

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.