/

CVE-2026-72695

Severity:

HIGH RISK

(8.1)

Path Traversal (CWE-22) in Grav Media Upload Handler

CVE-2026-72695

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Deletion

Severity:

HIGH RISK

(8.1)

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 contains a path traversal vulnerability in its media deletion logic, allowing an authenticated user with media management permissions to target files outside the intended media directory.

The issue becomes risky when attacker-controlled filenames are used to construct deletion paths without validating the complete resolved path.

Affected context

The vulnerability occurs in Grav's media management functionality, specifically the file deletion behavior implemented by MediaUploadTrait::deleteFile(). It may affect deployments where authenticated users can manage media and where filenames containing directory components are accepted before the resulting path is passed to the filesystem deletion operation.

Exploit preconditions

  • Attack surface: Authenticated media management functionality
  • Required access: A user account with permissions to manage or delete media
  • Trigger point: Processing of a user-supplied filename during file deletion
  • Why exploitation is possible: The basename is checked, but directory components may remain unvalidated and influence the final path passed to unlink()

Why this happens

The underlying bug is incomplete path validation. The application validates only part of a user-controlled filename while retaining untrusted directory components, allowing the final filesystem path to escape the intended media storage directory.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where input is used in filesystem operations without canonicalizing and constraining the complete resolved path.

Potential impact

  • Arbitrary files within the application's operating environment may be deleted
  • Application availability could be disrupted by removal of required files
  • Stored media, configuration artifacts, or user data may be lost
  • Deletion of security-relevant files could weaken monitoring or system integrity
  • The impact may be amplified by the permissions of the application process

General mitigation guidance

Mitigation generally focuses on treating filenames and paths as untrusted input and enforcing the intended storage boundary.

Common defensive patterns include:

  • Resolve candidate paths canonically and verify they remain beneath the configured media directory
  • Prefer server-generated identifiers or basenames over user-controlled path components
  • Reject directory separators and traversal components where subdirectories are not required
  • Use filesystem APIs that separate trusted directories from untrusted names
  • Apply least-privilege permissions to the application process and media storage
  • Restrict media-management privileges to users who require them
  • Maintain backups and recovery controls for important application files

How teams detect issues like this

Organizations can look for path traversal risks through:

  • Static analysis rules that flag user-controlled values passed to file deletion or file access APIs
  • Code review checks for basename-only validation, string-prefix checks, and missing canonical-path containment checks
  • Tests using normalized and non-normalized path inputs to verify storage-boundary enforcement
  • Runtime monitoring of deletion operations outside approved media directories
  • Authorization and policy checks ensuring media-management permissions are narrowly assigned

Automated security review tools may help identify filesystem operations that receive insufficiently constrained input.

Sources

SourceLink
github.comgithub.com/getgrav/grav/security/advisories/GHSA-jq29-c7v8-rg55
vulncheck.comvulncheck.com/advisories/grav-before-path-traversal-via-mediauploadtrait-deletefile

Frequently asked

questions

It can be exploitable through the application's authenticated media-management interface when that interface is reachable by an attacker who has the required privileges.

Exploitation generally requires an authenticated account with permission to manage or delete media. The practical impact also depends on the filesystem permissions of the Grav process.

Validate the complete canonical path and enforce that it remains inside the intended media directory before performing any deletion. Avoid relying only on basename checks.

Use trusted server-side file identifiers, reject unexpected path components, apply least privilege, and include filesystem-boundary tests and static analysis in the development process.

Find out what's already
exploitable in your codebase.