/

CVE-2025-14179

Severity:

CRITICAL RISK

(9.8)

SQL Injection in PHP PDO Firebird Driver

CVE-2025-14179

Modified

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Injection and Data Compromise

Severity:

CRITICAL RISK

(9.8)

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

The PHP PDO Firebird driver contains a SQL injection flaw caused by improper handling of NUL bytes when preparing SQL queries.

When attacker-controlled values are quoted with PDO::quote() and embedded into SQL statements, a truncated string token can cause subsequent tokens to be interpreted as part of the string, enabling injection of arbitrary SQL.

Affected context

This vulnerability affects applications written in PHP that:

  • Use the PDO Firebird driver as the database abstraction layer
  • Build SQL statements by concatenating strings that include the result of PDO::quote()
  • Accept attacker-controlled input that may contain NUL bytes

The issue arises during token-by-token query construction inside the PDO Firebird driver, where NUL-terminated string copying causes quoted literals to be truncated before the closing quote, altering the intended SQL structure.

Exploit preconditions

  • Attack surface: Application endpoints or interfaces that accept untrusted input and use it to construct SQL queries against a Firebird database via PHP PDO.
  • Required access: Ability to supply crafted input that is passed to PDO::quote() and then concatenated into a SQL statement (e.g., HTTP parameters, form fields, API payloads).
  • Trigger point: Execution of a SQL query where the quoted value contains a NUL byte and is processed by the vulnerable PDO Firebird driver.
  • Why exploitation is possible: The driver uses strncat() to copy string tokens during query preparation. Because strncat() stops at the NUL byte, it drops the remainder of the literal, including the closing quote, causing the SQL parser to treat following tokens as part of the same string, which can reshape the query and inject attacker-controlled SQL fragments.

Why this happens

The root cause is a low-level string handling error in the PDO Firebird driver's query construction logic.

During SQL tokenization and reconstruction, a string token that includes a NUL byte is copied using strncat(), which interprets the NUL as the end of the string. This truncation removes the closing quote from the token while leaving the remainder of the query intact.

As a result, subsequent SQL tokens are interpreted as a continuation of the string literal rather than separate syntactic elements, violating the intended query structure. When the truncated string literal originated from attacker-controlled input passed through PDO::quote(), the attacker effectively gains control over how the rest of the query is parsed. This behavior aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), as the quoting mechanism fails to reliably isolate data from SQL syntax.

Potential impact

  • An attacker may inject arbitrary SQL into queries executed against the Firebird database.
  • An attacker may read, modify, or delete sensitive application data.
  • An attacker may escalate privileges within the application by manipulating authentication or authorization queries.
  • An attacker may cause denial of service through destructive or resource-intensive SQL operations.
  • An attacker could potentially pivot to compromise other systems that rely on the database's integrity or trust relationships.

General mitigation guidance

Effective mitigation focuses on ensuring that untrusted data cannot alter the structure of SQL statements and on hardening the database interaction layer:

  • Prefer parameterized queries / prepared statements with bound parameters for all dynamic values, avoiding manual concatenation of PDO::quote() output into SQL strings.
  • Treat quoting APIs as defensive tools of last resort; instead, structure code so that SQL and data are strictly separated.
  • Avoid passing raw binary or potentially NUL-containing data as textual SQL literals; where unavoidable, handle such data as parameters rather than inline strings.
  • Introduce abstraction layers (e.g., query builders or ORM patterns) that centralize and standardize safe query construction, reducing direct string manipulation.
  • Apply least-privilege principles to database accounts so that even if an injection occurs, the accessible operations and data are minimized.
  • Add input validation and normalization for fields that are expected to be textual, constraining them to allowable character sets and formats where business requirements permit.

How teams detect issues like this

Detecting this class of vulnerability typically combines code-level inspection with behavior monitoring:

  • Static analysis patterns:
  • Flag manual SQL string concatenation where variables are embedded into SQL, especially when using PDO::quote() followed by concatenation.
  • Identify usage patterns of PDO Firebird where untrusted input flows into SQL literals instead of bound parameters.
  • Code review signals:
  • SQL statements built via string concatenation or interpolation in PHP code using PDO for Firebird.
  • Functions or utility wrappers that quote input and return string fragments to be appended to base queries.
  • Handling of data that may contain NUL bytes and is later embedded into textual SQL contexts.
  • Policy enforcement examples:
  • Enforce coding standards that require prepared statements with bound parameters for all dynamic SQL.
  • Use CI-integrated linters or SAST tools configured with rules targeting SQL construction anti-patterns in PHP.
  • Apply database and application logs analysis to look for anomalous query patterns or unexpected syntax that might indicate injection attempts.

Sources

SourceLink
github.comgithub.com/php/php-src/security/advisories/GHSA-w476-322c-wpvm
access.redhat.comaccess.redhat.com/security/cve/CVE-2025-14179
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2468567
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2025/cve-2025-14179.json

Frequently asked

questions

Yes, it can be remotely exploitable if the application exposes interfaces (such as web forms, APIs, or CLI inputs) where user-supplied data is passed into PDO::quote() and then concatenated into SQL that is executed via the PDO Firebird driver.

An attacker typically needs only the ability to submit crafted input to the application—no direct database credentials are required. As long as their input is incorporated into SQL queries through the vulnerable pattern, they may be able to exploit the flaw.

The safest pattern is to refactor database interactions to use parameterized queries with bound parameters for all untrusted data. Instead of concatenating the output of PDO::quote() into SQL strings, developers should rely on prepared statements and let the PDO driver handle parameter binding without manual string composition.

Adopt a development policy that prohibits manual SQL string concatenation with untrusted input, enforce use of prepared statements in code review, and integrate automated checks that flag unsafe query construction. Additionally, centralize database access through well-reviewed abstractions and ensure that handling of binary or NUL-containing data is always done via parameters rather than inline SQL literals.

Find out what's already
exploitable in your codebase.