🗂️PortSwigger Lab Writeup: User ID Controlled by Request Parameter with Unpredictable User IDs

🎯 Objective
The objective of this lab is to exploit a broken access control where the app has a horizontal privilege escalation vulnerability on the user account page. The goal is to obtain the API key for the user carlos.
- Lab URL:
https://portswigger.net/web-security/access-control/lab-user-id-controlled-by-request-parameter-with-unpredictable-user-ids - Category: Access Control
- Difficulty: Apprentice
🧪 Exploitation Steps
🕵️Step 1: Observe the Website
- Firstly open the lab URL in your browser, and observe what it is about and how it works.


- At first glance, the website seems to be a shopping website with a login page. In the lab description, it is mentioned that we need to obtain the API key for the user
carlos.
📝Step 2: Login as wiener
- Login with the credentials of user wiener to access the account page first.

- Now, On user account page of wiener we can see the API key of wiener.

- Now, Move to home page and click on the first post.

- Here, you can see that there is a hyperlink embedded in page for the author of the post.
- Open the source code of the page to confirm if there is UserId embedded in this hyperlink.

- Hence, This is confirmed that UserIds of user are embedded in their written posts.
- Now, find a post which is authored by carlos to obtain its UserID.

- Open the source code of this post to copy the UserID of carlos

- Copy the UserID and Go to the account page of wiener to paste this UserID in
/my-account?id=parameter.
- Hence, we can now see the API key of user carlos.
🧑💼Step 3: Submit API of carlos
- Copy the API key of carlos and submit it in Submit Solution.

- And Finally, the Lab is solved.
🧠 Conclusion
- This lab demonstrated how information disclosure in public content can enable horizontal privilege escalation. Even with unpredictable user IDs, the application exposed user identifiers in HTML source code via blog post author links, allowing attackers to discover and access other users' API keys.
- The impact is high — sensitive user identifiers leaked across the application (in HTML, JavaScript, API responses) enable attackers to enumerate users and access their private data regardless of whether the IDs are predictable.
- Fix: minimize information disclosure by not embedding user IDs in public/client-side content, use generic descriptions for author links, enforce proper server-side authorization on all account endpoints, validate that the current user owns the requested account before exposing sensitive data, and regularly audit all user-facing content for leaked sensitive information.