Description
Registration and profile-update requests can let users set their own privileges if the application saves fields such as Role, IsAdmin or IsPrivileged.
Potential impact
An ordinary user may gain access to administrative functions or sensitive data.
Remediation
Leave permission fields out of public request models and assign the initial role on the server. Handle role changes separately and verify that the administrator may grant the requested role.
Examples
Before
csharp
var user = new User
{
Email = request.Email,
Role = request.Role ?? "User"
};
After
csharp
var user = new User
{
Email = request.Email,
Role = "User"
};
The first assignment uses "User" only when request.Role is null. The second takes the email from the request and always assigns "User".