/

CVE-2026-42844

Severity:

HIGH RISK

(8.8)

Privilege Escalation / Authorization Bypass in Grav API

CVE-2026-42844

Analyzed

Vulnerability type

Category:

Privilege Escalation / Authorization Bypass

CWE:

CWE-269, CWE-434

Impact:

Full Administrative Compromise of the Grav API

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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-upload endpoint 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.write permission, 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-upload endpoint.
  • 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-upload that causes an arbitrary YAML file to be written under user/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 as api.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.write and 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.

Sources

SourceLink
github.comgithub.com/getgrav/grav/security/advisories/GHSA-6xx2-m8wv-756h

Frequently asked

questions

Yes, if the Grav API is exposed over the network and a remote attacker can obtain valid low-privilege API credentials with api.media.write, they can exploit the issue without local server access.

The attacker must be an authenticated API user with at least the api.media.write permission (or any equivalent permission that grants access to /api/v1/blueprint-upload). No pre-existing administrative rights are required.

The safest approach is to strictly separate uploadable content from configuration and account data. Upload endpoints should write only to predefined, non-sensitive directories, and any paths or filenames derived from user input must be normalized and constrained. Additionally, permissions that handle identity and role management should be isolated from content-related permissions.

To prevent similar issues:

  • Design privilege models so that content upload permissions cannot influence user accounts, roles, or configuration.
  • Treat account and configuration stores as sensitive and immutable from general-purpose upload or content APIs.
  • Incorporate security-focused code review and automated checks to flag file writes into sensitive directories and to verify that authorization logic aligns with the intended privilege boundaries.
  • Regularly test APIs with security-focused integration tests targeting upload endpoints and access control rules.
Find out what's already
exploitable in your codebase.