Summary
Grav CMS's API plugin contains an authorization logic flaw that lets any user with basic API access modify their own permission configuration via the UsersController update endpoint.
By tampering with their user record, an attacker can escalate privileges to Super Administrator (admin.super and api.super), potentially gaining full system control and reaching remote code execution through existing admin capabilities.
Affected context
This vulnerability affects Grav CMS sites that:
- Use the Grav API plugin with versions prior to 1.0.0-beta.15
- Expose the REST API, granting users the
api.accesspermission - Rely on the API to manage user information and permissions
The risky behavior occurs when the UsersController::update endpoint processes user updates without correctly constraining which fields can be changed or revalidating authorization for permission changes.
Exploit preconditions
- Attack surface: Grav API HTTP endpoints, specifically the user update route handled by
UsersController::update. - Required access: Valid Grav account with basic API access (
api.access). No elevated roles are needed initially. - Trigger point: Sending an API request to update the authenticated user's account, including permission fields such as
admin.superorapi.super. - Why exploitation is possible: The controller trusts the incoming data for the caller's user record, lacks robust field-level authorization checks, and does not properly enforce that only privileged actors may change privilege-bearing fields.
Why this happens
The core issue is an authorization logic flaw where the API endpoint responsible for updating user accounts does not enforce strict checks on which attributes may be modified by which roles.
Instead of:
- Treating permission fields as sensitive and immutable for non-admin users, and
- Performing a separate privilege check for permission changes,
the UsersController::update operation allows a user with basic api.access to submit an update that alters their own permission configuration.
This behavior maps to CWE-863: Incorrect Authorization, as authorization is either missing or misapplied at the point where sensitive operations—changing role and capability assignments—are executed. The design implicitly couples "may update your profile" with "may update any field of your user object," enabling privilege escalation.
Potential impact
- Attacker can escalate their account to Super Administrator (
admin.super). - Attacker can gain API super access (
api.super) and manage system state programmatically. - Full access to Grav CMS administrative capabilities, including user management, configuration, plugins, and site content.
- Potential remote code execution via existing admin functions, such as installing or editing plugins/themes and altering configuration.
- Complete compromise of the Grav instance, with knock-on impact to data integrity, confidentiality, and availability.
General mitigation guidance
Secure remediation centers on strong, explicit authorization checks for sensitive fields and operations:
- Treat role, group, and permission fields as privileged attributes that only highly trusted roles (e.g., existing Super Administrators) can modify.
- Implement field-level authorization logic: even if a user is allowed to update their profile, they should not be able to alter their own permissions, roles, or groups.
- Enforce a server-side whitelist of updatable fields for non-privileged users, excluding any access control–related attributes.
- Apply defense-in-depth by validating that the actor's current privileges are strictly higher than the effective privileges of the target account whenever permissions are changed.
- Limit the breadth of default API capabilities: ensure that
api.accessdoes not implicitly include access to powerful administrative actions. - Run the application with least privilege at the system level so that even if admin privileges are abused, the operating system and surrounding environment provide additional containment.
How teams detect issues like this
Detection and assurance can focus on both code and runtime behavior:
- Static analysis / code scanning:
- Search for controllers or handlers that update user records or permission-related fields without explicit role checks.
- Flag patterns where incoming request bodies are mapped directly to user models, particularly when permission fields are not filtered.
- Identify endpoints where authorization relies only on "is authenticated" or generic capabilities rather than granular permission checks.
- Code review practices:
- Require security review for any changes to authentication, authorization, or user management code paths.
- Verify that every endpoint that can modify roles, groups, or permissions contains clear and explicit authorization rules.
- Look for "update your own profile" or "self-service" endpoints and confirm that access-control fields are immutable for regular users.
- Runtime and log monitoring:
- Monitor for unexpected assignment of high-privilege flags (e.g.,
admin.super,api.super) to previously low-privilege accounts. - Alert on sudden changes in permission sets performed via the API rather than through the expected administrative UI.
- Policy and tooling:
- Use automated security testing tools or CI-integrated policy checks to enforce that no route allows unvetted updates to permission-bearing fields.

