GHSA-gcp9-5jc8-976x
MEDIUMGHSA-gcp9-5jc8-976x is a medium-severity (CVSS 5.3) CWE-943 vulnerability in thorsten/phpmyfaq. O3 Security confirms whether GHSA-gcp9-5jc8-976x is actually reachable in your code before you act, and blocks exploitation at runtime until you patch.
phpMyFAQ has a LIKE Wildcard Injection in Search.php — Unescaped % and _ Metacharacters Enable Broad Content Disclosure
Real-World Exposure
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 searchCustomPages() method in phpmyfaq/src/phpMyFAQ/Search.php uses real_escape_string() (via escape()) to sanitize the search term before embedding it in LIKE clauses. However, real_escape_string() does not escape SQL LIKE metacharacters % (match any sequence) and _ (match any single character). An unauthenticated attacker can inject these wildcards into search queries, causing them to match unintended records — including content that was not meant to be surfaced — resulting in information disclosure.
Details
File: phpmyfaq/src/phpMyFAQ/Search.php, lines 226–240
Vulnerable code:
$escapedSearchTerm = $this->configuration->getDb()->escape($searchTerm);
$searchWords = explode(' ', $escapedSearchTerm);
$searchConditions = [];
foreach ($searchWords as $word) {
if (strlen($word) <= 2) {
continue;
}
$searchConditions[] = sprintf(
"(page_title LIKE '%%%s%%' OR content LIKE '%%%s%%')",
$word,
$word
);
}
escape() calls mysqli::real_escape_string(), which escapes characters like ', \, NULL, etc. — but explicitly does not escape % or _, as these are not SQL string delimiters. They are, however, LIKE pattern wildcards.
Attack vector:
A user submits a search term containing _ or % as part of a 3+ character word (to bypass the strlen <= 2 filter). Examples:
- Search for
a_b→ LIKE becomes'%a_b%'→_matches any single character, e.g. matches"aXb","a1b","azb"— broader than the literal stringa_b - Search for
te%t→ LIKE becomes'%te%t%'→ matchestest,text,te12t, etc. - Search for
_%_→ LIKE becomes'%_%_%'→ matches any record with at least one character, effectively dumping all custom pages
This allows an attacker to retrieve custom page content that would not appear in normal exact searches, bypassing intended search scope restrictions.
PoC
- Navigate to the phpMyFAQ search page (accessible to unauthenticated users by default).
- Submit a search query:
_%_(underscore, percent, underscore — length 3, bypasses the<= 2filter). - The backend executes:
WHERE (page_title LIKE '%_%_%' OR content LIKE '%_%_%') - This matches all custom pages with at least one character in title or content — returning content that would not appear for a specific search term.
Impact
- Authentication required: None — search is publicly accessible
- Affected component:
searchCustomPages()inSearch.php; custom pages (faqcustompages table) - Impact: Unauthenticated users can enumerate/disclose all custom page content regardless of the intended search term filter
- Fix: Escape
%and_in LIKE search terms before interpolation:
Or use parameterized queries with properly escaped LIKE values.$word = str_replace(['\\', '%', '_'], ['\\\\', '\\%', '\\_'], $word);
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐘Packagist | thorsten/phpmyfaq | all versions | 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 thorsten/phpmyfaq. O3's reachability analysis confirms whether the vulnerable code path is actually invoked in your application, so you act on real exposure instead of every transitive match.
Fix
Update thorsten/phpmyfaq to 4.1.1 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-gcp9-5jc8-976x 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 pinpoints whether GHSA-gcp9-5jc8-976x is reachable in your code and exactly where to fix it, then blocks exploitation in production at runtime until the patched version is deployed.
Tailored to GHSA-gcp9-5jc8-976x. 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-gcp9-5jc8-976x in your dependencies?
O3 detects GHSA-gcp9-5jc8-976x across Packagist dependencies and uses function-level reachability to confirm whether the vulnerable code path is actually reachable — not just present. No false positives.