User Role Controlled by Request Parameter: I Became Admin by Changing One Cookie (PortSwigger Lab Walkthrough)

A step-by-step PortSwigger lab walkthrough: when you log in, the site gives your browser a cookie, Admin=false, and then trusts whatever comes back. Intercept the request in Burp Suite, change false to true, and the admin panel opens.

Difficulty: Apprentice
Category: Access control
Lab: User role controlled by request parameter

The website decides who is admin with a cookie. The cookie lives in your browser, so you decide.

This is the third lab in this access control series, after Unprotected admin functionality and Unprotected admin functionality with unpredictable URL. This time you need Burp Suite.

The goal

The lab description: this lab has an admin panel at /admin, which identifies administrators using a forgeable cookie. Delete the user carlos. Log in with wiener:peter

The admin panel is at /admin, and it identifies administrators using a forgeable cookie. To solve the lab, open the admin panel and delete the user carlos. You can log in to your own account with wiener:peter.

Step 1: Log in

Open the lab, go to My account, and log in as wiener with the password peter.

Logged in to My Account: Your username is: wiener

Step 2: Try the admin panel

Visit /admin. It's not available to you:

Admin interface only available if logged in as an administrator

In Burp Suite, turn Intercept on, then visit /admin again. Burp catches the request before it reaches the server:

Burp Suite intercepted GET /admin with Cookie: Admin=false; session=...

Look at the cookie header:

http
Cookie: Admin=false; session=...

false means you are not the admin, and true means you are. Change it to true, then forward the request.

The same request with Cookie: Admin=true

The admin panel is now accessible:

The admin panel: Users wiener and carlos, each with a Delete link

Step 4: Delete carlos

Click Delete next to carlos. That's a new request, which also carries Admin=false, so intercept it and change the cookie to true again before forwarding it.

Burp Suite intercepted GET /admin/delete?username=carlos with the cookie changed to Admin=true

The user is deleted, and the lab is solved.

Congratulations, you solved the lab

What was going on?

The server was sending a cookie, and then deciding from that cookie whether the logged-in user is an admin. That is not a good practice.

A cookie is stored in the browser, on the user's own machine. Anything on that side of the trust boundary can be read and changed by the user, whether with Burp Suite, the browser's developer tools, or a script. So when the server asks the browser "are you an admin?", the browser can simply say yes.

The fix

  • Keep the role on the server. The cookie should only carry a random session ID. The server looks up who that session belongs to and what their role is in its own records, and checks that role on every request to the admin panel.
  • If a role must travel in a token, sign it and verify the signature on every request, so any change made by the user is rejected.

The server must not rely on anything the user can change to decide who is admin.

Watch the video walkthrough

https://www.youtube.com/@devsecknight

References

ResourceWhy it is useful
PortSwigger Lab: User role controlled by request parameterThe official lab used in this walkthrough.
PortSwigger: Access control vulnerabilitiesPortSwigger's guide to broken access control, including parameter-based access control methods.
OWASP Top 10: Broken Access ControlWhy broken access control is the number one web application risk.

This is a PortSwigger practice lab, built to be hacked. Only test systems you own or have written permission to test. Security audits and private pentests: click to reveal email

Related posts