DEV Community

Victor
Victor

Posted on Edited on

Corridor: Finding the Hidden Door Through IDOR

1. Introduction

In this write-up, I will document my experience completing the Corridor room on TryHackMe, focusing on identifying and exploiting an Insecure Direct Object Reference (IDOR) vulnerability.

At first glance, the challenge looks relatively simple. The web application presents a corridor containing multiple doors. Each door represents a different location, and clicking on one redirects us to another URL.

However, something interesting caught my attention: the URLs contained long hexadecimal strings that looked like MD5 hashes.

Instead of randomly clicking through every door, I decided to investigate how these URLs were generated and whether the application was using predictable identifiers behind the scenes.

The main objective was to understand how insecure object references can expose resources that are not directly accessible through the application's interface.

2. Understanding the Vulnerability – IDOR

Before exploring the application, it is important to understand the vulnerability behind this challenge.

IDOR (Insecure Direct Object Reference) is an access control vulnerability that occurs when an application uses user-controllable identifiers to access internal resources without properly verifying whether the requester is authorized to access them.

For example, consider an application that provides the following URLs:

https://example.com/user/1001
https://example.com/user/1002
https://example.com/user/1003
Enter fullscreen mode Exit fullscreen mode

If the application does not enforce proper authorization checks, an attacker might change 1001 to 1002 and access another user's information.

The important point is that the application trusts the supplied object reference without verifying whether the current user has permission to access the requested resource.

In Corridor, the application uses MD5 hashes instead of directly exposing numerical identifiers. Although this makes the URLs look less predictable, it does not necessarily make the underlying resources secure.

3. Reconnaissance – Exploring the Web Application

After deploying the target machine on TryHackMe, I accessed the assigned IP address through my browser.

The first thing I noticed was a corridor containing multiple clickable doors.

At this stage, I did not know what each door represented or whether there were hidden resources behind the visible interface.

3.1. Initial Enumeration

I started by interacting with several doors and observing how the application behaved.

Each time I clicked a door, the browser navigated to a different URL.

For example:

http://<TARGET_IP>/c4ca4238a0b923820dcc509a6f75849b
Enter fullscreen mode Exit fullscreen mode

Another door generated a different path:

http://<TARGET_IP>/c81e728d9d4c2f636f067f89cc14862c
Enter fullscreen mode Exit fullscreen mode

The pages themselves did not reveal much useful information.

However, the URL structure immediately caught my attention.

The path contained a 32-character hexadecimal string, which is a common representation of an MD5 hash.

Rather than treating these values as random identifiers, I decided to investigate their origin.

3.2. Inspecting the Page Source

Instead of manually clicking every door, I inspected the website's HTML source code using the browser's Developer Tools.

I wanted to understand how the doors were implemented and whether their destinations were already available in the page source.

This allowed me to identify the URL references associated with the different doors.

An important observation was that the application used an image map with clickable areas. Each area referenced a different hexadecimal path.

This gave me a useful starting point for analyzing the identifiers.

4. Analyzing the MD5 Hashes

The next step was to determine whether the hexadecimal values were actually MD5 hashes.

MD5 produces a 128-bit hash value, commonly represented as a 32-character hexadecimal string.

For example:

MD5("1") = c4ca4238a0b923820dcc509a6f75849b

MD5("2") = c81e728d9d4c2f636f067f89cc14862c

MD5("3") = eccbc87e4b5ce2fe28308fd9f2a7baf3
Enter fullscreen mode Exit fullscreen mode

I noticed that these values matched the URLs generated when clicking the first few doors.

This suggested that the application was using MD5 hashes of sequential integer values as resource identifiers.

4.1. Verifying the Hash Pattern

To verify this assumption, I used Python's built-in hashlib library.

import hashlib

for i in range(1, 14):
    hashed_value = hashlib.md5(str(i).encode()).hexdigest()
    print(f"{i}: {hashed_value}")
Enter fullscreen mode Exit fullscreen mode

The output generated a sequence of hashes corresponding to the visible doors.

This confirmed an important detail:

The application was not generating random identifiers. It was calculating MD5 hashes from predictable integer values.

4.2. Understanding the Security Problem

At this point, I had identified the underlying pattern.

The application appeared to follow this logic:

Room ID
   |
   v
Convert integer to string
   |
   v
Generate MD5 hash
   |
   v
Use hash as URL path
   |
   v
Retrieve corresponding resource
Enter fullscreen mode Exit fullscreen mode

The problem was that MD5 hashing did not prevent someone from generating another valid identifier.

Since the original input was predictable, I could calculate the hash for any integer without needing to reverse the hashing algorithm.

This was the key observation that led to the exploitation stage.

5. Exploitation – Finding the Hidden Door

After identifying the pattern, I started thinking about the possible resource identifiers.

The visible doors represented sequential values from 1 to 13.

However, I wanted to determine whether the application accepted identifiers outside this range.

I decided to test boundary values.

5.1. Testing the Next Sequential Value

My first attempt was to calculate the MD5 hash of 14.

echo -n "14" | md5sum
Enter fullscreen mode Exit fullscreen mode

The resulting hash was:

aab3238922bcc25a6f606eb525ffdc56
Enter fullscreen mode Exit fullscreen mode

I then appended this value to the target URL and accessed it through my browser.

The application did not return the expected hidden resource.

This indicated that simply increasing the identifier was not the correct approach.

5.2. Thinking About the Lower Boundary

Instead of continuing to test larger numbers, I considered the opposite direction.

The visible sequence started at 1.

What if the application also supported a resource identified by 0?

I generated its MD5 hash:

echo -n "0" | md5sum
Enter fullscreen mode Exit fullscreen mode

The output was:

cfcd208495d565ef66e7dff9f98764da
Enter fullscreen mode Exit fullscreen mode

Next, I modified the URL by replacing the existing hash with the newly generated value:

http://<TARGET_IP>/cfcd208495d565ef66e7dff9f98764da
Enter fullscreen mode Exit fullscreen mode

I submitted the request through my browser.

This time, the application returned the hidden resource containing the flag.

5.3. Retrieving the Flag

The hidden endpoint was accessible even though it was not represented by any of the visible doors.

This demonstrated that the application was accepting a predictable object reference without adequately restricting access to the underlying resource.

The challenge was completed after retrieving the flag and submitting it to TryHackMe.

Flag:

flag{<FLAG>}
Enter fullscreen mode Exit fullscreen mode

6. Technical Analysis – Why Did This Work?

The interesting part of Corridor is not the MD5 algorithm itself. It is how the application used the hash as a resource identifier.

6.1. MD5 Is Not Encryption

One important distinction is that MD5 is a hashing algorithm, not an encryption algorithm.

Encryption is designed to be reversible using the appropriate decryption key.

Hashing is designed to be a one-way transformation.

However, this does not mean that MD5 hashes of predictable values are impossible to identify.

For example, if an application calculates:

hashlib.md5(b"1").hexdigest()
Enter fullscreen mode Exit fullscreen mode

An attacker can calculate the same value independently.

There is no secret involved in generating the hash.

Therefore, hashing a sequential integer does not provide meaningful protection against enumeration.

6.2. The Root Cause

The underlying security issue can be summarized as follows:

  • The application used predictable integer values as resource identifiers.
  • It converted those identifiers into MD5 hashes.
  • The resulting hashes were exposed through URLs.
  • The application allowed direct requests using those identifiers.
  • The server did not adequately enforce authorization restrictions on the requested resource.

The hash provided obscurity, not authorization.

6.3. Why This Is an IDOR Vulnerability

IDOR occurs when an attacker can manipulate an object reference to access a resource they should not be able to access.

In this challenge, manipulating the URL path allowed me to access a resource that was not linked through the normal interface.

The important security lesson is that hiding an identifier does not replace server-side access control.


7. Security Impact

In a real-world application, similar implementation mistakes could have serious consequences.

Depending on the resources exposed, an attacker might be able to:

  • Access other users' private information.
  • Retrieve confidential documents.
  • View internal application resources.
  • Access administrative functionality.
  • Modify or delete resources belonging to other users.
  • Discover endpoints that are not exposed through the normal interface.

The impact depends on the application's functionality and the permissions enforced by the backend.

For example, an IDOR vulnerability in a financial application could expose transaction information or potentially allow unauthorized modifications to financial records.


8. Mitigation and Prevention

There are several ways developers can prevent this type of vulnerability.

8.1. Implement Server-Side Authorization

Every request should be checked against the authenticated user's permissions.

The application must verify that the requester is authorized to access the requested resource, regardless of whether the identifier is numerical, hashed, or randomly generated.

8.2. Avoid Predictable Resource Identifiers

Using randomly generated identifiers, such as UUIDs, can make enumeration more difficult.

However, this should only be considered an additional security measure.

Random identifiers do not replace proper authorization checks.

8.3. Apply Object-Level Access Control

The backend should validate ownership and permissions before returning or modifying an object.

For example:

def get_document(user, document_id):
    document = database.get_document(document_id)

    if document.owner_id != user.id:
        raise PermissionError("Access denied")

    return document
Enter fullscreen mode Exit fullscreen mode

This example illustrates the importance of checking ownership rather than trusting the supplied identifier.

8.4. Perform Security Testing

Developers should regularly test direct object references and authorization boundaries.

Useful testing approaches include:

  • Changing resource identifiers manually.
  • Testing sequential and boundary values.
  • Inspecting HTTP requests and responses.
  • Testing access between different user accounts.
  • Reviewing backend authorization logic.

9. Key Takeaways

Completing Corridor helped reinforce several important web security concepts.

1. Never trust identifiers supplied by clients.

URLs and request parameters can be manipulated. Every resource request needs proper server-side validation.

2. Hashing does not equal authorization.

MD5 hashes of predictable values can be generated easily. They should never be treated as a security boundary.

3. Always inspect the application structure.

Looking at the HTML source revealed useful information about how the application generated its endpoints.

4. Test boundary conditions.

Testing values outside the visible range was what eventually led me to the hidden resource.

5. Understand the difference between obscurity and security.

A resource that is difficult to discover is not necessarily protected. Real security comes from correctly implemented authentication and authorization mechanisms.


10. Conclusion

Corridor is a short but valuable introduction to IDOR vulnerabilities.

What initially appeared to be a simple web application with several clickable doors turned into an interesting exercise in URL analysis, hash identification, and resource enumeration.

The most important discovery was that the application used MD5 hashes of sequential integers as resource identifiers. By identifying this pattern and testing a boundary value, I was able to access a hidden endpoint that was not available through the normal interface.

My biggest takeaway from this challenge is that security should never depend on how difficult an identifier looks.

Whether an application uses sequential numbers, MD5 hashes, or UUIDs, the backend must always verify that the requester has permission to access the requested resource.

That is the fundamental lesson behind IDOR, and it is something I will keep in mind when both developing and testing web applications.


Author: Victor Hoang

Platform: TryHackMe

Room: Corridor

Topics: Web Security | IDOR | MD5 | Access Control | Enumeration

Top comments (0)