> For the complete documentation index, see [llms.txt](https://ganesha-hk.gitbook.io/cybersecurity-writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ganesha-hk.gitbook.io/cybersecurity-writeups/port-swigger-access-control-labs/lab-4.md).

# lab-4

## User Role Can Be Modified in User Profile

**Difficulty:** Apprentice

### Lab Description

This lab has an admin panel at `/admin`, accessible only to users with a `roleid` of `2`. The role is stored server-side but can be updated via a mass-assignment vulnerability in the profile update endpoint.

**Objective:** Access the admin panel and delete the user `carlos`.

**Credentials:** `wiener:peter`

### Solution

**Step 1 — Capture the email-change response**

Log in as `wiener:peter` and navigate to the account page. Update the email address and capture all requests in Burp Suite. Send the `POST /change-email` request to Repeater.

**Step 2 — Spot the roleid in the response**

Examine the response body from the `/change-email` endpoint. The server returns a JSON representation of the updated user object, which includes:

```json
{
  "username": "wiener",
  "email": "new@email.com",
  "roleid": 1
}
```

The `roleid` field is visible in the response. If the server reflects it back, it may also accept it as input.

**Step 3 — Inject roleid into the request**

In Repeater, add `"roleid": 2` to the JSON request body:

```json
{
  "email": "new@email.com",
  "roleid": 2
}
```

Send the request. The response confirms the update, and navigating back to the main page now shows an **Admin panel** link — the role escalation was successful.

**Step 4 — Delete carlos**

Open the admin panel and delete the user `carlos` to complete the lab.

### Conclusion

The `/change-email` endpoint accepted and applied arbitrary JSON fields from the request body without restriction — a **mass assignment** vulnerability. By injecting `roleid: 2` alongside the expected `email` field, the server silently elevated the account's privileges. Server-side endpoints should only apply updates to explicitly whitelisted fields, never blindly binding all incoming JSON properties to the user object.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ganesha-hk.gitbook.io/cybersecurity-writeups/port-swigger-access-control-labs/lab-4.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
