- Invoice System in Laravel: 1.0
- Vulnerability Type: Broken Access Control + Privilege Escalation
- Severity: CRITICAL
- Status: Unpatched
/user(POST/PUT methods)
The user management flow is exposed without effective authorization controls. The user resource routes can be reached without admin-only middleware, and the controller accepts attacker-controlled role data. This allows any user to create or modify accounts with administrative privileges.
Below is a POST request demonstrating arbitrary role assignment during user creation:
POST /user HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
name=attacker&email=attacker@example.com&password=Password123&role=admin
This payload injects the administrative role:
role=adminThe application lacks server-side enforcement to prevent non-admin users from setting the role field, leading to full privilege escalation.
- Privilege Escalation: Attackers can elevate their own accounts to administrator status.
- Account Takeover: Modification of existing users with elevated permissions.
- Access Control: Unauthorized access to all administrative functions.
- Enforce Authorization: Protect all
/userroutes with admin-only middleware. - Restrict Input: Remove
rolefrom the$fillablearray or validate it against a trusted whitelist. - Use Policies: Implement Laravel Policies to authorize user creation and updates.