🗂️PortSwigger Lab Writeup: User Role Controlled by Request Parameter

🎯 Objective
The objective of this lab is to exploit a broken access control where the app has an admin panel which identifies administrators using a forgeable cookie. The goal is to access the admin panel and delete the user carlos.
- Lab URL:
https://portswigger.net/web-security/access-control/lab-user-role-controlled-by-request-parameter - 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 access the admin panel and then delete the account of
carlos.
📝Step 2: Try Accessing Admin Panel
- In order to access the admin panel, we need to first login with the given account credentials -
wiener:peter
- On our account page ,we only see a feature to update the email.

- Now, open admin panel located at
/admin
- Hence, We get an error saying that the Admin interface can only be accessed by Administrator.
- Now, Open the HTTP History in Burpsuite and see the
GET /adminrequest and its response to find any loophole to access the admin panel.
- Here, we can see that there is a cookie
Admin=falsethrough which backend might be checking if an Administrator is accessing the panel or not. - Now, lets change this cookie value through Browser Developer Tools from
Admin=falsetoAdmin=true
- Now, Open the admin panel after changing the value of cookie.

- Hence, we are now able to access the admin panel by successfully forging the cookie value.
🧑💼Step 3: Delete carlos
- Click on the Delete option for carlos to delete the account.

- And Finally, the Lab is solved.
🧠 Conclusion
- This lab demonstrated how broken access control through client-side cookie manipulation allows unauthorized privilege escalation. By changing the
Admin=falsecookie toAdmin=true, we bypassed role-based access controls and gained administrative access. - Such vulnerabilities have a critical impact — attackers can easily modify cookies to escalate privileges, access sensitive functionality, and perform unauthorized administrative actions.
- Fix: implement server-side session management with secure role verification, never trust client-side parameters or cookies for authorization decisions, use cryptographically signed tokens (JWT with proper validation), store user roles server-side in secure sessions, and implement proper role-based access control (RBAC) with server-side enforcement.