High

phpMyFAQ has SQL Injection in `StopWords::add()` — Unescaped Stop Word Insertion

  • Disclosed: 24.09.2026
  • Updated: 11.10.2026 10:22

Summary

The StopWords::add() method in phpMyFAQ builds a SQL INSERT statement using sprintf() and inserts the user-supplied stop word value directly into the query string without calling the application's database escaping function on it. A sibling method, StopWords::update(), which modifies an existing stop word, correctly escapes the same kind of input. The omission is isolated to the add() (insert) code path.

An authenticated administrator who can reach the stop-word management feature can submit a crafted value as the "word" parameter that breaks out of the SQL string literal and injects arbitrary SQL, including statements to drop tables, exfiltrate data, or modify other rows in the database.


Affected Code

File: phpmyfaq/src/phpMyFAQ/StopWords.php Method: add() (approx. lines 60–75 in the audited revision)

php
$sql = sprintf(
    "INSERT INTO %s VALUES(%d, '%s', '%s')",
    $this->getTableName(),
    $id,
    $this->configuration->getDb()->escape($this->language), // language IS escaped
    $word                                                     // <-- $word is NOT escaped
);

$word is taken directly from the administrative form input (the new stop word to add) and concatenated into the SQL string via sprintf("'%s'", ...) with no call to the database driver's escape() method.

Contrast with the safe sibling method

Method: update() (line 82 in the audited revision)

php
$this->configuration->getDb()->escape($word)

update() — which modifies an existing stop word — correctly escapes $word before use. add() does not perform the same escaping on the equivalent value. This inconsistency between two methods handling the same data type is the root cause: the escaping convention used throughout the rest of the file was not applied uniformly to this one insertion path.


Proof of Concept

Precondition: Attacker has valid administrator credentials (or has otherwise obtained an authenticated administrator session, e.g. via a separate session-hijacking or CSRF vector).

Attack steps:

  1. Authenticate to the phpMyFAQ administration panel.

  2. Navigate to the Stop Words management feature.

  3. Submit a new stop word with the following value instead of a normal word:

    test', 'en'); DROP TABLE faqstopwords; --
  4. The resulting SQL statement sent to the database becomes (table/column names approximate, based on the traced sprintf template):

    sql
    INSERT INTO faqstopwords VALUES(1, 'en', 'test', 'en'); DROP TABLE faqstopwords; --')
  5. The injected DROP TABLE faqstopwords; statement executes as a second SQL statement (subject to the database driver/PDO configuration permitting multi-statement execution; even where multi-statement execution is disabled, the same injection point allows classic single-statement SQLi techniques such as UNION-based data extraction or boolean/time-based blind injection against other tables the database user can access).


Impact

  • Confidentiality: An attacker with this access can use UNION-based or blind SQL injection techniques to read data from other tables in the database (e.g. user credentials, FAQ content marked as private/internal, session data) that the database user account has permission to access.
  • Integrity: Arbitrary INSERT/UPDATE/DELETE statements can be appended, allowing modification of unrelated application data.
  • Availability: As demonstrated in the PoC, structural statements like DROP TABLE can be injected, directly impacting application availability.

Mitigating factor: Exploitation requires an authenticated administrator session. This is not exploitable by an anonymous or low-privilege user. This lowers the severity from Critical/High to Medium, consistent with phpMyFAQ's own threat model where administrators are a trusted role — but it remains a genuine defense-in-depth failure: a compromised or malicious admin account (or an admin tricked via a separate vector such as CSRF, if no CSRF protection exists on this specific form) can leverage this into full database compromise, which a properly parameterized query would have prevented even in that scenario.


Root Cause

The codebase's established pattern for this class (StopWords.php) is to escape all string values via $this->configuration->getDb()->escape($value) before placing them into a sprintf()-built SQL string. This pattern is correctly applied to:

  • $this->language in add()
  • $word in update()

It is not applied to $word in add(). This is a single-line omission, not a structural design flaw — the safe pattern already exists in the same file and the same class, just inconsistently applied across the two methods that handle the same input type.


Recommended Fix

Apply the same escaping already used in update() and already used for $this->language in the same add() method:

php
$sql = sprintf(
    "INSERT INTO %s VALUES(%d, '%s', '%s')",
    $this->getTableName(),
    $id,
    $this->configuration->getDb()->escape($this->language),
    $this->configuration->getDb()->escape($word)   // FIX: escape $word here
);

Stronger recommended fix (defense in depth): Migrate this query, and ideally all sprintf()-built SQL in this class, to parameterized/prepared statements (e.g. PDO::prepare() with bound parameters) rather than string-escaping plus sprintf(). Escaping is correct when applied consistently, but prepared statements remove this entire vulnerability class structurally and prevent any future omission of this kind from being exploitable.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Composer package phpmyfaq/phpmyfaq < 4.1.6 4.1.6
Composer package thorsten/phpmyfaq < 4.1.6 4.1.6

References

CVSS score -
CVSS vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N
Weakness (CWE)
CWE-89
Platform
Composer
Package
phpmyfaq/phpmyfaq, thorsten/phpmyfaq
Disclosed
24.09.2026
Updated
11.10.2026 10:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-rw77-vq4g-x3hp - CC BY 4.0

Vulnerability history: thorsten/phpmyfaq

All published vulnerabilities of this package (Composer package), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (112) in the archive
Total entries
112
First → latest
05.2022 09.2026
Without a fix
2
Exploited in attacks
0

Severity breakdown

  • Critical 8
  • High 36
  • Medium 67
  • Low 1

Disclosures per year

  1. 2022: 8
  2. 2023: 62
  3. 2024: 2
  4. 2025: 6
  5. 2026: 34
Severity:
  1. phpMyFAQ has SQL Injection in `StopWords::add()` — Unescaped Stop Word Insertion this entry
    High CVE-2026-56738 < 4.1.6 4.1.6
  2. High · 8.1 CVE-2026-56737 >= 3.2.0, < 4.1.6 4.1.6
  3. High · 7.5 CVE-2026-35672 < 4.1.3 4.1.3
  4. High · 8.8 CVE-2026-35671 < 4.1.3 4.1.3
  5. High · 7.6 CVE-2026-46367 >= 4.1.1, < 4.1.2 4.1.2
  6. High · 7.5 CVE-2025-69200 < 4.0.16, >= 4.1.0-alpha, <= 4.1.0-beta.2 4.0.16
  7. High · 8.1 CVE-2025-59943 >= 4.0.7, < 4.0.13 4.0.13
  8. High · 7.6 CVE-2023-5865 < 3.2.2 3.2.2
  9. High · 7.4 CVE-2023-5864 < 3.2.1 3.2.1
  10. High · 8.3 CVE-2023-5319 < 3.1.18 3.1.18
  11. Critical · 9.0 CVE-2023-5320 < 3.1.18 3.1.18
  12. Critical · 9.1 CVE-2023-5316 < 3.1.18 3.1.18
  13. High · 8.8 CVE-2023-4007 < 3.1.16 3.1.16
  14. High · 8.2 CVE-2023-2550 < 3.1.13 3.1.13
  15. High · 8.3 CVE-2023-1887 < 3.1.12 3.1.12
  16. High · 7.3 CVE-2023-1886 < 3.1.12 3.1.12
  17. Critical · 9.8 CVE-2023-0788 < 3.1.11 3.1.11
  18. Critical · 9.8 CVE-2023-0789 < 3.1.11 3.1.11
  19. High · 8.8 CVE-2023-0790 < 3.1.11 3.1.11
  20. High · 8.8 CVE-2023-0793 < 3.1.11 3.1.11
  21. Critical · 9.8 CVE-2023-0311 < 3.1.10 3.1.10
  22. High · 7.5 CVE-2022-4409 < 3.1.9 3.1.9
  23. Critical · 9.8 CVE-2022-3754 < 3.1.8 3.1.8
  24. High · 8.4 CVE-2022-3608 < 3.2.0-alpha 3.2.0-alpha
  25. High · 8.8 CVE-2018-16650 < 2.9.11 2.9.11

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.