CVE-2026-46359: Thorsten/phpmyfaq :setTokenData Through Unescaped OAuth Token Vulnerability
HIGHCVE-2026-46359 is a HIGH (CVSS 7.5) :settokendata through unescaped oauth token vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Thorsten/phpmyfaq libraries in the Packagist ecosystem. The issue involves :settokendata through unescaped oauth token fields. Remediation is available by upgrading affected packages to version 4.1.2.
CVE-2026-46359 at a Glance
Security Impact
CVSS: 7.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2026-46359
To remediate this vulnerability, upgrade all affected Thorsten/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.
Upgrade thorsten/phpmyfaq to 4.1.2
Upgrade phpmyfaq/phpmyfaq to 4.1.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for thorsten/phpmyfaq
How to Check if You Are Affected
To determine whether your application is affected by CVE-2026-46359, inspect your project dependencies for Thorsten/phpmyfaq:
inspect dependencies for thorsten/phpmyfaq
Analyze the terminal output to locate any version of Thorsten/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.2), 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 Thorsten/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
CVE-2026-46359 Affected Thorsten/phpmyfaq Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
thorsten/phpmyfaq
|
Packagist |
< 4.1.2
|
4.1.2
|
|
phpmyfaq/phpmyfaq
|
Packagist |
< 4.1.2
|
4.1.2
|
References
Frequently Asked Questions
What is CVE-2026-46359?
Which Thorsten/phpmyfaq versions are affected?
What version fixes CVE-2026-46359?
Is thorsten/phpmyfaq affected?
Is phpmyfaq/phpmyfaq affected?
What is the CVSS score of CVE-2026-46359?
What CWE is associated with CVE-2026-46359?
How can I check Packagist dependencies for CVE-2026-46359?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-pm8c-3qq3-72w7",
"modified" : "2026-06-09T00:02:16Z",
"published" : "2026-05-06T20:44:39Z",
"aliases" : [ "CVE-2026-46359" ],
"summary" : "phpMyFAQ has SQL Injection in CurrentUser::setTokenData through unescaped OAuth token fields",
"details" : "## Summary\n\n`CurrentUser::setTokenData()` in `phpmyfaq/src/phpMyFAQ/User/CurrentUser.php` at lines 515-534 builds a SQL UPDATE statement with `sprintf` and interpolates OAuth token fields (`refresh_token`, `access_token`, `code_verifier`, and `json_encode($token['jwt'])`) without calling `$db->escape()`. Sibling methods `setAuthSource()` and `setRememberMe()` in the same file do call `$db->escape()` on user-controlled values, so the omission is local to this method. An attacker (Bob) whose Azure AD display name contains a single quote (for example `O'Brien`, or a deliberate SQL payload) breaks out of the string literal and injects arbitrary SQL against the phpMyFAQ database.\n\n## Details\n\n**Vulnerable code** (`phpmyfaq/src/phpMyFAQ/User/CurrentUser.php`, lines 513-534):\n\n```php\npublic function setTokenData(#[\\SensitiveParameter] array $token): bool\n{\n $update = sprintf(\n \"\n UPDATE\n %sfaquser\n SET\n refresh_token = '%s',\n access_token = '%s',\n code_verifier = '%s',\n jwt = '%s'\n WHERE\n user_id = %d\",\n Database::getTablePrefix(),\n $token['refresh_token'],\n $token['access_token'],\n $token['code_verifier'],\n json_encode($token['jwt'], JSON_THROW_ON_ERROR),\n $this->getUserId(),\n );\n\n return (bool) $this->configuration->getDb()->query($update);\n}\n```\n\n`json_encode()` does NOT escape single quotes. A JWT claim such as `{\"preferred_username\": \"O'Malley\"}` produces `{\"preferred_username\":\"O'Malley\"}` after `json_encode`, which terminates the SQL string literal at the apostrophe.\n\n**Correct pattern in the same file** (`setAuthSource`, line 458-461):\n\n```php\n$update = sprintf(\n \"UPDATE %sfaquser SET auth_source = '%s' WHERE user_id = %d\",\n Database::getTablePrefix(),\n $this->configuration->getDb()->escape($authSource),\n $this->getUserId(),\n);\n```\n\n`setRememberMe()` (line 471-478) follows the same safe pattern with `$db->escape()`.\n\n**Reachability**: The phpMyFAQ Azure AD (Entra ID) OAuth flow calls `setTokenData()` after token exchange. The token response includes an `id_token` whose payload originates from the identity provider. An attacker registers a Microsoft account with a display name or custom claim containing SQL metacharacters. When that user logs into a phpMyFAQ instance with Azure AD auth enabled, the malicious claim flows into the UPDATE without sanitization.\n\n## Proof of Concept\n\nPrerequisites: phpMyFAQ instance with Azure AD / Entra ID authentication enabled.\n\n1. Bob registers an Azure AD account with display name `x]\",\"email\":\"x',(SELECT SLEEP(5)))-- -`.\n\n2. Bob initiates the OAuth login flow on the target phpMyFAQ.\n\n3. After authorization, the token endpoint returns a JWT with the crafted claim.\n\n4. phpMyFAQ calls `setTokenData()` with the unsanitized token array. The resulting SQL becomes:\n\n```sql\nUPDATE faquser\nSET\n refresh_token = '<valid>',\n access_token = '<valid>',\n code_verifier = '<valid>',\n jwt = '{\"preferred_username\":\"x',(SELECT SLEEP(5)))-- -\"}'\nWHERE\n user_id = 42\n```\n\nThe single quote after `x` closes the `jwt` string literal. Everything after it executes as attacker-controlled SQL.\n\n5. To confirm time-based blind injection locally (requires modifying the OAuth token response in a proxy):\n\n```python\nimport requests\n\n# Simulates what happens when the crafted JWT claim reaches the DB\n# In production, this happens automatically through the OAuth flow\npayload = \"x'||(SELECT SLEEP(5))||'\"\n\n# The interpolated query will pause for 5 seconds, confirming injection\nprint(f\"Injected jwt value: {payload}\")\nprint(\"If the login takes 5+ seconds longer than normal, injection succeeded.\")\n```\n\n## Impact\n\nAn attacker who can authenticate via Azure AD with a crafted claim achieves arbitrary SQL execution on the phpMyFAQ database. This permits reading all FAQ data (including restricted entries), modifying or deleting content, and extracting password hashes and session tokens of all users including administrators.\n\n**CWE**: CWE-89 (SQL Injection)\n\n## Recommended Fix\n\nEscape all interpolated values using `$this->configuration->getDb()->escape()`, matching the pattern used by `setAuthSource()` and `setRememberMe()` in the same file:\n\n```php\npublic function setTokenData(#[\\SensitiveParameter] array $token): bool\n{\n $db = $this->configuration->getDb();\n $update = sprintf(\n \"\n UPDATE\n %sfaquser\n SET\n refresh_token = '%s',\n access_token = '%s',\n code_verifier = '%s',\n jwt = '%s'\n WHERE\n user_id = %d\",\n Database::getTablePrefix(),\n $db->escape($token['refresh_token']),\n $db->escape($token['access_token']),\n $db->escape($token['code_verifier']),\n $db->escape(json_encode($token['jwt'], JSON_THROW_ON_ERROR)),\n $this->getUserId(),\n );\n\n return (bool) $db->query($update);\n}\n```\n\n---\n*Found by [aisafe.io](https://aisafe.io)*",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "thorsten/phpmyfaq"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.1.2"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 4.1.1"
}
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "phpmyfaq/phpmyfaq"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.1.2"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 4.1.1"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/thorsten/phpMyFAQ/security/advisories/GHSA-pm8c-3qq3-72w7"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-46359"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/thorsten/phpMyFAQ"
}, {
"type" : "WEB",
"url" : "https://www.vulncheck.com/advisories/phpmyfaq-sql-injection-in-currentuser-settokendata-via-unescaped-oauth-token-fields"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-89" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-05-06T20:44:39Z",
"nvd_published_at" : null
}
}