Post

PwnSec Shop Web Challenge Write-Up - PwnSecCTF 2024

This is a write-up for my web challenge that I wrote for PwnSec CTF 2024

PwnSec Shop

alt text

Files: pwnsec-shop.zip

After reviewing the source code of the shop, we find out that it implements an RBAC (Role Based Access Control) with roles: admin, vendor, customer, and guest, where each have specific permissions on different models such as: product, order, user, and productRequest.

alt text

A user can register as a customer or as a vendor.

alt text

A vendor can submit a new product for admins to approve.

alt text

Users can change their password in /profile

alt text

When reviewing the source code for the change password functionality we can see that it accepts any parameters sent in the request body and places them in the user entry.

alt text

This means that instead of sending password=newPassword we can send role=admin to update our role to be able to access the admin functionalities.

alt text

alt text

After logging in again we can see new pages (admin pages) on the navigation ba.

alt text

In /admin/product-photos admin can view all image files for products on the server.

alt text

By viewing one of them, we notice a parameter called file in the URL.

alt text

By checking the source code for this functionlity we can clearly see that it accepts any input from us, so maybe we can make some path traversal and read /flag.txt.

alt text

/admin/product-photos/view?file=../../../../../../../../../../flag.txt

alt text

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