CVE-2026-56738: Phpmyfaq/phpmyfaq :add()` — Unescaped Stop Word Vulnerability

HIGH
Advisory Identifier: GHSA-rw77-vq4g-x3hp
CWE-89
Published
Advisory Summary

CVE-2026-56738 is a HIGH :add()` — unescaped stop word vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Phpmyfaq/phpmyfaq libraries in the Packagist ecosystem. The issue involves :add()` — unescaped stop word insertion. Remediation is available by upgrading affected packages to version 4.1.6.

CVE-2026-56738 at a Glance

CVE Identifier CVE-2026-56738
GHSA Identifier GHSA-rw77-vq4g-x3hp
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Phpmyfaq/phpmyfaq
Package Ecosystem Packagist
Published Date
Last Updated

How to Fix CVE-2026-56738

To remediate this vulnerability, upgrade all affected Phpmyfaq/phpmyfaq dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

phpmyfaq/phpmyfaq fixed: 4.1.6
Upgrade phpmyfaq/phpmyfaq to 4.1.6
thorsten/phpmyfaq fixed: 4.1.6
Upgrade thorsten/phpmyfaq to 4.1.6
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for phpmyfaq/phpmyfaq

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-56738, inspect your project dependencies for Phpmyfaq/phpmyfaq:

inspect dependencies for phpmyfaq/phpmyfaq

Analyze the terminal output to locate any version of Phpmyfaq/phpmyfaq in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.1.6), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Phpmyfaq/phpmyfaq, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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.

CVE-2026-56738 Affected Phpmyfaq/phpmyfaq Versions

2 component(s)
Fixed Versions:
4.1.6
Product / Package Ecosystem Affected Versions Fixed Version
phpmyfaq/phpmyfaq
Packagist
< 4.1.6
4.1.6
thorsten/phpmyfaq
Packagist
< 4.1.6
4.1.6

References

Frequently Asked Questions

What is CVE-2026-56738?
CVE-2026-56738 is a security vulnerability in Phpmyfaq/phpmyfaq involving :add()` — Unescaped Stop Word Insertion under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Phpmyfaq/phpmyfaq versions are affected?
Affected versions include releases prior to 4.1.6 across affected packages: phpmyfaq/phpmyfaq, thorsten/phpmyfaq.
What version fixes CVE-2026-56738?
Upgrading to 4.1.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is phpmyfaq/phpmyfaq affected?
Yes, phpmyfaq/phpmyfaq is affected in releases prior to 4.1.6. Upgrade your dependency to 4.1.6 or later.
Is thorsten/phpmyfaq affected?
Yes, thorsten/phpmyfaq is affected in releases prior to 4.1.6. Upgrade your dependency to 4.1.6 or later.
What CWE is associated with CVE-2026-56738?
CVE-2026-56738 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check Packagist dependencies for CVE-2026-56738?
Run the dependency tree command: 'inspect dependencies for phpmyfaq/phpmyfaq'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-rw77-vq4g-x3hp",
  "modified" : "2026-09-24T19:30:07Z",
  "published" : "2026-09-24T19:30:07Z",
  "aliases" : [ "CVE-2026-56738" ],
  "summary" : "phpMyFAQ has SQL Injection in `StopWords::add()` — Unescaped Stop Word Insertion",
  "details" : "## Summary\n\nThe `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.\n\nAn 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.\n\n---\n\n## Affected Code\n\n**File:** `phpmyfaq/src/phpMyFAQ/StopWords.php`\n**Method:** `add()` (approx. lines 60–75 in the audited revision)\n\n```php\n$sql = sprintf(\n    \"INSERT INTO %s VALUES(%d, '%s', '%s')\",\n    $this->getTableName(),\n    $id,\n    $this->configuration->getDb()->escape($this->language), // language IS escaped\n    $word                                                     // <-- $word is NOT escaped\n);\n```\n\n`$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.\n\n### Contrast with the safe sibling method\n\n**Method:** `update()` (line 82 in the audited revision)\n\n```php\n$this->configuration->getDb()->escape($word)\n```\n\n`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.\n\n---\n\n## Proof of Concept\n\n**Precondition:** Attacker has valid administrator credentials (or has otherwise obtained an authenticated administrator session, e.g. via a separate session-hijacking or CSRF vector).\n\n**Attack steps:**\n\n1. Authenticate to the phpMyFAQ administration panel.\n2. Navigate to the Stop Words management feature.\n3. Submit a new stop word with the following value instead of a normal word:\n\n   ```\n   test', 'en'); DROP TABLE faqstopwords; --\n   ```\n\n4. The resulting SQL statement sent to the database becomes (table/column names approximate, based on the traced `sprintf` template):\n\n   ```sql\n   INSERT INTO faqstopwords VALUES(1, 'en', 'test', 'en'); DROP TABLE faqstopwords; --')\n   ```\n\n5. 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).\n\n---\n\n## Impact\n\n- **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.\n- **Integrity:** Arbitrary `INSERT`/`UPDATE`/`DELETE` statements can be appended, allowing modification of unrelated application data.\n- **Availability:** As demonstrated in the PoC, structural statements like `DROP TABLE` can be injected, directly impacting application availability.\n\n**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.\n\n---\n\n## Root Cause\n\nThe 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:\n\n- `$this->language` in `add()`\n- `$word` in `update()`\n\nIt 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.\n\n---\n\n## Recommended Fix\n\nApply the same escaping already used in `update()` and already used for `$this->language` in the same `add()` method:\n\n```php\n$sql = sprintf(\n    \"INSERT INTO %s VALUES(%d, '%s', '%s')\",\n    $this->getTableName(),\n    $id,\n    $this->configuration->getDb()->escape($this->language),\n    $this->configuration->getDb()->escape($word)   // FIX: escape $word here\n);\n```\n\n**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.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpmyfaq/phpmyfaq"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.1.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.1.5"
    }
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "thorsten/phpmyfaq"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.1.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.1.5"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/thorsten/phpMyFAQ/security/advisories/GHSA-rw77-vq4g-x3hp"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-56738"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/thorsten/phpMyFAQ/commit/d56ef5d75c3c007de095bc4c13b470c7ac783f0f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/thorsten/phpMyFAQ"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/thorsten/phpMyFAQ/releases/tag/4.1.6"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-24T19:30:07Z",
    "nvd_published_at" : "2026-09-24T17:17:04Z"
  }
}