CVE-2026-136507 in psqlODBC
Summary
by MITRE • 11/26/2026
psqlODBC parsed and built connection strings in ways that let a value end early:
- In a braced value, such as PWD={…}, a trailing byte 0x7d of a GBK, Big5 or SJIS character was taken for the closing brace.
- A braced value that ended right after an escaped }} was not reported as unterminated, and its contents were parsed as further keywords. - SQLConnectW(), SQLDriverConnectW() and SQLBrowseConnectW() cut a connection string whose UTF-8 form is longer than 32767 bytes, which changes how the rest of it is parsed. - On Windows with MSDTC, the password and user name were put into the XA open string without escaping, and the XA library copied each item of that string into a 64-byte stack buffer. - Percent-encoding a long password wrote one byte past a 4096-byte stack buffer.
An end user who supplies a password, or another value the application puts into the connection string, can set other connection keywords, for example to connect the application to a server of their choosing. The MSDTC case can also overflow a stack buffer in the process that loads the XA library.
Versions up to and including psqlODBC 18.00.0006 are affected.
Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.
Analysis
by VulDB Data Team • 11/26/2026
The PostgreSQL ODBC driver, known as psqlODBC, contains multiple critical vulnerabilities stemming from improper parsing logic for connection strings and insufficient buffer management during string manipulation operations. These flaws allow an attacker who can influence the contents of a database connection string to manipulate application behavior or achieve arbitrary code execution through stack-based buffer overflows. The core issue lies in how the driver interprets special characters, escape sequences, and length limits within the structured text format used for ODBC connections. This lack of rigorous validation creates opportunities for both logical bypasses that alter connectivity parameters and memory corruption vulnerabilities that compromise system stability and security.
One significant category of vulnerability involves the parsing logic for braced values in connection strings. In standard ODBC syntax, key-value pairs are often enclosed in curly braces, such as PWD={password}. The driver incorrectly handles multi-byte character encodings like GBK, Big5, and SJIS when processing these delimiters. Specifically, if a trailing byte of a valid multibyte character happens to be 0x7d, which is the ASCII code for the closing curly brace, the parser mistakenly interprets this byte as the end of the value rather than part of the data itself. This premature termination allows an attacker to truncate expected values and inject subsequent keywords into the connection string. For instance, by carefully crafting a password or username that ends with such a byte sequence in these specific encodings, an attacker can effectively close the current parameter early and append new parameters like SERVERNAME or DATABASE, thereby redirecting the application's database connections to infrastructure controlled by the attacker.
A second parsing flaw relates to escape sequences within braced values. The ODBC specification defines double braces as a way to include literal brace characters in connection strings. However, psqlODBC fails to correctly identify when a braced value ends immediately after an escaped sequence of two closing braces. Instead of recognizing the end of that specific parameter, the driver continues parsing the subsequent content as additional keywords or values. This logical error further facilitates injection attacks where malicious parameters are seamlessly appended to legitimate connection strings without triggering standard validation errors, allowing for stealthy manipulation of database connectivity settings.
The vulnerability landscape is compounded by issues related to string length handling and buffer management in specific API functions such as SQLConnectW, SQLDriverConnectW, and SQLBrowseConnectW. These functions impose a hard limit on the UTF-8 representation of connection strings at 32767 bytes. When a provided connection string exceeds this threshold, the driver truncates it rather than rejecting it or handling it safely. This arbitrary cutoff alters how the remainder of the string is parsed, potentially leading to inconsistent states where critical security parameters like authentication credentials are silently dropped while other malicious instructions remain active. Furthermore, on Windows systems utilizing Microsoft Distributed Transaction Coordinator (MSDTC), there is a severe stack-based buffer overflow vulnerability. When establishing XA transactions, the driver places usernames and passwords into an open string without proper escaping or length validation before copying them into fixed-size 64-byte stack buffers allocated within the XA library loading process. An attacker supplying sufficiently long credentials can overwrite adjacent memory on the stack, potentially gaining control over execution flow and achieving remote code execution with the privileges of the affected application process.
Another distinct buffer overflow exists in the handling of percent-encoded passwords. When a password containing special characters is processed through percent-encoding routines, the driver fails to account for the expanded size of the encoded string relative to its original allocation. This miscalculation results in writing one byte past the end of a 4096-byte stack buffer. While this specific overflow may appear minor due to its single-byte nature, it can still corrupt adjacent memory structures or return addresses depending on compiler-specific layout and optimization levels, contributing to potential exploitation vectors for privilege escalation or denial of service conditions.
The operational impact of these vulnerabilities is severe, particularly in environments where applications accept user-supplied input that gets incorporated into database connection strings without rigorous sanitization. An end-user with the ability to supply a password or other value can exploit the parsing flaws to redirect connections to malicious servers, facilitating man-in-the-middle attacks, credential harvesting, or data exfiltration. In scenarios involving MSDTC and stack buffer overflows, the risk escalates to full system compromise, allowing attackers to execute arbitrary code within the context of the application process. This is particularly dangerous in enterprise environments where database drivers run with elevated privileges or have access to sensitive internal resources.
Mitigation strategies must focus on both immediate patching and long-term architectural improvements. The primary remediation step is to upgrade psqlODBC to version 18.00.0007 or later, which addresses the parsing logic errors for multibyte encodings, escape sequences, length limits, and buffer overflows in MSDTC and percent-encoding routines. Application developers should also implement strict input validation on any data that enters connection strings, ensuring that special characters are properly escaped according to ODBC standards before being passed to driver functions. Utilizing parameterized queries where possible can reduce reliance on complex string-based configuration methods. Additionally, enabling stack protection mechanisms such as Stack Canaries and Address Space Layout Randomization (ASLR) in application builds provides a layer of defense against exploitation attempts involving buffer overflows.
From a classification perspective, these vulnerabilities map to several Common Weakness Enumerations that highlight the nature of the flaws. The parsing issues where values end prematurely or keywords are injected correspond to CWE-20 Improper Input Validation and CWE-74 Injection in External Control of String Syntax. The stack buffer overflows associated with MSDTC and percent-encoded passwords fall under CWE-121 Stack-based Buffer Overflow, indicating a failure to enforce bounds checking during memory operations. In terms of the MITRE ATT&CK framework, these vulnerabilities facilitate initial access techniques such as T1078 Valid Accounts if credentials are harvested via redirected connections, or potentially privilege escalation through exploitation of buffer overflows leading to code execution. The truncation issue related to string length limits can be viewed under CWE-134 Use of Externally-Controlled Format String or general input validation failures that lead to unexpected behavior in system components.
Organizations relying on PostgreSQL ODBC drivers must prioritize patching these specific versions immediately, especially if the applications using them are exposed to untrusted users or external networks. Security teams should audit connection string construction logic within their codebases to ensure no user-supplied data is directly interpolated into driver parameters without adequate sanitization and length checks. Regular vulnerability scanning focused on outdated ODBC drivers and monitoring for anomalous database connection patterns can help detect exploitation attempts in real-time, providing an additional layer of defense against these sophisticated parsing-based attacks.