IDOR Guide
IDOR Guide
References (IDOR)
IDOR vulnerabilities are a serious concern for organizations and in-
dividuals alike, as they can result in the compromise of sensitive data
and financial loss. These vulnerabilities occur when an application
exposes direct object references, such as file names or database keys,
in its user interface, allowing attackers to manipulate them to access
unauthorized data or functionality. IDOR vulnerabilities can be found
in a variety of applications, including web applications, mobile apps,
and desktop software.
4
guard their data and reduce the risk of suffering from the consequences
of IDOR vulnerabilities.
Imagine that you have registered on a shopping website and have pro-
vided your personal information such as your address, email, and phone
number. You are then redirected to a page where you can review and
edit your information. On this page, you may see a link in the browser
bar that looks something like this:
example.com/user/details?id=2023
5
when your account is created. In this example, your account is associ-
ated with the ID ”2023”.
6
Figure 1: Direct Reference to Database Objects Scenario
example.com/static/receipt/205.pdf
7
However, an attacker can exploit this vulnerability by simply modifying
the filename in the URL like below:
example.com/static/receipt/200.pdf
8
3 Risks Caused by IDOR
IDOR attacks can have serious consequences for both website owners
and users. Some of the risks associated with IDOR include:
9
3.3 Direct File Access
IDOR vulnerabilities can also allow attackers to directly access files
stored on the application’s server. This can include sensitive files such
as configuration files or log files, as well as static files such as images
or documents. Direct file access attacks can lead to sensitive informa-
tion leakage and potentially allow attackers to execute malicious code
on the server. For example, an attacker could use an IDOR vulner-
ability to download a server’s configuration file, which could contain
sensitive information such as database passwords. Alternatively, an
attacker could use an IDOR vulnerability to upload a malicious script
and execute it on the server.
10
4 How to Exploit IDOR Vulnerabilities
11
ilgaz. After creating the accounts, We logged in as user ”ilgaz, and
start examining the requests and responses from the network tab. In
network tab we can easily obtain the user’s ID by accessing the
http://127.0.0.1:8000/api/user-id/
With the user ID of the ”ilgaz” user in hand, we also retrieved the user
ID of the ”talha” user by repeating the same steps. By understanding
the way user IDs are assigned in an auto-incremented fashion, we were
able to formulate strategies for conducting an attack. Even if we could
not detect any pattern, we could find valid users using an enumeration
attack, which basically is a brute-force method to check if certain data
exists on a web server database.
12
Let’s go back to our topic. As shown in the above figures, when we
retrieve the user ID for the ”talha” user, we can see that user IDs are
assigned to users in an auto-incremented way.
From now on, we will use the features of our website to create
different shipping and billing addresses and orders for two users, and
begin searching for IDOR vulnerabilities.
As can be seen in the following figures, we have created different
addresses and orders.
13
Figure 7: Payment History of Ilgaz
14
Figure 9: Payment History of Talha
15
After logging in as the ”talha” user, we examine the requests made
using Burp Suite. We attempt to access ”ilgaz” users’ data using
related user ID. We open the intercept in the proxy tab in Burp Suite
and click on the profile menu on the website. We see that the data in
the profile is retrieved by a GET request to
localhost:8000/api/addresses
16
Leaving the address endpoint behind, we continue by examining
other requests via burp and browser. As shown in the figure below, we
can see that the requests made to the ”order-summary” and ”address”
endpoints are validated using the CSRF token and the response is sent
in the same way.
17
At this point, we will create and update billing addresses while
Burpsuite intercept is active.
18
Figure 13: Intercepted request of new billing address
19
Figure 14: Successfuly created message
Now let’s log into the other account and see if our new address is
created under the other user’s profile.
20
Figure 15: Ilgaz’s account, address section
At the beginning of the exploit part, we could not access the pro-
files of other users. But right now, we have a much more powerful
weapon than reading data. It is writing data! For the time being,
21
we can create profile data under another user. What if we could also
update the address information? If we can update address informa-
tion, we can change the user ID of any address to our own user ID
and may associate any information with our ”talha” user. This would
allow us to access all email addresses, phone numbers, payment, and
billing addresses in the system.
22
First, to use update address endpoint, we will simply intercept
update billing address operation in ”talha” user.
23
Figure 17: Intercepted request of updating billing address
24
Figure 18: Intruder configurations
api/addresses/"addressID"/update
,we need to set the AddressID part in the request URL and the ID part
in the parameters section as the ”payload position”. Since we want to
put the same payload in every payload position we use the Battering
Ram attack type, you can see the attack type and payload positions
in the above figure.
25
Figure 19: Payload configurations
26
As seen in the figures below, Burpsuite sent 20 different payloads
and some of them resulted in a status of 200. When we visited the
profile of the user ”talha,” we were able to see the addresses of all
other users under ”talha”. What a shame!
27
Figure 21: Profile of the user ”talha”
28
4.2 Direct Reference to Static Files
We will continue with the example of direct reference to static files.
As you may remember from the previous figures, there is a section in
the payment history menu where the receipts of the payments can be
downloaded. If we download receipt number 5, we get the receipt for
our own order, as can be seen in the figures below .
29
Let’s activate the intercept again in Burpsuite and examine the
requests and confirm whether we can access other users’ receipts. We
retrieve the relevant receipt using a get request send to
/127.0.0.1:8000/api/download/5
30
5 Vulnerable Code Examples
The three classes and one function in the example are taken from our
test environment. As shown in the below figures, although the user’s
authentication status is checked, it is not verified whether the user has
access to the relevant address in address creation, updating, and dele-
tion.
31
The authentication process is handled by Django as default. But
unfortunately download file function does not check whether the re-
ceipt being downloaded belongs to the user attempting to download
it.
32
6 How to Prevent IDOR Attacks
33
An alternative approach is to use Python’s built-in ”request.user”
method. By filtering user objects with this method, we can retrieve
the relevant data for that user from the database. As shown in the
figures below, we have modified all functions that were vulnerable to
IDOR.
34
To ensure that the download receipts function is secure, we can
filter orders that belong to the requesting user and also have requested
order ID. This will guarantee that the user can only access their own
receipts.
35
6.2 General Methods for preventing IDOR
Randomizing the numbers assigned to reference objects, rather than
using a sequential numbering system, can help to reduce the risk of
IDOR vulnerabilities. However, this is not a complete solution and
other measures must be taken to fully protect against these types of
attacks. Even using unique identifiers like UUIDs, which are designed
to have a high level of randomness, may not be sufficient if a company’s
list of user IDs is leaked. In this case, attackers could potentially use
the leaked list to execute IDOR attacks if the web application does not
have proper access control measures in place.
36
attackers to access sensitive data or manipulate objects by altering
the user-supplied input. To implement an indirect reference map, the
application should replace the direct reference to an object with an
identifier such as a UUID (Universally Unique Identifier). Internally,
the application should maintain a mapping between the UUIDs and the
corresponding objects, so that it can translate the indirect reference
back to the original form. It is important to note that while UUIDs
and other methods of generating randomly assigned IDs can make it
more difficult for attackers to guess the direct reference, they are not
a foolproof solution. Indirect reference maps should be used in combi-
nation with other methods to effectively prevent IDOR vulnerabilities.
37
6.5 Parameter Verification
Parameter verification involves checking user-supplied input to ensure
it is of the correct length, type, and does not contain unacceptable
characters. This can help prevent IDOR vulnerabilities by making it
harder for attackers to access sensitive data or manipulate objects by
altering the user-supplied input. Some checks that can be performed
as part of parameter verification include:
• Verifying that input is of the proper data type (e.g., strings, num-
bers, dates, etc.) It is important to note that while parameter
verification can help prevent IDOR vulnerabilities, it is not a
foolproof solution. Organizations should use other methods in
addition to parameter verification to effectively prevent IDOR
vulnerabilities.
38
on the server to ensure that the user is authorized to access the re-
quested data. It is important to perform access validation at multiple
levels, including the data or object level, to ensure that there are no
holes in the process. By performing access validation, organizations
can effectively prevent IDOR vulnerabilities and protect sensitive data
from unauthorized access.
39
7 Attempt to exploit more secure code
Let’s revisit the steps we took previously to exploit the vulnerability.
The following figures illustrate the actions taken in the correct order.
40
Figure 31: Intercepting request and sending it to the intruder.
41
Figure 32: Clearing unrelated fields and changing user ID, configuring
payloads as before
42
As can be seen in the figure below, all of the requests we sent
resulted in 400 and we got the unauthorized message as a response.
43
We also got 400 and we got the unauthorized message when trying
to manipulate BurpSuite request.
8 References
• Github E-Commerce Repository – https://github.com/justdjango/
django-ecommerce
• https://shellmates.medium.com/insecure-direct-object-references-i
• https://spanning.com/blog/insecure-direct-object-reference-web-ba
• https://portswigger.net/web-security/access-control/idor
• https://www.eccouncil.org/cybersecurity-exchange/web-application-
idor-vulnerability-detection-prevention/
44