Home Broken Access Control
Post
Cancel

Broken Access Control

Intro

This post/writeup is all about the Broken access control.

I’ll be using primarily Portswigger Web Academy Labs, but i do intent do throw other labs and writeups here as well.

Information disclosure is all about disclosing information that was not intended to be exposed to user, like debug page for example or leaks data that is intended for privileged or other users.

TOC

Theory

Access control (or authorization) is the application of constraints on who (or what) can perform attempted actions or access resources that they have requested. In the context of web applications, access control is dependent on authentication and session management:

  • Authentication identifies the user and confirms that they are who they say they are.
  • Session management identifies which subsequent HTTP requests are being made by that same user.
  • Access control determines whether the user is allowed to carry out the action that they are attempting to perform.

Unprotected admin functionality

This lab has an unprotected admin panel.

Solve the lab by deleting the user carlos.

If we check the Site map we can find /administrator-panel which is present in robots.txt

picture 1

We can simply open the panel and delete the carlos and solve the lab

picture 2

Unprotected admin functionality with unpredictable URL

This lab has an unprotected admin panel. It’s located at an unpredictable location, but the location is disclosed somewhere in the application.

Solve the lab by accessing the admin panel, and using it to delete the user carlos

This lab is very similar to the previous one, we however need to check the source to find the Admin panel.

picture 4

When we access the Admin panel, we just have to delete carlos user to solve the lab.

picture 5

Alternatively we could have a look in LinkFinder.

User role controlled by request parameter

This lab has an admin panel at /admin, which identifies administrators using a forgeable cookie.

Solve the lab by accessing the admin panel and using it to delete the user carlos.

You can log in to your own account using the following credentials: wiener:peter

Let’s login using provided credentials wiener:carlos:

picture 6

If we check the request we can notice that administrator’s role is being controlled by cookie.

picture 7

We can change that cookie in the browser directly, or use Match and replace

picture 8

Either way, go to Admin panel and delete carlos when done to solve the lab

picture 9

User role can be modified in user profile

This lab has an admin panel at /admin. It’s only accessible to logged-in users with a roleid of 2.

Solve the lab by accessing the admin panel and using it to delete the user carlos.

You can log in to your own account using the following credentials: wiener:peter

First we have to login using provided credentials wiener:peter. If we make a change to profile - we can change Email address, we would notice roleid parameter in the request

picture 10

We can modify that parameter:

picture 11

We can then go ahead and solve the lab by deleting carlos from Admin panel

picture 12

URL-based access control can be circumvented

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.

Upon starting the lab, let us go to Admin panel:

picture 13

Disclaimer: We get "Access denied".

Now at this point it was not clear to me what to do, as if i just go and add X-Original-URL header, we still end up with Access denied and cannot tell that Header is being used.

If we do that in root however / and place invalid header like /invalid (taken from Solution!), we get 404 Not Found just because of X-Original-URL header.

Changing X-Original-URL value to /admin, leads us unauthenticated (!) directly to the Admin panel.

picture 14

We now have to change the GET request to /?username=carlos and modify the header X-Original-URL: /admin/delete

picture 15

PS: Match and replace did not really work as then CSS,JS wasn’t loaded etc.

Method-based access control can be circumvented

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.

As we were given this possibility we can login using provided administrator:admin credentials and promote administrator to admin again and check the request in burp to see what’s actualy going on.

picture 16

We cannot do it, but we’ve captured the request!

picture 17

Now login as wiener:peter and send a request to /admin-roles:

picture 18

Unauthorized. How about GET request?

picture 19

Now we see the message that username parameter is missing.

Can we upgrade ourselves (wiener = normal user) to administrator?

picture 20

Sure we do & another lab has been solved!

User ID controlled by request parameter

This lab has a horizontal privilege escalation vulnerability on the user account page.

To solve the lab, obtain the API key for the user carlos and submit it as the solution.

You can log in to your own account using the following credentials: wiener:peter

When we login we get an API key assigned!

picture 21

If we click on My account again, another request would be issued

picture 22

We can request for API from carlos

picture 23

Submit the API Key and solve the lab!

User ID controlled by request parameter, with unpredictable user IDs

This lab has a horizontal privilege escalation vulnerability on the user account page, but identifies users with GUIDs.

To solve the lab, find the GUID for carlos, then submit his API key as the solution.

You can log in to your own account using the following credentials: wiener:peter

If we login using wiener:peter credentials that were provided by us and check the My account link, we’ll see that it’s pointing to GUID from wiener.

picture 24

We would now need to find the place where we could display the GUID of carlos!

We can see that carlos has dropped few posts:

picture 25

If we check the source we’d find the carlos’s GUID

1
<a href='/blogs?userId=a6e6c070-4117-4627-af43-e299301ae904'>carlos</a></span> | 12 September 2022</p>

We can use it to display the API key:

picture 26

User ID controlled by request parameter with data leakage in redirect

This lab contains an access control vulnerability where sensitive information is leaked in the body of a redirect response.

To solve the lab, obtain the API key for the user carlos and submit it as the solution.

You can log in to your own account using the following credentials: wiener:peter

Let’s login using provided credentials wiener:peter

picture 27

If we again click on My account the id should be set.

picture 28

Now let’s swap it with carlos and check the Burp.

We can notice the 302 redirect however page will still load and disclose the API of carlos’s

picture 29

Submit the API key and solve the lab!

User ID controlled by request parameter with password disclosure

This lab has user account page that contains the current user’s existing password, prefilled in a masked input.

To solve the lab, retrieve the administrator’s password, then use it to delete carlos.

You can log in to your own account using the following credentials: wiener:peter

Let’s login using provided credentials wiener:peter. If we click on My account we would notice that password get’s loaded to the frontend which is weird.

picture 30

Now, we can also achieve that for administrator.

picture 31

In order to solve the lab, we need to login using password found and login as administrator and delete carlos.

picture 32

Insecure direct object references

This lab stores user chat logs directly on the server’s file system, and retrieves them using static URLs.

Solve the lab by finding the password for the user carlos, and logging into their account.

We can make use of live chat in this lab.

picture 33

Live chat has Download transcript option and if we use it, we can see our chat history.

picture 34

What happens if we swap the id of 2 with 1?

picture 35

Yeah, we can see the chat that belongs to other user along with the carloss password which we can use to login and solve the lab.

Multi-step process with no access control on one step

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.

Let’s login using administrator:admin that was provided to us.

User Promotion is done in 2 steps:

FIRST REQUEST picture 36

POST Request

1
2
3
4
5
6
7
POST /admin-roles HTTP/1.1
Host: 0afd004904aed73fc06eab33000b00a8.web-security-academy.net
Cookie: session=0C1CqV6e1kBdfkaON0eKHjwamc4GDKrO
...
Connection: close

username=administrator&action=upgrade

SECOND REQUEST picture 37

POST Request

1
2
3
4
5
6
7
POST /admin-roles HTTP/1.1
Host: 0afd004904aed73fc06eab33000b00a8.web-security-academy.net
Cookie: session=0C1CqV6e1kBdfkaON0eKHjwamc4GDKrO
...
Connection: close

action=upgrade&confirmed=true&username=administrator

Now let’s try replay same requests using wiener user.

Replaying first request ends with 401 Unauthorized:

picture 38

Replaying second request seems to work! :)

picture 39

To solve the lab, simply promote wiener like seen in the screenshot above.

Referer-based access control

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.

Let’s login using provided administrator:admin and try to promote carlos user.

picture 40

Send the query above to Burp Repeater

Let’s login usingwiener:peter and try to use the wiener’s session. It will work if Referer header is set to hostname/admin.

picture 42

Lab has been solved.

picture 41

This post is licensed under CC BY 4.0 by the author.