CVE-2026-46359: phpMyFAQ has SQL Injection in CurrentUser::setTokenData through unescaped OAuth token fields

Published May 6, 2026
·
Updated

Summary

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 (refreshtoken, accesstoken, codeverifier, and jsonencode($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.

Details

Vulnerable code (phpmyfaq/src/phpMyFAQ/User/CurrentUser.php, lines 513-534):

php public function setTokenData(#[\SensitiveParameter] array $token): bool { $update = sprintf( " UPDATE %sfaquser SET refreshtoken = '%s', accesstoken = '%s', codeverifier = '%s', jwt = '%s' WHERE userid = %d", Database::getTablePrefix(), $token['refreshtoken'], $token['accesstoken'], $token['codeverifier'], jsonencode($token['jwt'], JSONTHROWONERROR), $this->getUserId(), );

return (bool) $this->configuration->getDb()->query($update); }

jsonencode() does NOT escape single quotes. A JWT claim such as {"preferredusername": "O'Malley"} produces {"preferredusername":"O'Malley"} after jsonencode, which terminates the SQL string literal at the apostrophe.

Correct pattern in the same file (setAuthSource, line 458-461):

php $update = sprintf( "UPDATE %sfaquser SET authsource = '%s' WHERE userid = %d", Database::getTablePrefix(), $this->configuration->getDb()->escape($authSource), $this->getUserId(), );

setRememberMe() (line 471-478) follows the same safe pattern with $db->escape().

Reachability: The phpMyFAQ Azure AD (Entra ID) OAuth flow calls setTokenData() after token exchange. The token response includes an idtoken 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.

Proof of Concept

Prerequisites: phpMyFAQ instance with Azure AD / Entra ID authentication enabled.

1. Bob registers an Azure AD account with display name x]","email":"x',(SELECT SLEEP(5)))-- -.

2. Bob initiates the OAuth login flow on the target phpMyFAQ.

3. After authorization, the token endpoint returns a JWT with the crafted claim.

4. phpMyFAQ calls setTokenData() with the unsanitized token array. The resulting SQL becomes:

sql UPDATE faquser SET refreshtoken = '<valid>', accesstoken = '<valid>', codeverifier = '<valid>', jwt = '{"preferredusername":"x',(SELECT SLEEP(5)))-- -"}' WHERE userid = 42

The single quote after x closes the jwt string literal. Everything after it executes as attacker-controlled SQL.

5. To confirm time-based blind injection locally (requires modifying the OAuth token response in a proxy):

python import requests

Simulates what happens when the crafted JWT claim reaches the DB In production, this happens automatically through the OAuth flow payload = "x'||(SELECT SLEEP(5))||'"

The interpolated query will pause for 5 seconds, confirming injection print(f"Injected jwt value: {payload}") print("If the login takes 5+ seconds longer than normal, injection succeeded.")

Impact

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

CWE: CWE-89 (SQL Injection)

Recommended Fix

Escape all interpolated values using $this->configuration->getDb()->escape(), matching the pattern used by setAuthSource() and setRememberMe() in the same file:

php public function setTokenData(#[\SensitiveParameter] array $token): bool { $db = $this->configuration->getDb(); $update = sprintf( " UPDATE %sfaquser SET refreshtoken = '%s', accesstoken = '%s', codeverifier = '%s', jwt = '%s' WHERE userid = %d", Database::getTablePrefix(), $db->escape($token['refreshtoken']), $db->escape($token['accesstoken']), $db->escape($token['codeverifier']), $db->escape(jsonencode($token['jwt'], JSONTHROWONERROR)), $this->getUserId(), );

return (bool) $db->query($update); }

--- Found by aisafe.io

Other sources

phpMyFAQ before 4.1.2 contains a sql injection vulnerability in CurrentUser::setTokenData that allows authenticated attackers to execute arbitrary SQL by injecting malicious OAuth token claims. Attackers with Azure AD accounts containing SQL metacharacters in display names or JWT claims can break out of string literals and execute arbitrary database queries.

— MITRE

phpMyFAQ has SQL Injection in CurrentUser::setTokenData through unescaped OAuth token fields

— Packagist

Affected Software

5 affected componentsFixes available
PhpMyFaq phpmyfaq<4.1.2
composer/phpmyfaq/phpmyfaq<=4.1.1
composer/thorsten/phpmyfaq<=4.1.1
composer/phpmyfaq/phpmyfaq<=4.1.1
4.1.2
composer/thorsten/phpmyfaq<=4.1.1
4.1.2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade composer/phpmyfaq/phpmyfaq to a version that resolves this vulnerability.

    Fixed in 4.1.2
  2. Upgrade

    Upgrade composer/thorsten/phpmyfaq to a version that resolves this vulnerability.

    Fixed in 4.1.2
  3. Upgrade

    Upgrade phpMyFAQ to a version that resolves this vulnerability.

    Fixed in 4.1.2

Event History

May 6, 2026
Advisory Published
via GitHub·08:44 PM
Data Sourced
via GitHub·08:44 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via Packagist·08:44 PM
DescriptionSeverityAffected Software
May 15, 2026
CVE Published
via MITRE·06:36 PM
Data Sourced
via MITRE·06:36 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·07:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

What is the severity of CVE-2026-46359?

CVE-2026-46359 has a high severity rating due to its potential to allow authenticated attackers to execute arbitrary SQL queries.

2

How do I fix CVE-2026-46359?

To fix CVE-2026-46359, upgrade phpMyFAQ to version 4.1.2 or later.

3

Who is affected by CVE-2026-46359?

CVE-2026-46359 affects all versions of phpMyFAQ prior to 4.1.2.

4

What type of vulnerability is CVE-2026-46359?

CVE-2026-46359 is an SQL injection vulnerability.

5

What is the impact of CVE-2026-46359?

The impact of CVE-2026-46359 includes the potential for attackers to manipulate database queries and access sensitive data.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203