/

CVE-2026-46359

Severity:

HIGH RISK

(7.5)

SQL Injection in phpMyFAQ OAuth Token Handling

CVE-2026-46359

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Query Execution

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

phpMyFAQ before 4.1.2 contains a SQL injection vulnerability in CurrentUser::setTokenData where OAuth token claims are concatenated into SQL queries without proper sanitization.

Authenticated attackers with Azure AD accounts whose display names or JWT claims contain crafted SQL metacharacters can break out of string literals and execute arbitrary queries against the phpMyFAQ database.

Affected context

The vulnerability surfaces in phpMyFAQ deployments that use OAuth authentication (such as Azure AD) and rely on token claims to populate or update user records.

It is most relevant when:

  • The application maps JWT claims (e.g., displayName, name, or custom claims) directly into SQL statements.
  • These claims are not normalized or escaped before being used in database operations.
  • The database account used by phpMyFAQ has broad privileges on the application schema.

Exploit preconditions

  • Attack surface: Web-facing phpMyFAQ instances using OAuth-based login flows.
  • Required access: Valid authenticated OAuth account (e.g., Azure AD), and the ability to control or influence token claims such as display name or other string fields.
  • Trigger point: Login or token processing path where CurrentUser::setTokenData constructs SQL queries from token claim values.
  • Why exploitation is possible: The token claim values are interpolated into SQL statements as raw strings without parameterization or robust escaping, allowing injected metacharacters to terminate or extend the original query.

Why this happens

This issue stems from constructing SQL queries by concatenating untrusted data from OAuth token claims directly into query strings.

Instead of using parameterized queries or prepared statements, CurrentUser::setTokenData appears to embed values such as user display names, identifiers, or other claims inline, trusting the identity provider to supply benign strings.

This pattern maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, where user-controllable input is not properly neutralized, enabling attackers to alter the intended SQL logic.

Potential impact

  • Execution of arbitrary SELECT, INSERT, UPDATE, or DELETE operations on the phpMyFAQ database.
  • Unauthorized access to or extraction of sensitive FAQ content, user records, or configuration data.
  • Tampering with user roles or permissions, potentially escalating privileges within phpMyFAQ.
  • Data corruption or deletion impacting availability of the knowledge base.
  • Placement of backdoor entries or malicious configuration values to aid further compromise.

General mitigation guidance

Effective mitigation focuses on ensuring that untrusted identity claims are never directly embedded in SQL:

  • Use parameterized queries or prepared statements for all database interactions involving token-derived values.
  • Introduce a normalization layer for identity data (e.g., display names) that strips or encodes control characters and SQL metacharacters before persistence.
  • Treat identity provider claims as untrusted input despite coming from a trusted IdP, and apply standard input validation and output encoding patterns.
  • Limit database account privileges according to least-privilege principles so that even if an injection occurs, the blast radius is constrained.
  • Centralize database access behind a data access layer that enforces parameterization and disallows ad-hoc query construction.

How teams detect issues like this

Teams can detect and monitor for vulnerabilities of this type using:

  • Static analysis: Rules that flag string concatenation used to build SQL statements, particularly in authentication and user management code paths.
  • Code review: Checkpoints ensuring all OAuth/JWT claim handling passes through vetted data access utilities that enforce parameterization.
  • Logging and monitoring: Database query logging to spot anomalous queries containing unexpected tokens, comments, or control characters in user-related fields.
  • Security testing: Targeted penetration tests or dynamic analysis using tampered JWTs and claims to validate that token-derived values are safely handled.
  • Policy enforcement: CI/CD pipeline checks that prevent merging of code introducing raw SQL construction or bypassing the established ORM/data access layer.

Sources

SourceLink
github.comgithub.com/thorsten/phpMyFAQ/security/advisories/GHSA-pm8c-3qq3-72w7
vulncheck.comvulncheck.com/advisories/phpmyfaq-sql-injection-in-currentuser-settokendata-via-unescaped-oauth-token-fields

Frequently asked

questions

Exploitation generally requires an authenticated OAuth account where the attacker can control token claim values, such as display names or custom attributes, and target a phpMyFAQ instance that consumes those claims without sanitization.

No administrative privileges are required; a normal OAuth user account with controllable claims is typically sufficient, although the ultimate impact depends on the database privileges granted to the phpMyFAQ application user.

The safest approach is to adopt parameterized queries or an ORM for all database access, ensuring that token-derived values are bound as parameters rather than concatenated into SQL strings, and to normalize or validate claim values before persistence.

Establish a secure coding standard that forbids dynamic SQL construction with untrusted data, enforce use of vetted data access layers, treat identity provider claims as untrusted input, and integrate automated checks in CI to flag unsafe SQL patterns.

Find out what's already
exploitable in your codebase.