CVE-2026-136509 in psqlODBC
Summary
by MITRE • 11/26/2026
psqlODBC did not check that a server reply matches the query it sent: that a FETCH returns no more rows than it asked for, that each row has the described number of columns, that one query produces one result, and that a COPY, a transaction or the connection ends where the protocol says. By sending replies that do not match, 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) can corrupt memory in the application:
- A FETCH reply with more rows than requested overflows the row cache. - Extra results in reply to a FETCH, or to the queries of a keyset-driven cursor, are freed while still in use. - A key query of a keyset-driven cursor answered with extra columns, or a re-read row with fewer columns, overflows the row cache. - Replies without columns or rows, or with NULL values, to the driver's internal queries at connect time and in catalog functions are dereferenced. - A malformed relacl value in SQLTablePrivileges() makes the driver write past a buffer. - On Windows with MSDTC, a long transaction name returned by the server overflows a buffer during recovery. - Values in replies to the driver's internal queries are used without checking their range: an empty column name, a parameter count, a large-object size, a function's or trigger's argument count, and a result of exactly 32767 columns. They are dereferenced, read past, returned to the application or sent back to the server as stack memory, or make the driver loop forever. - A reply that ends a COPY, the connection or the transaction at an unexpected point leaves freed results, keysets or table information in use: a CopyOutResponse followed by a lost connection, a ROLLBACK command tag under UseDeclareFetch=1, or a lost connection while a cursor with positioned updates is closed. Eight extra bytes in a reply also make the driver wait forever for a COPY to end. - On Windows, a start-up reply without client_encoding crashes the driver, and with MSDTC a failed connection makes the XA library use a connection it has already freed. - An error message ending in the first byte of a multibyte character leaves the SQLSTATE returned by SQLGetDiagRecW() unterminated. - When a string value did not fit the application's buffer, eight Unicode entry points filled the buffer and wrote no null terminator, so a caller that reads to the terminator, as ODBC allows, read past the end of its own buffer.
This continues the fixes for CVE-2026-120058 and CVE-2026-120060, which covered other replies. 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 stems from a fundamental failure in input validation regarding server responses, allowing for severe memory corruption when interacting with untrusted or compromised database servers. The core technical flaw lies in the driver's assumption that all replies received from the PostgreSQL backend will strictly adhere to the protocol specification without deviation. Specifically, the software fails to verify critical structural integrity of data packets, including ensuring that FETCH operations return no more rows than requested, confirming that each row contains exactly the number of columns described in the metadata, and validating that a single query produces only one result set. Furthermore, the driver does not properly enforce protocol boundaries for COPY commands, transaction states, or connection termination sequences. This lack of rigorous validation creates multiple attack vectors where an adversary controlling the network path can inject malformed packets to exploit memory management errors within the application process.
The operational impact manifests primarily through heap corruption and stack-based buffer overflows, which typically lead to application crashes but carry a significant risk of arbitrary code execution under specific conditions. Several distinct mechanisms contribute to this instability. For instance, receiving a FETCH reply with more rows than requested causes an overflow in the row cache memory structure. Similarly, keyset-driven cursors that receive extra results or incorrect column counts result in use-after-free vulnerabilities where data structures are freed while still being actively referenced by the application logic. Internal queries executed during connection establishment and catalog operations are particularly vulnerable; if these replies contain NULL values, missing columns, or malformed relational ACL strings as seen in SQLTablePrivileges(), the driver attempts to dereference invalid pointers, leading to immediate crashes. On Windows systems utilizing Microsoft Distributed Transaction Coordinator (MSDTC), long transaction names returned by the server can overflow fixed-size buffers during recovery processes, while failed connections may cause the XA library to operate on already freed connection objects.
Additional vectors involve improper handling of string terminators and numeric ranges within protocol responses. When a string value exceeds the application's buffer capacity in Unicode entry points, the driver fills the buffer but fails to append a null terminator. This omission forces any subsequent caller that relies on standard C-string termination logic to read past the end of its own allocated memory space, resulting in information disclosure or further corruption. Numeric parameters such as column names, parameter counts, large object sizes, and argument counts for functions are used without range checking; values like exactly 32767 columns can trigger infinite loops or out-of-bounds reads. Error messages ending abruptly within a multibyte character sequence leave the SQLSTATE string returned by SQLGetDiagRecW() unterminated, compounding memory safety issues. Furthermore, unexpected termination of COPY operations or transactions leaves internal state structures like keysets and table information in an inconsistent, usable-but-freed state, which can be exploited to manipulate program flow.
From a classification perspective, this vulnerability aligns with CWE-20 Improper Input Validation and CWE-119 Buffer Overflow without proper bounds checking. The exploitation technique involves manipulating the communication channel between the client driver and the database server, corresponding to MITRE ATT&CK techniques related to Command and Control or Data Injection via network protocol manipulation. Although code execution has not been explicitly demonstrated in public reports, the nature of heap corruption and use-after-free conditions presents a high probability for successful exploitation by skilled attackers capable of performing man-in-the-middle attacks against connections that do not enforce strict SSL verification modes such as verify-full.
Mitigation strategies must focus on both software updates and network security configurations. The primary remediation is to upgrade psqlODBC to version 18.00.0007 or later, where these validation checks have been implemented. In environments where immediate patching is not feasible, administrators should enforce the use of SSL connections with verify-full mode enabled for all database interactions. This ensures that clients validate the server's certificate against a trusted authority and hostname, significantly reducing the risk of interception by malicious actors on the network path. Additionally, restricting access to PostgreSQL services through firewalls and ensuring that only authorized applications can initiate ODBC connections helps limit the attack surface available to potential adversaries seeking to exploit these protocol-level flaws.