Accidental Observation to Critical IDOR
The myaccount endpoint accepted an id parameter that let an attacker view and modify another user's account details, including changing their email. By changing a victim's email to an attacker-controlled address, the attacker could trigger a password reset and take over the account.
Published on medium.com
Insecure Direct Object Reference falls under the category for Broken Access Controls as per OWASP TOP 10 (2017 Edition). This issue usually occurs due to weak implementation of the application’s access control logics which links an identifier or an object to a particular asset say useridparameter defines which user’s…
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.
Insecure Direct Object Reference falls under the category for Broken Access Controls as per OWASP TOP 10 (2017 Edition). This issue usually occurs due to weak implementation of the application's access control logics which links an identifier or an object to a particular asset, say a user_id parameter that defines which user's data is to be updated. IDORs are compared to server-side issues, are widely observed, and easy to identify. However, often IDORs can be tricky, and an application that looks very much robust might also have IDORs.
After a long break I started back to look for vulnerabilities and recently encountered an interesting IDOR vulnerability which ended up as a Critical (P1) issue. In this blog, I will be discussing the same issue.
Context
The target was a subsidiary of an old target, referred to here as targetsub.com. The relevant feature is the account area: a password change page and a "my account" page that shows the logged-in user's details. At this point the researcher was able to change the email of the user with id=88, which is what later matters for the takeover.
Setup
The researcher logged into an existing account on the subsidiary after 3 to 4 months of inactivity. Because the application's policy is to rotate passwords every few months, the login flow forced a password change before the account could be used normally. No special tools or roles are described beyond a browser and a second, attacker-controlled account created later.
Finding it
On the forced password change page, the URL looked something like this:
https://www.targetsub.com/change-password/?id=90
Looking at the ?id= parameter, the researcher tried to change its value but had no success. After completing the password change through the normal flow, the researcher logged in to the application and navigated back to the change password page.
This time the URL looked something like this:
https://www.targetsub.com/change-password/
The ?id= parameter was no longer present. It was a little strange for the application to use two different flows on the same endpoint. Next, the researcher moved to the my account page, and the URL looked something like this:
https://www.targetsub.com/myaccount/
Exploitation
Step 1: Add an identifier to the account page
The researcher modified the URL by adding the ?id= parameter with a value of 88:
https://www.targetsub.com/myaccount/?id=88
With this URL, the researcher was able to access the details of the user with id=88.
Step 2: Change the victim's email
At this point the researcher was able to change the email of the user. At this point the researcher was able to change the email of the user with id=88.
Step 3: Take over the account
The researcher created another account and changed its email to an attacker-controlled email address. With the email now pointing at an address the attacker controls, the researcher could call a password reset link on that attacker-controlled email and, without user interaction, perform a full account takeover.
Root cause
Adding an ?id= parameter to the account page returned another user's details, and the email of that user could then be changed. The application therefore trusts the caller to say which user's record is being viewed and modified. The password change endpoint showed the same pattern of an ?id= parameter in one flow and none in another, which is what drew attention to the parameter in the first place. Why the existing access control logic did not stop the request is not described; likely the object-level authorisation check was missing or applied only to some flows.
Impact
An authenticated attacker who can reach the account page could read the details of the user with id=88, change that user's email address, and then use a password reset to the attacker-controlled address to take over the account, without user interaction. change that user's email address, and then use a password reset to the attacker-controlled address to take over the account, without user interaction. The researcher rated the issue Critical (P1). The report does not describe how ids are assigned beyond the example values, so whether ids are enumerable in practice is not stated.
Fix
The report does not describe what was changed. The fix that follows from the root cause is to derive the record from the authenticated session instead of from a client-supplied id, and to enforce an object-level authorisation check on every request that reads or modifies an account, including the email change, so that a supplied identifier can only ever refer to the caller's own record.
Variants to test
- Identifier on account endpoints. Take any endpoint that renders the logged-in user's profile, such as
/myaccount/, and append common identifier parameters (uid, id, user_id, oid). A positive result is the page rendering another user's details. - Same endpoint, different flows. Compare the URLs the application uses for the same endpoint across flows, as with the password change page that carried ?id= in one flow and not in another. A positive result is a parameter that appears in one flow and is accepted in another.
- Write actions behind the identifier. Once a read works with a supplied id, try the write actions on the same page, such as changing the email. A positive result is the change applying to the other user's record.
- Chained takeover. After changing a victim's email to an attacker-controlled address, request a password reset. A positive result is a reset link arriving at the attacker's address and completing the takeover without user interaction.
What happened, in plain words
A security researcher found a way to take over other people's accounts on a website. The website had a page that showed your account details, and the researcher was able to change the email address of another user there. The researcher discovered that by adding a simple number to the web address, they could view and change someone else's account details. They could then change that person's email to one they controlled, request a password reset, and get into the account. This kind of flaw is called an Insecure Direct Object Reference (IDOR). It was rated Critical (P1).
What is an IDOR?
IDOR stands for Insecure Direct Object Reference. It is a type of access control problem. In plain terms, it means the website uses something you can easily change (like a number in the web address) to decide which piece of data to show or change, and it does not check whether you are allowed to access that data.
Imagine a hotel where your room number is written on your key card. If the hotel lets you write any room number on the card yourself, you could write someone else's room number and get into their room. That is an IDOR: the website trusts you to say which record you want, without verifying that the record belongs to you.
IDORs are common and often easy to spot, but they can also be hidden in applications that look secure.
The target
The researcher was testing a website that we will call targetsub.com. It was a subsidiary of a company they had tested before. The website had a user account area with two pages: a page to change your password and a "my account" page that shows your details. The "my account" page also lets you change the email address linked to your account. That email change is important because it can lead to account takeover.
How the researcher found it
The researcher logged into an existing account on targetsub.com after not using it for 3 to 4 months. The website had a policy that passwords must be changed every few months, so after logging in, it forced them to change the password before they could use the account normally.
On the forced password change page, the web address (URL) looked like this:
https://www.targetsub.com/change-password/?id=90
Let's break this down:
https://is the secure protocol used to communicate with the website.www.targetsub.comis the domain name of the website./change-password/is the path to the password change page.?id=90is a parameter. The?starts the query string, andid=90means the parameter namedidhas the value90. Parameters are a way to pass information to the website, often used to identify which record to show.
The researcher noticed the ?id= parameter and tried changing its value, but had no success. But nothing happened; the attempts were unsuccessful.
After completing the password change through the normal flow, the researcher logged in and went back to the change password page. This time, the URL looked like this:
https://www.targetsub.com/change-password/
The ?id= parameter was gone. It seemed strange that the same page (endpoint) would behave differently in two flows: one with an id parameter and one without. It seemed strange that the same page (endpoint) would use two different flows, one with an id parameter and one without.
Next, the researcher went to the "my account" page. The URL was:
https://www.targetsub.com/myaccount/
This page shows account details.
Exploiting the IDOR
Step 1: Add an identifier to the account page
The researcher modified the URL by adding the ?id= parameter with a value of 88:
https://www.targetsub.com/myaccount/?id=88
With this URL, the researcher was able to see the details of the user with id=88. This is the core of the IDOR: the page used the id from the URL to decide whose data to show, without checking if the logged-in user was allowed to see that data.
Step 2: Change the victim's email
At this point the researcher was able to change the email of the user with id=88. The account page has an email change function, and because the page was rendering the victim's data, the change applied to the victim's account.
Step 3: Take over the account
The researcher created another account and changed its email to an attacker-controlled email. The researcher could then call a password reset link on that attacker-controlled email. The password reset link would be sent to the attacker's email. By clicking that link, the researcher could set a new password for the victim's account and take it over completely, without any action from the victim.
Why it worked
The account page returned another user's details when an id parameter was supplied, and the email of that user could then be changed. The email change function on that page followed the same identifier. So the application trusted the caller to say which user's record is being viewed and modified. The password change endpoint showed the same pattern: an ?id= parameter in one flow and none in another, which is what drew attention to the parameter in the first place. The report does not describe why the existing access control logic did not stop the request; likely the object-level authorisation check was missing or applied only to some flows.
Impact
An authenticated attacker who can reach the account page could read the details of the user with id=88, change that user's email address, and then use a password reset to the attacker-controlled address to take over the account, without user interaction. change that user's email address, and then use a password reset to the attacker-controlled address to take over the account, without user interaction. The researcher rated the issue Critical (P1). The report does not describe how ids are assigned beyond the example values, so whether ids are enumerable in practice is not stated.
How to fix it
The fix that follows from the root cause is to derive the record from the authenticated session instead of from a client-supplied id, and to enforce an object-level authorisation check on every request that reads or modifies an account, including the email change, so that a supplied identifier can only ever refer to the caller's own record.
Variants to test
- Identifier on account endpoints. Take any endpoint that renders the logged-in user's profile, such as
/myaccount/, and append common identifier parameters (uid,id,user_id,oid). A positive result is the page rendering another user's details. - Same endpoint, different flows. Compare the URLs the application uses for the same endpoint across flows, as with the password change page that carried
?id=in one flow and not in another. A positive result is a parameter that appears in one flow and is accepted in another. - Write actions behind the identifier. Once a read works with a supplied id, try the write actions on the same page, such as changing the email. A positive result is the change applying to the other user's record.
- Chained takeover. After changing a victim's email to an attacker-controlled address, request a password reset. A positive result is a reset link arriving at the attacker's address and completing the takeover without user interaction.
Glossary
- IDOR (Insecure Direct Object Reference): A security flaw where a website uses user-supplied input (like a number in the URL) to directly access a data object without checking if the user is authorised to access it.
- Access control: The process of deciding who is allowed to do what on a website. Broken access control is when these rules are not properly enforced.
- OWASP Top 10: A list of the ten most critical web application security risks, published by the Open Web Application Security Project.
- Parameter: A piece of information passed to a website, often in the URL after a
?, like?id=90. It can also be in form data or cookies. - Endpoint: A specific URL or function in a web application that performs a particular action, like
/change-password/or/myaccount/. - URL (Uniform Resource Locator): The address of a web page, like
https://www.example.com/page. - Query string: The part of a URL after the
?, containing parameters and their values. - Session: A way for a website to remember who you are across multiple requests, typically using a cookie. It is like a temporary ID card that the website gives you after you log in.
- Cookie: A small piece of data stored in your browser by a website, often used to maintain your session.
- Account takeover: A type of attack where an attacker gains unauthorised access to someone else's account.
- Password reset: A feature that lets a user set a new password, usually by receiving a link via email.
- Critical (P1): A severity rating indicating a very serious vulnerability that should be fixed immediately.
- Authenticated: Logged in with a valid username and password.
- Client-supplied: Data that comes from the user's browser (the client) rather than from the server's own records.
- Object-level authorisation check: A check that verifies whether the user is allowed to access a specific data object (like an account record).
- Enumerable: Able to be counted through or guessed in sequence, like numeric ids (1, 2, 3, ...).