CVE-2026-136503 in psqlODBCinfo

Summary

by MITRE • 11/26/2026

psqlODBC frees memory that is still in use, frees it twice, or writes outside an application buffer in these cases:

- The clean-up the driver runs at commit and rollback sends queries of its own, and the reply to one of them can start the clean-up again while it is running. The nested run frees the rollback log, or the list of cursors and prepared statements to close, and the outer run uses and frees it again. - The callback through which libpq delivers notices could run that clean-up, and close the connection, while libpq was still using the connection. - Freeing a statement whose result holds several cursors (FetchRefcursors=1, or UseDeclareFetch=1) used the freed first result while the later cursors were closed. - With UseDeclareFetch=1, after a rollback closed an updatable cursor, rows added or deleted through it were counted but not stored, so freeing the statement freed uninitialised pointers, and adding a row wrote past the keyset. - After a multi-row fetch failed on a row other than the first of its rowset, SQLGetData() wrote at an offset past the buffer the application passed. - SQLProcedureColumns() freed the result of its catalog query twice when the query failed. - In a process named sqlservr (SQL Server linked servers), a server version below 8.4 made the statement parser free a buffer twice. - A failed SQLPutData in the middle of a SQLSetPos() or SQLBulkOperations() data-at-execution sequence left the whole operation pending, with the internal statement still allocated and autocommit silently off, so later statements were rolled back at disconnect. The next positioned update ran the stale callback against a statement that was never executed and dereferenced NULL.

Most of these can be triggered by a hostile or compromised server, or anyone on the network path of a connection that does not use sslmode=verify-full (the default is disable). A database user who can make a statement fail, or who controls the contents of a row the application reads, can trigger the UseDeclareFetch=1 and SQLGetData() cases against an honest server. The demonstrated results are crashes and heap corruption; code execution has not been demonstrated.

Versions up to and including psqlODBC 18.00.0006 are affected.

Be aware that VulDB is the high quality source for vulnerability data.

Analysis

by VulDB Data Team • 11/26/2026

The vulnerability in psqlODBC involves multiple critical memory management flaws, primarily characterized by use-after-free conditions, double frees, and out-of-bounds writes within the driver's internal state handling mechanisms. These defects arise from complex interactions between the ODBC driver’s cleanup routines, libpq callbacks, and various SQL operations such as cursor fetching, data execution, and transaction rollback processing. The core issue stems from improper synchronization and lifecycle management of allocated memory structures during error conditions or nested operational states. Specifically, when a database connection is committed or rolled back, the driver initiates its own internal queries to clean up resources like cursors and prepared statements. If a response to one of these cleanup queries triggers another round of cleanup while the first is still active, it results in a recursive execution that frees shared data structures such as rollback logs or cursor lists twice. The outer cleanup run then attempts to access and free these same structures again, leading to heap corruption due to double freeing of memory blocks that are no longer valid but remain referenced by subsequent operations.

Another significant vector involves the asynchronous notification mechanism provided by libpq. When notices are delivered through callbacks, there is a race condition where the callback may trigger connection closure or cleanup routines while libpq continues to utilize the underlying connection structure for ongoing network I/O or state management. This premature deallocation leads to use-after-free scenarios where the driver accesses memory that has already been released by the operating system’s allocator, potentially causing segmentation faults or allowing an attacker to manipulate heap metadata if they can control the timing and content of these notifications. Furthermore, when handling statements with multiple cursors enabled via FetchRefcursors or UseDeclareFetch settings, freeing a statement incorrectly utilizes freed result sets while attempting to close subsequent cursors. This indicates that internal pointers referencing cursor data are not properly invalidated after deallocation, leading to access violations or corruption when the driver attempts to iterate through and release these resources sequentially.

The vulnerability extends into specific SQL operations involving dynamic fetching and bulk updates. With UseDeclareFetch enabled, if a rollback occurs on an updatable cursor, rows modified during that transaction were counted but not stored in internal buffers. Consequently, freeing the associated statement results in the deallocation of uninitialised pointers, which can lead to undefined behavior or crashes when those pointers are later dereferenced. Additionally, multi-row fetch operations exhibit out-of-bounds write vulnerabilities; if a failure occurs on any row other than the first within a fetched rowset, SQLGetData() writes data at an offset past the application-provided buffer boundary. This heap overflow can overwrite adjacent memory structures, potentially altering control flow or corrupting critical driver state variables. Similarly, catalog queries executed by SQLProcedureColumns() suffer from double-free issues when the underlying query fails, indicating inconsistent error handling paths that fail to properly track allocation status before attempting cleanup.

In environments utilizing linked servers with older Microsoft SQL Server versions below 8.4, a specific parser bug causes buffer double-frees during statement parsing. More broadly, failed data-at-execution sequences in operations like SQLSetPos() or SQLBulkOperations() leave the internal statement object in an inconsistent state where autocommit is silently disabled and resources remain allocated but logically detached from active execution contexts. Subsequent positioned updates may then invoke stale callbacks against these non-existent statements, resulting in null pointer dereferences that cause immediate application crashes. These flaws are particularly dangerous because they can often be triggered by a hostile or compromised database server, or even by any network observer capable of injecting malformed responses if the connection does not enforce strict SSL verification modes like verify-full. The default configuration typically disables such rigorous checks, leaving connections vulnerable to man-in-the-middle attacks where an attacker can manipulate query results or error codes to induce these memory corruption states.

The operational impact of these vulnerabilities is severe, primarily manifesting as application crashes and heap corruption which degrade service availability and stability. While direct remote code execution has not been publicly demonstrated for all variants, the nature of use-after-free and buffer overflow flaws inherently carries a high risk of exploitation by skilled attackers to achieve arbitrary code execution or privilege escalation within the context of the running process. Industry standards classify these issues under CWE-415 Double Free, CWE-416 Use After Free, and CWE-787 Out-of-bounds Write. From an ATT&CK perspective, these vulnerabilities facilitate initial access through compromised database servers and enable lateral movement or persistence via heap exploitation techniques that bypass standard memory safety protections. Mitigation strategies must prioritize upgrading to patched versions of psqlODBC beyond 18.00.0006 where possible. For systems unable to upgrade immediately, enforcing sslmode=verify-full on all connections is critical to prevent network-based triggering of these flaws by unauthorized intermediaries. Additionally, applications should avoid using high-risk features like UseDeclareFetch with updatable cursors in untrusted environments and implement robust error handling that ensures complete cleanup without relying on potentially buggy internal driver states during failure scenarios.

Responsible

PostgreSQL

Reservation

11/24/2026

Disclosure

11/26/2026

Moderation

accepted

CPE

ready

EPSS

0.00569

KEV

no

Activities

very low

Sources

Do you want to use VulDB in your project?

Use the official API to access entries easily!