Sunday, October 18, 2026

PHP PDO Emulated Prepares Expose pdo_pgsql to NULL Pointer Dereference Crash

A recent security audit of PHP’s PDO ecosystem uncovered a denial-of-service vector in the pdo_pgsql driver that can crash PHP processes when emulated prepared statements are enabled.

PDO’s parser assumes a valid zend_string and dereferences it, triggering a NULL pointer dereference (SIGSEGV). The issue is tracked as CVE-2025-14180 and rated Moderate (6.3/10).

PDO implements two modes for preparing statements: native prepares, where the client library and server handle parameter binding, and emulated prepares, where PDO performs parameter expansion and escaping on the PHP side before sending a single text query.

When emulation is enabled (PDO::ATTR_EMULATE_PREPARES => true), pdo_pgsql delegates quoting to its quoter callback, which calls libpq’s PQescapeStringConn to escape bytes and produce a quoted zend_string.

If libpq detects an invalid multibyte sequence in the input it sets an error flag and the pdo_pgsql quoter bails out, returning NULL instead of a zend_string. That NULL is then written into the parser’s plc->quoted field.

The PDO SQL parser soon afterwards sums string lengths with the ZSTR_LEN macro, which expands directly to reading the .len field of a zend_string pointer.

Because plc->quoted is NULL, evaluating ZSTR_LEN(plc->quoted) performs a NULL dereference, causing the PHP process to crash.

The practical consequence is a reliable denial of service against PHP workers that process attacker-controlled input while using PDO emulated prepares with pdo_pgsql.

This defect is an example of a common class of bugs where higher-level code assumes successful allocation or return values from lower-level libraries without validating for failure.

PT Security Researchers said that, the fault stems from a gap in error handling between PDO’s SQL parsing logic and PostgreSQL’s libpq escaping routine: under certain malformed inputs, libpq fails and returns NULL during quoting.

Here the root cause is the mismatch between libpq’s error semantics and PDO’s expectations: libpq signals failure via an err flag and the driver returns NULL, but the parser path does not check for NULL before using the result.

PHP PDO ecosystem

The vulnerability was discovered while auditing PDO and its drivers alongside other issues such as a separate SQL injection in pdo_firebird (CVE-2025-14179) and third-party client library flaws in libpq and fbclient documented by the same research team.

PDO (PHP Data Objects) is PHP’s standard database abstraction layer, providing a consistent, object-oriented API for interacting with multiple DBMSs.


PHP Data Objects (Source : PT SWARM).
PHP Data Objects (Source : PT Security).

Mitigations are straightforward for application owners: disable PDO emulated prepares for PostgreSQL connections by explicitly setting PDO::ATTR_EMULATE_PREPARES to false, which forces native prepares and avoids the vulnerable parser path.

Operators should also ensure their PHP installations are patched with the upstream security release addressing CVE-2025-14180; maintainers have incorporated fixes into routine PHP updates that harden quoting and parser interactions.

The pdo_mysql driver escapes the data itself, interpolates it into the SQL template, and sends a single fully formed text query to the server.

MySQL general log (Source : PT SWARM).
MySQL general log (Source : PT Security).

Developers should audit code paths that perform quote-then-prepare workflows, and avoid relying on PDO::quote followed by PDO::prepare with emulation enabled against backends that use external client libraries with complex encoding rules.

For technical background and reproduction details, see the PHP security advisory for CVE-2025-14180 and the PDO SQL parser sources in the PHP repository.

The broader audit and related findings including the pdo_firebird SQL injection via NUL bytes (CVE-2025-14179), and a libpq integer overflow leading to DoS are described in the Positive Technologies write-ups: “Hack the Elephant One Bite at a Time: JPEG-Related Memory-Safety Bugs in PHP”.

Follow us on Google News, LinkedIn, and X to Get Instant Updates and Set GBH as a Preferred Source in Google.

Mayura Kathir
Mayura Kathirhttps://gbhackers.com/
Mayura Kathir is a cybersecurity reporter at GBHackers News, covering daily incidents including data breaches, malware attacks, cybercrime, vulnerabilities, zero-day exploits, and more.

Hot this week

How To Access Dark Web Anonymously and know its Secretive and Mysterious Activities

What is Deep Web The deep web, invisible web, or...

How to Build and Run a Security Operations Center (SOC Guide) – 2023

Today’s Cyber security operations center (CSOC) should have everything...

Russian Hackers Bypass EDR to Deliver a Weaponized TeamViewer Component

TeamViewer's popularity and remote access capabilities make it an...

Web Server Penetration Testing Checklist – 2026

Web server pentesting is performed under three significant categories: identity,...

ATM Penetration Testing – Advanced Testing Methods to Find The Vulnerabilities

ATM Penetration testing, Hackers have found different approaches to...

Hackers Use ConnectWise SkyKick Credentials to Access Microsoft 365, Halting Cloud Backups

Attackers abused compromised ConnectWise Cloud Backup credentials to access...

Anthropic’s Claude AI Uncovers Origins of NSA-Provided Cryptographic Keys After 25 Years

Anthropic says an internal Claude research model reconstructed how...

OpenBSD Kernel Flaw Dating Back 37 Years Enables Local Privilege Escalation to Root

A newly disclosed OpenBSD kernel exploitation chain combines a...

GhostAction Hackers Hide Credential-Stealing Malware in Fake Font Files Across 94 GitHub Repositories

GhostAction attackers have expanded their GitHub credential theft campaign...

SideCopy Hackers Target Indian Organizations With ReverseRAT Malware to Steal Data

Indian authorities have warned that SideCopy hackers are targeting...

New GhostBat Android Malware Targets 60 Banking and UPI Apps to Steal PINs

A new GhostBat RAT variant targets 60 Android financial...

New ROMULUS Malware Platform Uses Six Servers to Deliver Multiple Malicious Payloads

ROMULUS, a shared ClickFix delivery platform operating across six...

Related Articles

Recent News