Summary
Grav API Plugin contains an authorization flaw in user-management operations that can allow a lower-privileged account with user-write access to create or manipulate credentials associated with a super-administrator target.
Because API key scopes are not adequately enforced and required super-user checks are omitted, successful exploitation may provide persistent administrator access and allow two-factor authentication changes.
Affected context
The issue occurs in Grav API Plugin deployments where a non-super account has the api.users.write permission and can reach the API endpoints responsible for API key and two-factor authentication management. Risk is present when target authorization checks are incomplete and generated API keys are not constrained to the privileges intended for the requesting account.
Exploit preconditions
- Attack surface: Grav API Plugin user-management endpoints
- Required access: An authenticated account with
api.users.write - Trigger point: API key creation or two-factor authentication management for a privileged user target
- Why exploitation is possible: The affected operations omit the super-user target authorization check, while API key permission scopes are not enforced consistently
Why this happens
The underlying flaw is an authorization enforcement gap in sensitive user mutation operations. The affected methods do not apply the same accessGrantsSuper() target check used by related endpoints, allowing a lower-privileged account to act on a super-administrator target.
This maps primarily to CWE-639: Authorization Bypass Through User-Controlled Key, because target identity and privilege context are not sufficiently restricted. It also relates to CWE-862: Missing Authorization, as the required authorization decision is absent from specific mutation paths.
Potential impact
- An attacker may create an API key associated with super-administrator privileges
- The attacker could obtain persistent privileged access to Grav
- Two-factor authentication for a privileged account could be rotated or disabled
- Site content, configuration, and user accounts could be modified
- A compromised account could support further administrative or operational abuse
General mitigation guidance
Mitigation generally focuses on enforcing authorization consistently across every sensitive user-management operation.
Common defensive patterns include:
- Apply explicit target-level authorization checks to API key and two-factor authentication mutations
- Enforce API key scopes and privilege boundaries at both creation time and request time
- Prevent lower-privileged users from selecting or modifying higher-privileged targets
- Use centralized authorization policies rather than endpoint-specific assumptions
- Require reauthentication or additional approval for privileged credential changes
- Apply least privilege to API accounts and administrative roles
- Review existing keys and two-factor authentication settings for unexpected privileged changes
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules that compare authorization checks across sibling user mutation endpoints
- Code review searches for credential, API key, and MFA operations lacking target-level permission checks
- Tests verifying that lower-privileged accounts cannot mutate super-administrator targets
- Policy enforcement requiring API key scopes to be validated during both issuance and use
- Audit logging and alerting for privileged API key creation, scope changes, and two-factor authentication resets
- Automated security review tools that identify missing authorization branches and inconsistent access-control enforcement

