Skip to content
IDOR Write-up Beginner

Hunting Insecure Direct Object Reference Vulnerabilities for Fun and Profit (PART-1)

The social media platform failed to validate object identifiers (post IDs and user IDs) on several endpoints, allowing an attacker to delete any user's posts and change or delete any user's profile and cover pictures. The author found 12 IDOR vulnerabilities in total.

Mohammed Abdul Raheem Follow

Published on codeburst.io

Bounty$3,000total stated by author View original

Arbaz Hussainget invitation to test one private program and find vulnerabilities with his team mates but he was busy with his work and selected me to test that program. So i would like to thankArbazfor sharing site and Thanks toAqeelAsif for teaching me lots of stuff from which i was able to find 21 valuable…

Mohammed Abdul Raheem, on codeburst.io

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 penetration test of a popular social media platform, carried out on a private program. The features involved are the ones every social network has: posting a status to your timeline, deleting a post, uploading a profile picture, uploading a cover picture, and deleting either of those pictures. Each of these actions is performed by the browser sending a request to the server that identifies the object being acted on, either a post or a user.

The researcher found 21 vulnerabilities in the program over two days and received $3000 in cryptocurrency. Twelve of them were IDORs. This first part describes the endpoints where the IDORs were found; the second part collects further endpoints worth testing.

The definition the author quotes is the classic one: a direct object reference occurs when a developer exposes a reference to an internal implementation object, such as a file, directory or database key, without a validation mechanism, which lets an attacker manipulate those references to reach unauthorised data.

Setup

The test was performed on a private program the researcher was invited to. A colleague, Arbaz Hussain, had received the invitation to test the program with his team but was busy, and passed the site to the researcher. The researcher thanks Aqeel Asif for the teaching that made the findings possible.

Two accounts are needed for this class of bug: the attacker's own account, used to capture legitimate requests, and a victim account whose objects are targeted. The report does not name the platform, the endpoints, the parameter values or the tooling used to intercept and edit requests.

Finding it

While using the site normally, the researcher posted a status on his timeline and clicked on the post. The site redirected him to another page, and the URL of that page contained the post id. Seeing an object identifier in the URL was the trigger: the next question was what the server would do with that identifier if it belonged to someone else.

He logged in with the attacker's account, posted on the timeline, and looked at the request the delete action produced. The same pattern was then applied to the profile picture and cover picture uploads, where the request body carried a userid parameter. The reasoning was that if userid was not validated on the server side either, many more IDORs would follow, and that turned out to be the case.

Exploitation

Step 1: deleting any post on the website

With the victim's post id visible in the URL of the post page, the researcher switched to the attacker's account and created a post of his own. Clicking the Delete the item option on that post made the following request to the server:

The request carries an id parameter in the POST data whose value is the unique id of the post. The researcher replaced the attacker's post id with the victim's post id and the victim's post was deleted. Because the server did not validate the post id parameter, posts on the website could be deleted remotely this way.

Step 2: changing anyone's profile picture

Starting from the attacker's profile, clicking Browse, selecting an image file and clicking Upload made the following request:

The userid parameter in the POST data is the unique id of the user. Changing it to another victim account's userid value changed that victim's profile picture to the attacker's image.

Step 3: changing anyone's cover picture

The cover picture upload behaved the same way. From the attacker's profile, Browse, select an image, Upload, and the request again carried a userid parameter in the POST data. Replacing it with a victim's userid changed the victim's cover picture to the attacker's image.

Step 4: deleting profile and cover pictures

The researcher then asked whether the same objects could be deleted, and tested IDOR against the delete actions for the profile picture and the cover picture. Both worked: he was able to delete the profile picture and the cover picture of every user. Rather than spend time recording a proof-of-concept video, he reported the issue and received a quick response within hours.

Root cause

The server trusted object identifiers supplied by the client. In each request the identifier of the object to act on, a post id or a user id, arrived in the POST body, and the server performed the action on whatever object that identifier named without checking that the authenticated user owned it. The report attributes each finding to improper validation of the parameter at the server side.

Impact

An authenticated attacker could delete any post on the website, replace any user's profile picture and cover picture with an image of their choosing, and delete any user's profile picture and cover picture. The report does not describe any further consequences, such as account takeover or access to private data, and does not state how many users were affected.

Fix

The fix such handlers need is a server-side ownership check: derive the acting user from the session and confirm that the post or user named in the request belongs to that session before performing the action, rather than trusting the identifier in the body.

Variants to test

  1. Post identifiers in URLs. Open one of your own posts and note the id in the page URL, then replay the delete or edit action with another account's post id. A positive result is the other account's post being removed.
  2. userid in upload bodies. Upload a profile or cover image and change the userid in the POST data to a second account's id. A positive result is the second account's image being replaced.
  3. Delete actions for the same objects. Repeat the previous test against the delete endpoints for profile and cover pictures. A positive result is the other account's picture disappearing.
  4. Other object references in POST data. Look for any other parameter that names a user, post, file or record and swap it between two accounts. A positive result is any action succeeding on an object the session does not own.

"i like quick responses so i boost up myself to test this program."

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 was given access to test a private social media platform. Over two days he found 21 security holes and was paid $3000 in cryptocurrency. Twelve of those holes were the same kind of mistake, called an Insecure Direct Object Reference, or IDOR for short. This article explains that mistake from scratch, using the same examples he gave, so that someone who has only ever used a browser can understand it.

A social media platform is a website where people create accounts, post status updates, and add profile and cover pictures. Every one of those things is stored on the company's server, which is a computer that holds the website and its data. When you click a button such as Delete or Upload, your browser sends a small message to that server asking it to do something. That message is called a request. The server sends back a reply, called a response, and your browser shows you the result.

An IDOR happens when the request contains a simple identifier for the thing you want to act on, such as the number of a post or the number of a user, and the server acts on whatever identifier it is given without checking that the person making the request is allowed to touch that thing. The identifier is called a direct object reference because it points straight at an object stored on the server. If you can change that identifier to someone else's, and the server still does the action, you have found an IDOR.

A useful everyday comparison is a cloakroom ticket. You hand in your coat and get a ticket with a number. When you come back, you give the ticket and get your coat. If the attendant never checks that the ticket belongs to you, and you can guess or read another person's ticket number, you can hand in their number and walk away with their coat. The ticket number is the direct object reference, and the missing check is the vulnerability.

The researcher quotes a classic definition: a direct object reference is likely to occur when a developer exposes a reference to an internal implementation object, such as a file, directory, or database key, without any validation mechanism, which allows attackers to manipulate these references to access unauthorised data. In plain words, the website shows you a name or number for something inside its systems, and it does not check whether you should be allowed to use that name or number.

How the test was set up

The test was done on a private program. A private program is a bug bounty arrangement where a company invites a small number of researchers to test its systems, rather than opening the invitation to everyone. The researcher was invited indirectly: a colleague, Arbaz Hussain, had received the invitation to test the program with his team but was busy with his own work, so he passed the site to the researcher. The researcher thanks Aqeel Asif for teaching him much of what made the findings possible.

To test for this kind of bug you need two accounts on the same website. One is the attacker's account, which you control and use to make normal requests that you can inspect. The other is the victim's account, which stands in for another user whose things you will try to touch. The report does not say whose account was used as the victim. The report does not name the platform, the exact web addresses of the actions, the values of the identifiers, or the tools used to capture and edit requests.

How the first hole was found

The researcher was using the site normally. He posted a status on his timeline, which is the stream of posts on his own profile page. He then clicked on his own post. The site took him to another page, and the address bar of that page, the URL, contained the post id. A URL is the address you see at the top of the browser, and an id is a unique label the site gives to each thing it stores, so that it can tell one post from another.

Seeing an identifier in the URL was the trigger. The question he asked himself was simple: what will the server do with that identifier if it belongs to someone else? That is the core of IDOR testing. You find a place where the browser tells the server which object to act on, and then you try telling it a different object.

He logged in with the attacker's account, posted on the timeline, and looked at the request that the delete action produced. He then applied the same pattern to the profile picture and cover picture uploads, where the request body carried a userid parameter. The request body is the part of the request that carries the data you are sending, such as the image file or the identifier. A parameter is simply a named value inside that data, like userid=123. The reasoning was that if userid was not checked on the server side either, many more IDORs would follow, and that turned out to be the case.

Step 1: deleting any post on the website

With the victim's post id visible in the URL of the post page, the researcher switched to the attacker's account and created a post of his own. Clicking the Delete the item option on that post made the following request to the server:

This is an HTTP request, the language browsers and servers use to talk to each other. The first line says the method is POST, which means "here is some data for you to act on", and gives the path of the action on the server. The Host line names the website. After the blank line comes the body, which here is a single parameter called id whose value is the attacker's post id. The square brackets mark places where the real value has been removed for privacy.

The request carries an id parameter in the POST data whose value is the unique id of the post. The researcher replaced the attacker's post id with the victim's post id and the victim's post was deleted. Because the server did not validate the post id parameter, posts on the website could be deleted remotely this way. In other words, the server received the number, looked up the post with that number, and deleted it, without asking whether the person sending the request was the owner of that post.

Step 2: changing anyone's profile picture

A profile picture is the image shown next to your name on your profile page. Starting from the attacker's profile, clicking Browse, selecting an image file and clicking Upload made the following request:

Again this is a POST request to an action on the server. The body contains a userid parameter, which is the unique id of the user whose picture is being changed. The researcher changed it to another victim account's userid value, and that victim's profile picture was replaced with the attacker's image. The server accepted the new picture and attached it to whichever user id was in the request, rather than to the user who was logged in.

Step 3: changing anyone's cover picture

The cover picture is the large banner image at the top of a profile page. The upload behaved the same way. From the attacker's profile, Browse, select an image, Upload, and the request again carried a userid parameter in the POST data. Replacing it with a victim's userid changed the victim's cover picture to the attacker's image. The same missing check produced the same result on a different feature.

Step 4: deleting profile and cover pictures

The researcher then asked whether the same objects could be deleted, and tested IDOR against the delete actions for the profile picture and the cover picture. Both worked: he was able to delete the profile picture and the cover picture of every user. Rather than spend time recording a proof-of-concept video, which is a short screen recording showing the bug in action, he reported the issue and received a quick response within hours.

Why it worked

The server trusted object identifiers supplied by the client. The client is your browser, and anything it sends can be changed by the person using it. In each request the identifier of the object to act on, a post id or a user id, arrived in the POST body, and the server performed the action on whatever object that identifier named without checking that the logged-in user owned it. The report attributes each finding to improper validation of the parameter at the server side.

A session is how a website remembers that you are logged in. After you sign in, the server gives your browser a cookie, which is a small piece of data stored by the browser and sent back with every request. The cookie acts like a wristband at an event: it proves you are inside, but it does not by itself say which objects you are allowed to touch. The missing step was comparing the wristband to the object.

What an attacker could do

A logged-in attacker could delete any post on the website, replace any user's profile picture and cover picture with an image of their choosing, and delete any user's profile picture and cover picture.

How to fix it

The fix such handlers need is a server-side ownership check: derive the acting user from the session and confirm that the post or user named in the request belongs to that session before performing the action, rather than trusting the identifier in the body. In cloakroom terms, the attendant must check that the ticket number matches the coat you handed in, not just that you have a ticket.

Other places to look

  1. Post identifiers in URLs. Open one of your own posts and note the id in the page URL, then replay the delete or edit action with another account's post id. A positive result is the other account's post being removed.
  2. userid in upload bodies. Upload a profile or cover image and change the userid in the POST data to a second account's id. A positive result is the second account's image being replaced.
  3. Delete actions for the same objects. Repeat the previous test against the delete endpoints for profile and cover pictures. A positive result is the other account's picture disappearing.
  4. Other object references in POST data. Look for any other parameter that names a user, post, file or record and swap it between two accounts. A positive result is any action succeeding on an object the session does not own.

"i like quick responses so i boost up myself to test this program."

Glossary

  • API: a way for one piece of software to ask another to do something, here the set of requests a website's pages send to its server.
  • Attacker account: the account you control and use to make requests you can inspect and change.
  • Bug bounty: a programme where a company pays researchers for reporting security problems.
  • Client: the software on your side, usually your browser, which sends requests to the server.
  • Cookie: a small piece of data a website stores in your browser and your browser sends back with each request, often used to keep you logged in.
  • Cover picture: the large banner image at the top of a social media profile.
  • Cryptocurrency: digital money sent over the internet, used here for the reward payment.
  • Direct object reference: a name or number in a request that points straight at something stored on the server, such as a post or a user.
  • Endpoint: the specific address on a server that performs one action, such as deleting a post.
  • HTTP: the language browsers and servers use to exchange requests and responses.
  • IDOR (Insecure Direct Object Reference): a bug where the server acts on an object named in the request without checking that the requester is allowed to touch it.
  • Identifier (id): a unique label for a stored object, such as a post or a user.
  • Parameter: a named value inside a request, such as id=123 or userid=456.
  • POST: an HTTP method used when the browser sends data to the server for it to act on.
  • Private program: a bug bounty programme open only to invited researchers.
  • Profile picture: the image shown next to your name on your profile page.
  • Proof-of-concept video: a short recording that demonstrates a bug working.
  • Request: the message your browser sends to a server asking it to do something.
  • Request body: the part of a request that carries the data being sent, such as an identifier or a file.
  • Response: the server's reply to a request.
  • Server: the computer that holds a website and its data and answers requests.
  • Session: the server's record that you are logged in, usually tied to a cookie.
  • Timeline: the stream of posts on a social media profile.
  • URL: the address of a page, shown in the browser's address bar.
  • Validation: checking that data sent by the client is acceptable and allowed, here checking that the identifier belongs to the logged-in user.
  • Victim account: a second account, also controlled by the tester, standing in for another user whose objects are targeted.

More by Mohammed Abdul Raheem

View all

1 more disclosed report, 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.