Summary
Grav's API plugin does not enforce API key scope limits on the non-self user path of the 2FA disable endpoint. A qualifying API key holder may disable two-factor authentication for another non-super account without supplying a TOTP code, potentially enabling account takeover.
Affected context
The issue occurs in Grav deployments using the API plugin's user management endpoint for disabling two-factor authentication. It becomes risky when an API key is associated with a super account or an account whose ACL grants user-write access, while the endpoint fails to apply the key's configured scope cap to operations against other users.
Exploit preconditions
- Attack surface: Authenticated HTTP API access to the user 2FA management endpoint - Required access: A valid API key associated with a qualifying account and sufficient ACL context - Trigger point: A POST request to the non-self user 2FA disable operation - Why exploitation is possible: The endpoint checks selected ACL conditions but does not invoke the permission enforcement path that applies API key scope restrictions, and it does not require a TOTP code for the targeted account
Why this happens
The endpoint implements authorization inconsistently with its sibling operation. Instead of invoking the centralized permission check that enforces API key scope caps, the non-self path relies on direct ACL reads such as super-administrator or user-write checks. This leaves a critical account-security function accessible under broader conditions than intended and maps to CWE-306, Missing Authentication for Critical Function.
Potential impact
- An attacker may disable two-factor authentication for another user account.
- Affected users could lose an important account-protection control.
- An attacker could use subsequent credential access to take over an account.
- Administrative or user data may be exposed or modified after account compromise.
General mitigation guidance
Mitigation generally focuses on making authorization checks centralized, complete, and fail-closed for every account-management operation. The endpoint should consistently enforce API key scope caps, require operation-specific permissions for the target account, and preserve step-up verification where disabling 2FA is a sensitive action. API keys should use the narrowest practical privileges, and account-management functions should avoid relying on broad role or ACL checks alone.
How teams detect issues like this
Detection can include static analysis and code review rules that compare sibling endpoint authorization paths, identify sensitive handlers that bypass centralized permission functions, and flag direct ACL checks without scope enforcement. Runtime monitoring can alert on 2FA-disable operations performed through API keys, especially when the requester and target differ or when the key has a narrow scope. Policy checks can require step-up verification and explicit target-resource authorization for account-security changes.

