Summary
Grav 2.0.0-beta.2 allows a low-privileged authenticated API user with api.media.write to upload arbitrary YAML files into user/accounts/ via the /api/v1/blueprint-upload endpoint.
By crafting a YAML file that defines a new user with api.super privileges, an attacker can then log in as this account and gain full administrative control over the Grav API.
Affected context
This vulnerability occurs in Grav installations using the affected API version where:
- The
/api/v1/blueprint-uploadendpoint is exposed and enabled. - User accounts are file-based and stored as YAML files under
user/accounts/. - Low-privileged API users can obtain the
api.media.writepermission, typically for uploading media or blueprints.
In such configurations, the boundary between content uploads and account configuration is not sufficiently enforced, allowing account YAML creation where only media uploads were intended.
Exploit preconditions
- Attack surface: Authenticated HTTP access to the Grav API, specifically the
/api/v1/blueprint-uploadendpoint. - Required access:
- Valid API authentication as a low-privileged user.
- Permission
api.media.write(or equivalent rights that allow blueprint uploads). - Trigger point:
- Sending a crafted upload request to
/api/v1/blueprint-uploadthat causes an arbitrary YAML file to be written underuser/accounts/. - The attacker then authenticates using the newly created account defined in that YAML file.
- Why exploitation is possible:
- The upload endpoint does not sufficiently constrain the destination path or type of files being written.
- The application trusts any appropriately structured YAML placed under
user/accounts/as a valid user definition, including privilege flags such asapi.super.
Why this happens
The underlying bug is a combination of improper authorization and unrestricted file write to a sensitive configuration directory.
The blueprint-upload functionality is designed for lower-risk content (e.g., blueprints or media), but the implementation allows a user with api.media.write to:
- Influence the target location of uploaded YAML files, and
- Store them in
user/accounts/, a directory used for defining user identities and roles.
Because Grav treats YAML files in user/accounts/ as authoritative account definitions, including role and privilege settings, the system effectively allows low-privileged users to define new high-privileged accounts.
This maps primarily to CWE-269: Improper Privilege Management, as privilege boundaries between content uploaders and account administrators are not enforced, and secondarily to CWE-434: Unrestricted Upload of File with Dangerous Type, since a user can upload configuration-bearing YAML into a sensitive location.
Potential impact
- Creation of arbitrary administrative (
api.super) accounts. - Full control over the Grav API, including configuration changes and endpoint management.
- Access to sensitive data exposed through API capabilities.
- Modification or deletion of content and user accounts.
- Use of administrative access to pivot into other integrated systems or services relying on the Grav API.
General mitigation guidance
Effective mitigation centers on tightening authorization and isolating configuration from user-controlled uploads:
- Ensure upload endpoints can only write into strictly controlled, non-executable, non-configuration directories dedicated to media or blueprints.
- Enforce explicit server-side mapping of upload targets (e.g., predefined directories) instead of trusting client-provided paths or names for any security-sensitive locations.
- Introduce a clear separation between content files and identity/privilege configuration files; prevent any user-controlled data from ending up under
user/accounts/or equivalent account stores. - Add permission tiers so that capabilities related to user or role management are separated from content upload permissions, avoiding overlaps between
api.media.writeand account management. - Apply least-privilege principles to all API permissions and review which roles can access blueprint or configuration-related upload functionality.
- Consider using an internal representation or database-backed store for accounts, rather than plain files that can be created or overwritten by upload features.
How teams detect issues like this
Detection can focus on configuration-sensitive writes, permission misuse, and anomalous account creation:
- Static analysis & code review:
- Search for upload or file-write endpoints that accept paths or filenames influenced by users.
- Flag any logic that writes to account or configuration directories based on low-privilege actions such as media upload.
- Review permission checks to ensure that content-related scopes (e.g., media write) cannot indirectly affect user or role definitions.
- Runtime monitoring & logging:
- Log all writes to
user/accounts/(or equivalent account storage) and alert on events triggered by non-administrative principals. - Monitor for new accounts or role changes initiated via API paths associated with media or blueprint uploads.
- Track successful logins for newly created accounts and correlate them with preceding upload actions.
- Policy enforcement:
- Use web application firewalls or API gateways to restrict access to sensitive endpoints and enforce method and path-based controls.
- Apply configuration management policies that treat account directories as immutable at runtime, except through vetted administrative workflows.
- Automated security testing tools and CI-integrated scanners can help highlight insecure file upload destinations and authorization gaps during development.

