# CVE-2026-72697: Grav CMS media_directory() path traversal and file disclosure

Source: https://junglewise.ai/threats/cve-2026-72697-grav-cms-media-directory-path-traversal-and-file-disclosure  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-08-25. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2026-72697 · Severity: medium · CVSS 6.5 · Published 2026-08-25

Grav CMS, a popular flat-file content management system, allows page editors to use the `media_directory()` function in template code to reference directories containing media files. A vulnerability in this function fails to validate that the directory paths are restricted to intended site folders, instead accepting any filesystem path the web server process can read. Combined with insufficient sandbox restrictions on file metadata, attackers can read the content of sensitive files system-wide—including configuration, credentials, and other tenants' data on shared hosting—bypassing intended security boundaries.

Technologies: [getgrav/grav (Packagist)](https://junglewise.ai/threats/technologies/getgrav-grav). Vendors: [Packagist](https://junglewise.ai/threats/vendors/packagist).

## Quick answers

**Is CVE-2026-72697 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-72697 being exploited in the wild.

**How severe is CVE-2026-72697?** Medium severity, with a CVSS score of 6.5, published 25 August 2026.

**Which products and versions are affected?** getgrav/grav (Packagist) <= 2.0.15, ECOSYSTEM:introduced=0,fixed=2.0.16.

**Is there a fix for CVE-2026-72697?** Yes. getgrav/grav (Packagist): upgrade to 2.0.16 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-72697 attacked?** It is attacked over the network, in a web application.

**Am I affected by CVE-2026-72697?** Check whether you run getgrav/grav (Packagist) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- getgrav/grav (Packagist): upgrade to 2.0.16 or later

  ```sh
  composer require getgrav/grav:^2.0.16
  ```


## Technical details

The vulnerability is a path traversal flaw in `GravExtension::mediaDirFunc()` combined with overpermissive sandbox allow-listing. The function checks whether its input is a Grav stream (e.g., `user://`, `theme://`) and resolves it if so, but if the input is a plain filesystem path—the normal documented shape—the check is skipped and the raw path is passed directly to the `Media` class constructor without validation. The `Media` class then enumerates and indexes all files in that directory matching configured media extensions (by default: `txt`, `json`, `xml`, `pdf`, `doc`, `docx`, image formats, and others). A second gap: the `Medium` class's `filepath` accessor—which returns the absolute filesystem path to a file—is included in the Twig sandbox's allow-list despite a code comment explicitly stating it should remain blocked. An attacker with page-authoring privileges can invoke `media_directory('/etc')` or any other path, enumerate files matching media extensions, and read their contents via the `filepath` property. Affected versions include at least 2.0.15; the advisory recommends validating paths with `realpath()` and enforcing containment within an allowed root, or removing `filepath` from the sandbox allow-list.

## Affected products

- Getgrav Grav 2.0.15 and likely earlier versions

## Identifiers

- CVE-2026-72697
- GHSA-47ch-6w46-6xm7

## Timeline

- 2026-09-17: disclosed: Advisory GHSA-47ch-6w46-6xm7 published
- 2026-09-17: kev added: CVE-2026-72697 assigned

## Related threats

- [Grav cross-site scripting in Twig sandbox asset methods](https://junglewise.ai/threats/cve-2026-86197-grav-cross-site-scripting-in-twig-sandbox-asset-methods)
- [Grav Twig sandbox config exfiltration via offsetGet and dump filters](https://junglewise.ai/threats/cve-2026-61842-grav-twig-sandbox-config-exfiltration-via-offsetget-and-dump)
- [Grav ZipArchiver decompression bomb via missing extraction limits](https://junglewise.ai/threats/cve-2026-61690-grav-ziparchiver-decompression-bomb-via-missing-extraction-limits)
- [Grav incomplete Twig sandbox denylist information disclosure](https://junglewise.ai/threats/grav-incomplete-twig-sandbox-denylist-information-disclosure-e903bd3b)
- [Grav UserInterface offsetGet/offsetExists Twig sandbox bypass](https://junglewise.ai/threats/grav-userinterface-offsetget-offsetexists-twig-sandbox-bypass-f709468e)
