# Grav: media_directory() Twig function allows filesystem path traversal and file content disclosure from sandboxed page content

High severity, published 2026-09-17. Update getgrav/grav to 2.0.16 or later: composer update getgrav/grav.

Canonical URL: https://buzzphp.com/security/ghsa-47ch-6w46-6xm7 · Data from GitHub as of 2026-11-25.

| | |
| --- | --- |
| Severity | high (CVSS 6.5) |
| Published | 2026-09-17 |
| Updated | 2026-09-17 |
| CVE | [CVE-2026-72697](https://nvd.nist.gov/vuln/detail/CVE-2026-72697) |
| GHSA | [GHSA-47ch-6w46-6xm7](https://github.com/advisories/GHSA-47ch-6w46-6xm7) |
| Weakness | CWE-22 |

| Package | Affected versions | Fixed in |
| --- | --- | --- |
| getgrav/grav | <= 2.0.15 | 2.0.16 |

## What to do

Update getgrav/grav to 2.0.16 or later: composer update getgrav/grav.

Check which version you run with `composer show getgrav/grav`, and every affected package with `composer audit`.

## About this advisory

Summary

The mediadirectory() Twig function is allow-listed for use in sandboxed, editor-authored page content (system/config/security.yaml). Its implementation, GravExtension::mediaDirFunc(), only treats the input as unsafe when it looks like a Grav stream (user://, theme://, etc). If the input is instead a plain filesystem path, absolute or relative, the stream check is skipped entirely and the raw string is handed straight to new Media($mediadir), which lists every file in that directory whose extension matches a configured media type (which by default includes txt, json, xml, pdf, doc, docx, and more, not just images) and builds Medium objects for them.



## Links

- [GHSA-47ch-6w46-6xm7 on GitHub](https://github.com/advisories/GHSA-47ch-6w46-6xm7)
- [CVE-2026-72697 on the National Vulnerability Database](https://nvd.nist.gov/vuln/detail/CVE-2026-72697)
- [All Composer security advisories](https://buzzphp.com/security)
