- Among the most common web vulnerabilities
- Occur when webapp exposes a direct reference to an object (like a file, or database resource) that users can directly control to obtain access to similar objects.
- Any access to resources due to lack of solid access control system is considered idor
Building access control is challenging, which is why IDOR is pervasive. Automating the process of identifying weaknesses in access control systems is also quite difficult
IE:
- User requests access to file they recently uploaded
- Receive link :
download.php?file_id=123 - Link directly references file
- If no access control = directly access any file by sending a req with its' file_id
- in many cases we'll find that the
idis easily guessable - access
download.php?file_id=124for example
- in many cases we'll find that the
What makes this important? A direct ref to an internal object or resource by itself is not directly a vulnerability.
- However it is indicative to another vulnerability: Weak access control
- Many webapps restrict users from accessing resources by restricting them from accessing pages/apis/funcs that can retrieve these resources.
- Assume users get access to these pages through a shared/guessed link
- Can they still access by simply having link?
- If webapp does not have access control on backend that compares user auth to resource access list, we may be able to.
There are many ways to implement solid access control for webapps like RBAC
- Main takeaway: IDOR vulnerability mainly exists to lack of access control on backend. If users had direct reference to objects in a webapp that lacks access control it would be possible to view/modify other users' data.
Devs ignore this frequently. Lots of web apps and mobile apps are left unprotected in the backend.
- In these apps: All users have arbitrary access to all other user data on the backend.
- Only thing stopping users from accessing another user's data is front-end implementation - designed to only show user's data.
- In such cases, manually manipulating HTTP requests may reveal all users have full access.
All of this makes idor vulns among the most critical vulns for any web/mobile app - not only due to exposing direct object references but because of a lack of a access control system. Even basic access control is challenging to develop. A comprehensive access control system covering the entire webapp without interfering with its' functions is even more difficult. IDOR/Access control vulns are found even in very large webapps, like facebook, instagram, and twitter.
neat articles: https://medium.com/@kedrisec/publish-tweets-by-any-other-user-6c9d892708e3 https://infosecwriteups.com/add-description-to-instagram-posts-on-behalf-of-other-users-6500-7d55b4a24c5a https://infosecwriteups.com/disclose-private-attachments-in-facebook-messenger-infrastructure-15-000-ae13602aa486
IDOR impact: Typically very large impact. Most basic example:
- accessing private files and resources of other users that should not be accessible (personal files, cc data (known as IDOR information disclosure vulnerabilities))
- Depending on nature of the exposed direct reference, the vulnerability may even allow the modification or deletion of other user's data which may lead to a complete account takeover.
- Once attacaker identifies the direct references
- db ids,
- url params
- they can begin testing specific patterns to see whether they can gain access to any data and may eventually understand how to extract/modify data for any arbitrary user.
IDOR vulns may also lead to user priv escalation from std to admin.
IDOR Insecure function calls
- many webapps expose url params/apis for admin-only fxs in front-end of the webapp and disable these functions for non-admin users.
- If we had access to such params/apis we can call them with our std user priv. If backend doesn't explicitly deny non-admin users from calling these functions we can perform unauth admin operations
- changing user pws
- granting users certain roles
- leading to total takeover
Identifying IDORs
URL Parameters and APIs First step: Identify direct obj references, of course.
- when requesting a file or resource, study HTTP requests to look for URL params or APIs with an object reference
?uid=1?filename=file_1.pdf
- Most basic cases we can try incrementing the values of the object reference to retrieve other data like
?uid=2or?filename=file_2.pdffor example - We can also fuzz to try thousands of variations to see if data is returned. Successful hits to files that are not our own may indicate IDOR vulnerabilities exist
AJAX calls Identify unused parameters or APIs in front-end code in the form of Javascript AJAX calls Some webapps developed in JS frameworks may insecurely place all function calls on the frontend + use appropriate ones based on user roles
IE:
- Nonadmin account (only user-level fx used, admin fx disabled)
- Find admin fx (looking into JS code)
- Identify AJAX calls to specific endpoints or APIs that contain direct object references
- If we identify direct object references in the JS dcode we can test them for IDOR.
This is not unique to admin functions, can be any fx or call that may not be found through monitoring HTTP requests.
Example AJAX call:
function changeUserPassword() {
$.ajax({
url:"change_password.php",
type: "post",
dataType: "json",
data: {uid: user.uid, password: user.password, is_admin: is_admin},
success:function(result){
//
}
});
}
We'd expect this is never able to be called as a non-admin If we locate in front-end we may test it in different ways to test whether we can call it to perform changes indicating IDOR
Understand Hashing/Encoding Webapps may not use simple sequential numbers as IDs for object references and hash it instead. If we find such parameters using encoded/hashed values ; we can still exploit them if there's no access control system on the backend.
Suppose the reference was encoded with something common like base64. We can decode it and view the plaintext of the object reference, change its' value, and encode it again to access other data.
- IE:
?filename=ASdajlajgaGAgASDSAD==we can immediately guess b64 encoded- decode to get original object ref (for example,
file_1) - encode a different object ref (i.e.
file_2) - and proceed to try accessing it with the b64 encoded str above.
- decode to get original object ref (for example,
On the other hand, obj ref may be hashed like:
download.php?filename=c81e728d9d4c2f636f067f89cc14862c
At first glance we may think this is a 'secure' obj ref, it's not using cleartext or easy encoding. If we look at source code we may see that it is being hashed before the API call is ever made:
$.ajax({
url:"download.php",
type: "post",
dataType: "json",
data: {filename: CryptoJS.MD5('file_1.pdf').toString()},
success:function(result){
//
}
});
Above we see code uses the filename and hashes it with cryptojs.md5 making it easy for us to calculate the filename for other potential files.
Otherwise we may manually try to identify the hashing algorithm used with hash identifier tools; and hash the filename to see if it matches the used hash. Once we can calculate hashes for other files, we repeat above process potentially revealing an IDOR vuln if possible to download files that do not belong to us.
Compare user roles More advanced IDOR attacks, we may need to register multiple users and compare their http requests and object references.
- gathers intel on how URL params and unique identifiers are being calculated + calculate them for other users to gather their data.
- i.e. :
{
"attributes" :
{
"type" : "salary",
"url" : "/services/data/salaries/users/1"
},
"Id" : "1",
"Name" : "User1"
}
If we have access to 2 users, one of which can view their salary after making the above API call.
- 2nd user may not have all of these API params to replicate the call and should not be able to make the same call as 1st user.
- With these details at hand we can try repeating the same API call while logged in as User2 to see if webapp returns anything.
- Such cases may work if webapp only requires valid login session to make API calls but no access control mechanism to compare caller session + data being called
- In such a case we can calculate API parameters for other users, thus IDOR
- Even if we cannot calculate API params for other users we would still identify a vulnerability in the back-end access control system and may start looking for other object references to exploit.
Mass IDOR enumeration Easy in some instances but very challenging in others. Once we identify potential IDOR we can start testing it with basic techniques to see whether it would expose any other data. In advanced IDOR we need to better understand:
- how webapp works
- how it calculates object references
- how its' access control system works
Below discussing various techniques from basic enumeration to mass data gathering to user priv escalation.
Insecure parameters Basic example that showcases a typical IDOR vuln: "Employee Manager" webapp hosting employee records
- Assumes we logged in as employee with
userid=1- In a real webapp we have to login
- Once we click on Documents, directed to:
/documents.php - When directed to
Documentspage we see several documents that belong to our user./documents/Report_1_09_2021.pdf/documents/Invoice_1_10_2021.pdf- Predictable naming pattern
- Has uid in filename and month/year
- These elements is one of the most basic type of idor vulns and is called a
static file IDOR - To successfully fuzz other files, we would assume that they all start with
ReportorInvoicewhich may reveal some files but not all.
- Page sets
uidwithGETparameter in the url asdocuments.php?uid=1- If webapp uses this uid
GETas direct ref to employee records it should show we may be able to view other employees' docs by simply changing this value. - If backend webapp
doeshave access control we should receive 403 - Given webapp passes our UID in cleartext as a direct ref, this may indicate poor webapp design and lead to arbitrary access to employee records.
- Another example is using a filter parameter to only display a specific users' docs like
uid_filter=1which can also be manipulated
- If webapp uses this uid
Mass enumeration
Try manually accessing all other employee docs with uid=3, uid=4 etc and so on.
Manually accessing files is not efficient in a real work env with hundreds or thousands of employees.
- Use burp/zap to retrieve all files or write a small bash script.
Inspect web browser tools -> enable element inspector
- click on any of the links to view html source
Example:
<li class='pure-tree_link'><a href='/documents/Invoice_3_06_2020.pdf' target='_blank'>Invoice</a></li>
<li class='pure-tree_link'><a href='/documents/Report_3_01_2020.pdf' target='_blank'>Report</a></li>
Pick any unique word to grep the link of the file. Each link starts with
<li class='pure-tree_link'>
so we can curl the page and grep for this line:
curl -s "http://SERVER_IP:PORT/documents.php?uid=1" | grep "<li class='pure-tree_link'>"
easily capture the document links successfully. We can use some bash commands to trim the extra parts and only get doc links in output.
- Usually better practice to use a regex pattern that matches strings between
/documentand.pdfwhich we can use withgrepto only get doc links:
curl -s "http://SERVER_IP:PORT/documents.php?uid=3" | grep -oP "\/documents.*?.pdf"
/documents/Invoice_3_06_2020.pdf
/documents/Report_3_01_2020.pdf
creating a for loop to loop over the uid param and return document for all employees, and wget to download each document link
#!/bin/bash
url="http://SERVER_IP:PORT"
for i in {1..10}; do
for link in $(curl -s "$url/documents.php?uid=$i" | grep -oP "\/documents.*?.pdf"); do
wget -q $url/$link
done
done
this is only one example of how we can achieve this objective, try using burp/zap or writing your own bash / powershell script to download all documents
IDOR - Bypassing encoded references
Referring to same example above there is new functionality, Contracts page:
Clicking on the pdf it downloads the file, and in Burp the contract PDF file name looks like the following:
contract=cdd96d3cc73d1dbdaffa03cc6cd7339b
POST request sent to download.php for this above filename.
Using download.php script to download files is common practice to avoid directly linking files. However in this case webapp is not sending direct reference in cleartext but appears to be hashing the filename with md5.
- hashes are 1-way
We can attempt to hash various values like uid, username, and filename to see if their md5 hashes match the above value - if we find a match we can replicate it for other users and collect their files. for example, compare md5 hash of our uid and see if it matches:
echo -n 1 | md5sum
(these hashes do not match)
We can attempt this with various other fields but none of them match our hash.
- In advanced cases we can also use Burp Comparer + fuzz various values then compare each to our hash to see if we find any matches. In this case, md5 hash could be for a unique value or a combination of values which could be very difficult to predict.
- Hence, this direct reference is a
Secure Direct Object reference- However! there is a fatal flaw in this web application.
Function disclosure Most modern webapps use JS frameworks like angular, react, vue.js etc. Many web devs make the mistake of performing sensitive functionality on the frontend. Thus we can view source code and determine what they're doing to calculate this hash value.
function downloadContract(uid) {
$.redirect("/download.php", {
contract: CryptoJS.MD5(btoa(uid)).toString(),
}, "POST", "_self");
}
Function:
- sends POST request with
contractparameter - value being sent is md5 hash using
CryptoJSlibrary- matches request we saw earlier
- In this case value being hashed is
btoa(uid)which is base64 encoded string of theuidvariable which is an input argument for the function. - going back to an earlier link where the function was called we see it calling
downloadContract('1') - Final value being used in the POST request is the base64 encoded string of
1which has beenmd5hashed. thus:echo -n 1 | base64 -w 0 | md5sumgives us a matching hash (-n-> avoid adding newlines and-wsame thing)
Hashes match = successfully reversed hashing technique used by object references, leading to IDOR. With that, we can enumerate other employee contracts using the above method. At this point we should write a script similar to the previous example and generate a list of hashes for attempting to download the contract files
Mass enumeration
Example bash script to generate 1-20 using the same reversing scheme above
for i in {1..10}; do echo -n $i | base64 -w 0 | md5sum | tr -d ' -'; done
POST request on download.php with each of the above hashes as the contract value which would give us our final script:
#!/bin/bash
for i in {1..10}; do
for hash in $(echo -n $i | base64 -w 0 | md5sum | tr -d ' -'); do
curl -sOJ -X POST -d "contract=$hash" http://SERVER_IP:PORT/download.php
done
done
IDOR example module

     
 
used chatgpt to make a bash script tbqh also used chatgpt to url-encode all of the above base64 encoded strings for input to the curl command
 
IDOR in Insecure APIs
In prev sections we've been looking at IDOR vulns to access files and resources outside of user access.
- IDOR can also exist in function calls and APIs
IDOR Information Disclosure Vulnerabilities allows us to read various types of resources whileas
IDOR Insecure Function Calls enable us to call APIs or execute functions as another user.
- i.e. apis / functions to change another user's private information, reset a password, or even buy items
- many cases - obtain info through info disclosure idor, using this information with idor insecure function calls
Identifying insecure APIs  in this example we are exposed the following information:
- put request to an API endpoint
- json body reveals
roleanduid,uuidfields - cookie contains key,value pair
role=employee(common security issue)
unless webapp explicitly defends against this, we should be able to arbitrarily set roles for our user.
Exploiting insecure APIs
We know we can change full_name , email, and about parameters (above) as these are under our control under /profile
Few examples or food for thought in this example:
- Change our
uidto another user'suid, such that we can take over their accounts- in our example, swapping uid gives us
uid mismatchresponse - indicating there is some backend access control
- in our example, swapping uid gives us
- Change another user's details, which may allow us to perform several web attacks
- changing api to
profile/api.php/profile/2and changing"uid":2, we getuuid mismatch - indicates checking uuid value we send matches user's uuid
- changing api to
- Create new users with arbitrary details, or delete existing users
- Send
POSTreq to api endpoint. Change request method to POST, change uid to a new uid, and send the request to the api endpoint of the newuid - receive response
Creating new employees is for admins only
- Send
- Change our role to a more privileged role (e.g.
admin) to be able to perform more actions- Doing a PUT req and trying to update our role to
admingives usInvalid role(we don't know the role name for administrator)
- Doing a PUT req and trying to update our role to
All our attempts failed! Is it secure?
- So far only tested
IDOR insecure function calls- however, we have not tested the API's
GETrequest forIDOR Information Disclosure Vulnerabilities- if no access control we might be able to read other user details
- however, we have not tested the API's
Thus our task is: test api against IDOR Information Disclosure vulnerabilities by attempting to get other users' details with GET requests
If API is vulnerable we may be able to leak user details and use this information to complete our IDOR attacks on function calls.
Module exercise:
Try to read details of user with uid=5. Whats their uuid?




Chaining IDOR vulnerabilties
Get request to API returns details of requested user.
Only form of auth is role=employee cookie.
- Note here even if we had a JWT unless this is checked explicitly by backend we may still be able to retrieve other user details
Information disclosure:
- GET req with another uid.
- Return details of another user with their uuid and role confirming we have
idor info disclosure vuln
- Return details of another user with their uuid and role confirming we have
- this provides us with new details, most notable the
uuidwhich we could not calculate before and thus could not change other user details
Now that we have another user uuid we can try testing a PUT req against the API that will modify the user's information
In addition to allowing us to view sensitive info the ability to modify another user's details also enables us to perform several other attacks.
- IE - modifying user's email address and requesting a pw reset
- Placing an XSS payload in the 'about' field, executed once user visits their Edit Profile page
Chaining two IDOR vulnerabilities
Since we have idor info disclosure, enumerate all users + identify other roles (ideally an admin role)
Objective: Try and write a script to enumerate all users, simularly to what we did previously.
More/less a repeat of what we did earlier. just asked chatgpt to curl out all of the ids 1-20 and we get an admin user:

now the objective is:
Try to change the admin's email to 'flag@idor.htb', and you should get the flag on the 'edit profile' page.
example PUT changing our own profile:   this should theoretically work
