GHSA-cv2g-8cj8-vgc7 — phpmyfaq/phpmyfaq
MEDIUMGHSA-cv2g-8cj8-vgc7 is a medium-severity (CVSS 6.1) 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 Regex Bypass in Filter::removeAttributes()
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.
How urgent is this, really
GHSA-cv2g-8cj8-vgc7 plotted by exploitation likelihood (EPSS) against impact (CVSS). The shaded corner — EPSS 50%+ and CVSS 7.0+ — is where this CVE doesn't sit, though severity or exploitability alone can still warrant action.
Where this sits among everything scored
Of 377,166 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Real counts from FIRST.org, not a sample — log-scaled since the landscape is heavily right-skewed.
Real-World Exposure
phpmyfaq/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 sanitization pipeline for FAQ content is:
Filter::filterVar($input, FILTER_SANITIZE_SPECIAL_CHARS)— encodes<,>,",',&to HTML entitieshtml_entity_decode($input, ENT_QUOTES | ENT_HTML5)— decodes entities back to charactersFilter::removeAttributes($input)— removes dangerous HTML attributes
The removeAttributes() regex at line 174 only matches attributes with double-quoted values:
preg_match_all(pattern: '/[a-z]+=".+"/iU', subject: $html, matches: $attributes);
This regex does NOT match:
- Attributes with single quotes:
onerror='alert(1)' - Attributes without quotes:
onerror=alert(1)
An attacker can bypass sanitization by submitting FAQ content with unquoted or single-quoted event handler attributes.
Details
Affected File: phpmyfaq/src/phpMyFAQ/Filter.php, line 174
Sanitization flow for FAQ question field:
FaqController::create() lines 110, 145-149:
$question = Filter::filterVar($data->question, FILTER_SANITIZE_SPECIAL_CHARS);
// ...
->setQuestion(Filter::removeAttributes(html_entity_decode(
(string) $question,
ENT_QUOTES | ENT_HTML5,
encoding: 'UTF-8',
)))
Template rendering: faq.twig line 36:
<h2 class="mb-4 border-bottom">{{ question | raw }}</h2>
How the bypass works:
- Attacker submits:
<img src=x onerror=alert(1)> - After
FILTER_SANITIZE_SPECIAL_CHARS:<img src=x onerror=alert(1)> - After
html_entity_decode():<img src=x onerror=alert(1)> preg_match_all('/[a-z]+=".+"/iU', ...)runs:- The regex requires
="..."(double quotes) onerror=alert(1)has NO quotes → NOT matchedsrc=xhas NO quotes → NOT matched- No attributes are found for removal
- The regex requires
- Output:
<img src=x onerror=alert(1)>(XSS payload intact) - Template renders with
|raw: JavaScript executes in browser
Why double-quoted attributes are (partially) protected:
For <img src="x" onerror="alert(1)">:
- The regex matches both
src="x"andonerror="alert(1)" srcis in$keep→ preservedonerroris NOT in$keep→ removed viastr_replace()- Output:
<img src="x">(safe)
But this protection breaks with single quotes or no quotes.
PoC
Step 1: Create FAQ with XSS payload (requires authenticated admin):
curl -X POST 'https://target.example.com/admin/api/faq/create' \
-H 'Content-Type: application/json' \
-H 'Cookie: PHPSESSID=admin_session' \
-d '{
"data": {
"pmf-csrf-token": "valid_csrf_token",
"question": "<img src=x onerror=alert(document.cookie)>",
"answer": "Test answer",
"lang": "en",
"categories[]": 1,
"active": "yes",
"tags": "test",
"keywords": "test",
"author": "test",
"email": "[email protected]"
}
}'
Step 2: XSS triggers on public FAQ page
Any user (including unauthenticated visitors) viewing the FAQ page triggers the XSS:
https://target.example.com/content/{categoryId}/{faqId}/{lang}/{slug}.html
The FAQ title is rendered with |raw in faq.twig line 36 without HtmlSanitizer processing (the processQuestion() method in FaqDisplayService only applies search highlighting, not cleanUpContent()).
Alternative payloads:
<img/src=x onerror=alert(1)>
<svg onload=alert(1)>
<details open ontoggle=alert(1)>
Impact
- Public XSS: The XSS executes for ALL users viewing the FAQ page, not just admins.
- Session hijacking: Steal session cookies of all users viewing the FAQ.
- Phishing: Display fake login forms to steal credentials.
- Worm propagation: Self-replicating XSS that creates new FAQs with the same payload.
- Malware distribution: Redirect users to malicious sites.
Note: While planting the payload requires admin access, the XSS executes for all visitors (public-facing). This is not self-XSS.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐘Packagist | phpmyfaq/phpmyfaq | all versions | 4.1.1composer require phpmyfaq/phpmyfaq:^4.1.1 |
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.1 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-cv2g-8cj8-vgc7 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 GHSA-cv2g-8cj8-vgc7 can be triaged on real exposure rather than presence alone.
Tailored to GHSA-cv2g-8cj8-vgc7. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is GHSA-cv2g-8cj8-vgc7 in your dependencies?
O3 Security finds GHSA-cv2g-8cj8-vgc7 across Packagist dependencies, including transitive ones, and its impact-aware SCA ranks findings by whether your code actually calls the vulnerable path.