IDOR & Security Headers
IDOR & Security Headers
Insecure direct object reference (IDOR) is a type of security vulnerability that occurs
when an application allows a user to manipulate a direct object reference (such as an
ID number or file name) to access unauthorized resources.
For example, suppose a web application allows users to view their account details by
providing their account ID in the URL. The URL might look something like this:
https://banksite.com/account?id=1234
In this case, the account ID "1234" is used as a direct object reference to retrieve the
user's account details from the database.
If an attacker can guess or manipulate the account ID parameter in the URL, they may
be able to access other users' account details, even if they don't have permission to
do so.
For instance, an attacker may try to access the account details of another user by
changing the account ID parameter in the URL to a different value:
https://banksite.com/account?id=1235
If the application does not properly validate the user's access rights to the requested
account, the attacker could access the sensitive information of another user.
Identifiers are becoming more frequently seen in headers or APIs rather than directly
in a user's address bar. However, because most websites are dynamic, identities and
parameters are still widely utilized in some capacity.
• Database keys
• Query parameters
• User or session IDs
• Filenames
Attackers frequently employ the Burp Suite Tool to carry out these kinds of attacks.
An attacker will first choose the website that would be the target of his IDOR assault.
The website is then included in the scope and spidered to collect all of the URLs with
the desired criteria.
Step 2: Request Parameter Filtering
Following the initial step, we will filter our collected requests using the parameter filters.
The only options available to an attacker for attack execution are that parameter or
injection points.
At this stage, if an attacker finds any injection places where they can run IDOR, they will
request the repeater. The vulnerable URL may be something
like www.abc.com/myaccount/uid=23. In this case, the "UID" appears to be weak.
Now that the attacker has access to the weak injection point, they will attempt to carry
out the IDOR attack using social engineering or the pattern specified in the injection
point. For instance, if an attacker changes uid from 23 to 24, another user’s account
with the ID number 24 will be opened.
Most IDOR-based attacks operate in similar ways, however, there are small
differences in how the identifier is revealed and/or exploited by hackers.
Body Manipulation:
The values of checkboxes, radio buttons, and other form elements may need to be
changed to do this. Potentially, hidden form values might also be modified.
The user ID for the account that is currently logged in may be passed on by a contact in
a hidden form field. We can make our request appear to come from a different user if we
can change that hidden value before submitting the form.
URL Tampering:
For example, let’s suppose there’s an example URL that may be something like
‘http://example.com/category/photos_id=1’
Cookie ID Manipulation:
Cookies are used to store and exchange data between the client and server. It helps in
identifying specific users and provides a good browsing experience to the user.
For example, there’s a cookie id in a web application that may be something like this
_gid=123456 which is for user A, and another cookie id is _gid=789012 which is for
user B.
So, if user A can change the value of _gid and replace the ID of user B and can see any
information which belongs to user B then there’s an IDOR.
Directory Traversal:
Directory Traversal is also known as a Path Traversal attack where an attacker can
access or manipulates the files and folders which should not be allowed to access
publicly. If there is a Directory Traversal vulnerability exists in a web application then
the attacker can easily able to see some sensitive files or folders such as images, themes,
scripts, and so on.
https://www.example.com/display_file.php?file.txt
https://www.example.com/display_file.php?../../../etc/passwd
4. Reputation Damage:
An IDOR vulnerability that results in a data breach or other security incident can
damage an organization's reputation and erode customer trust. This can result in
lost business, legal liability, and other negative consequences.
Developers should avoid displaying private object references such as keys or file
names.
Validation of Parameters should be properly implemented.
Verification of all the Referenced objects should be done.
Tokens should be generated in such a way that they should only be mapped to
the user and should not be public.
Use random identifiers so that it will be a little bit hard to guess for attackers.
Validation of user input should be properly implemented.
HTTP Security Headers
HTTP security headers are response headers that can be included in HTTP(S)
responses from a web server to provide additional security protections to web
browsers and other user agents.
These headers help protect against various types of attacks, including cross-site
scripting (XSS), clickjacking, and MIME-type sniffing.
CSP headers allow websites to define a policy that specifies which sources of
content are allowed to be loaded and executed on the page. This helps prevent
XSS attacks by blocking the execution of scripts that are not explicitly allowed by
the policy.
X-XSS-Protection:
X-Content-Type-Options:
By using the X-Content-Type-Options header, web developers can ensure that the
browser will always interpret responses with the correct MIME type, preventing
attacks that exploit MIME-sniffing vulnerabilities.
X-Frame-Options:
This header prevents a page from being displayed in an iframe, which can help
prevent clickjacking attacks.
Strict-Transport-Security (HSTS):
HTTP Strict Transport Security (HSTS) is an HTTP response header that can be
used to protect websites against man-in-the-middle attacks and cookie hijacking.
Suppose you have a website called www.example.com, and you have recently
migrated it from HTTP to HTTPS by purchasing an SSL certificate. However, some
users may still access your site using HTTP. To address this, you can redirect
HTTP users to HTTPS. However, during the redirection process, there is a risk of a
man-in-the-middle attack, where an attacker intercepts the traffic and poses as the
website to steal sensitive information.
To prevent this, the HSTS header can be used. When the browser sees the HSTS
header in the response, it is instructed to always use HTTPS to access the site,
even if the user types in the HTTP URL or if an attacker tries to redirect the user to
an HTTP URL. This prevents the risk of man-in-the-middle attacks and ensures that
sensitive information is always transmitted securely over HTTPS.
Referrer-Policy:
This header controls how much information about the referring page is sent to the
destination site, which can help protect user privacy.
REFERENCE
https://spanning.com/blog/insecure-direct-object-reference-web-based-
application-security-part-6/
https://portswigger.net/web-security/access-control/idor
https://crashtest-security.com/insecure-direct-object-reference-idor/
https://www.invicti.com/learn/insecure-direct-object-references-idor/
https://www.acunetix.com/blog/web-security-zone/what-are-insecure-direct-
object-references/
https://www.scaler.com/topics/cyber-security/idor/
https://www.geeksforgeeks.org/insecure-direct-object-reference-idor-
vulnerability/
https://www.loginradius.com/blog/engineering/http-security-headers/
https://www.wpoven.com/blog/http-security-headers/