CVE-2026-72695: Grav Path Traversal Vulnerability
HIGHCVE-2026-72695 is a HIGH (CVSS 8.1) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Grav libraries in the Packagist ecosystem. The issue involves path traversal in mediauploadtrait::deletefile() allows arbitrary file deletion. Remediation is available by upgrading affected packages to version 2.0.16.
CVE-2026-72695 at a Glance
Security Impact
CVSS: 8.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H).
How to Fix CVE-2026-72695
To remediate this vulnerability, upgrade all affected Grav dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade getgrav/grav to 2.0.16
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for getgrav/grav
How to Check if You Are Affected
To determine whether your application is affected by CVE-2026-72695, inspect your project dependencies for Grav:
inspect dependencies for getgrav/grav
Analyze the terminal output to locate any version of Grav in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.16), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Grav, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-72695 Affected Grav Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
getgrav/grav
|
Packagist |
< 2.0.16
|
2.0.16
|
References
Frequently Asked Questions
What is CVE-2026-72695?
Which Grav versions are affected?
What version fixes CVE-2026-72695?
Is getgrav/grav affected?
What is the CVSS score of CVE-2026-72695?
What CWE is associated with CVE-2026-72695?
How can I check Packagist dependencies for CVE-2026-72695?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-jq29-c7v8-rg55",
"modified" : "2026-09-17T20:34:05Z",
"published" : "2026-09-17T20:34:05Z",
"aliases" : [ "CVE-2026-72695" ],
"summary" : "Grav: Path Traversal in MediaUploadTrait::deleteFile() Allows Arbitrary File Deletion",
"details" : "# Path Traversal in MediaUploadTrait::deleteFile() Allows Arbitrary File Deletion\n\n## Summary\n\nA path traversal vulnerability in `MediaUploadTrait::deleteFile()` allows an authenticated user with media management permissions to delete arbitrary files on the server. The method validates only the basename portion of the filename using `Utils::checkFilename()`, while the directory path (which may contain `../` sequences) is preserved and passed unvalidated to `unlink()`. This enables directory escape from the intended media storage path.\n\n## Severity\n\n**High (8.1)** - CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H\n\n## CWE\n\nCWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')\n\n## Details\n\nIn `system/src/Grav/Common/Media/Traits/MediaUploadTrait.php`, the `deleteFile()` method (lines 332-365) performs filename validation only on the basename, not the full path:\n\n```php\npublic function deleteFile(string $filename, ?array $settings = null): void\n{\n $settings = $this->getUploadSettings($settings);\n $filesystem = Filesystem::getInstance(false);\n\n // Line 339-340: Only the BASENAME is validated\n $basename = $filesystem->basename($filename); // e.g. \"evil.jpg\" from \"../../evil.jpg\"\n if (!Utils::checkFilename($basename)) { // passes - no traversal in basename\n throw new RuntimeException(/* ... */);\n }\n\n $path = $settings['destination'] ?? $this->getPath();\n // ...\n\n // Line 353: Full pathname (with traversal) is preserved\n $pathname = $filesystem->pathname($filename); // \"../../\"\n\n // Line 356-357: Traversal path reconstructed\n [$base, $ext,,] = $this->getFileParts($basename);\n $name = \"{$pathname}{$base}.{$ext}\"; // \"../../evil.jpg\"\n\n // Line 360: Passed to doRemove()\n $this->doRemove($name, $path);\n}\n```\n\n`doRemove()` (line 521-582) then calls:\n\n```php\n// Line 538\nunlink(\"{$folder}/{$filename}\");\n// e.g. unlink(\"/var/www/grav/user/pages/mypage/../../config/system.yaml\")\n```\n\n`Utils::checkFilename()` (lines 1022-1044) properly checks for `/`, `\\`, and `..`, but it is applied to `$filesystem->basename($filename)` (the last path component only), so traversal sequences in the directory portion are never validated.\n\n### Data flow from user input\n\nThe vulnerability is reachable through the Flex media handling pipeline:\n\n1. `FlexMediaTrait::setUpdatedMedia()` (line 386) iterates form flash data where `$filename` is the array key - user-controlled\n2. For file deletions (`$file` is null, line 396), NO upload validation is performed (the `checkUploadedFile()` call at line 401 only executes when `$file` is truthy)\n3. The raw filename is stored in `$this->_uploads` at line 414\n4. `saveUpdatedMedia()` (line 499) calls `$media->deleteFile($filename, $settings)` with the unsanitized filename\n\n### Sibling: renameFile()\n\nThe same pattern exists in `renameFile()` (lines 374-405) which has even weaker validation - it performs NO `checkFilename()` call at all. While `renameFile()` currently has no callers in the core codebase, it is part of the public `MediaUploadInterface` and should be fixed as defense-in-depth.\n\n## Proof of Concept\n\n**Environment**: Grav CMS 2.0.16 with admin plugin\n\nThe attack requires an authenticated admin user with page/media editing permissions (not super-admin).\n\n1. Create a target file:\n```bash\necho \"DELETE_ME\" > /var/www/grav/user/data/target.txt\n```\n\n2. Submit a Flex object form (e.g. page edit) with a crafted media deletion where the filename key contains path traversal:\n\n```\nPOST /admin/pages/mypage/task:save\nContent-Type: multipart/form-data\n\n# The form flash data includes a media deletion entry with key:\n# \"../../data/target.txt\" -> null (deletion marker)\n```\n\n3. When `saveUpdatedMedia()` processes the deletion queue:\n - `$filename` = `../../data/target.txt`\n - `deleteFile(\"../../data/target.txt\")` is called\n - `$basename` = `target.txt` (passes `checkFilename()`)\n - `$pathname` = `../../data/`\n - `$name` = `../../data/target.txt`\n - `doRemove()` calls `unlink(\"/var/www/grav/user/pages/mypage/../../data/target.txt\")`\n - Which resolves to `unlink(\"/var/www/grav/user/data/target.txt\")`\n\n4. The file is deleted outside the intended media directory.\n\n### Impact\n\nAn authenticated user with media management permissions can:\n- Delete configuration files (`user/config/system.yaml`, `user/config/security.yaml`)\n- Delete other pages' content files\n- Delete authentication-related files (user account YAML files)\n- Cause denial of service by removing critical application files\n- Potentially escalate privileges by removing security configuration\n\n## Suggested Fix\n\nApply `Utils::checkFilename()` to the full `$filename` parameter before decomposing it, or reject any filename containing directory separators or `..` sequences:\n\n```php\npublic function deleteFile(string $filename, ?array $settings = null): void\n{\n $settings = $this->getUploadSettings($settings);\n $filesystem = Filesystem::getInstance(false);\n\n // Validate the FULL filename, not just the basename\n if (!Utils::checkFilename($filename)) {\n throw new RuntimeException(/* ... */);\n }\n\n // ... rest unchanged\n}\n```\n\nThe same fix should be applied to `renameFile()` for both `$from` and `$to` parameters.\n\n## References\n\n- Vulnerable file: `system/src/Grav/Common/Media/Traits/MediaUploadTrait.php` lines 332-365, 521-582\n- Caller: `system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php` lines 386-414, 490-499\n- Sibling: `system/src/Grav/Common/Media/Traits/MediaUploadTrait.php` lines 374-405 (renameFile)\n- Related GHSA: GHSA-g6j3-8jv9-ch5f (path traversal in PagesController::batchCopy - different file, same bug class)\n\n## Disclosure\n\nThis vulnerability was discovered using AI-assisted security research tools.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "getgrav/grav"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.0.16"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 2.0.15"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/getgrav/grav/security/advisories/GHSA-jq29-c7v8-rg55"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-72695"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/getgrav/grav"
}, {
"type" : "WEB",
"url" : "https://www.vulncheck.com/advisories/grav-before-path-traversal-via-mediauploadtrait-deletefile"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-09-17T20:34:05Z",
"nvd_published_at" : null
}
}