Aug 24, 2026·6 min read·168 visits
An authenticated PostgreSQL user can trigger a heap-based buffer overflow in the to_char() formatting subsystem by using a maliciously long POSIX timezone abbreviation, leading to arbitrary code execution as the 'postgres' user.
CVE-2026-14669 is a critical heap-based buffer overflow vulnerability in PostgreSQL's date/time formatting function to_char(timestamptz). The flaw arises from unsafe copying of user-controlled timezone abbreviations into a fixed-size internal buffer. An authenticated database user can trigger this issue by setting a long POSIX timezone abbreviation containing custom formatting, allowing them to overwrite adjacent heap structures and hijack execution control to achieve remote code execution (RCE) with the privileges of the 'postgres' operating system user.
CVE-2026-14669 represents a significant security defect in the core date and time formatting module of the PostgreSQL database server. The vulnerability is triggered during the execution of the to_char(timestamptz) formatting function. It occurs when handling custom user-supplied timezone configurations that exceed standard buffer expectations.
PostgreSQL allows active database sessions to declare custom timezone environment settings. Under the POSIX timezone specification, arbitrary alphanumeric strings enclosed within angle brackets are accepted as valid timezone abbreviations. When a user queries to_char with timezone-formatting nodes, the engine tries to process these abbreviations dynamically.
Because this operation runs in the memory space of the active backend database worker, the heap-based buffer overflow exposes critical process structures to corruption. The attack surface is available to any database user authorized to log in and run standard queries. Successful exploitation yields unauthenticated system-level code execution capabilities for the underlying database hosting environment.
The underlying flaw resides in DCH_to_char within src/backend/utils/adt/formatting.c, which governs format conversions for timestamps. During execution, PostgreSQL parses format descriptors and allocates memory on the heap for the formatted output string. The buffer allocation size for each character of the formatting layout relies on a fixed multiplier.
The global configuration defines DCH_MAX_ITEM_SIZ as 12 bytes per formatting token. Consequently, the timezone tokens TZ and tz receive an allocation limit of exactly 24 bytes in the output array. The system, however, calls the function tmtcTzn(in) to retrieve the actual string of the current session timezone, which is fully controlled by the database client.
Historically, the formatting engine made no check on the string length returned by tmtcTzn(in) relative to the pre-calculated node allocation bounds. The function proceeded to write the retrieved abbreviation using the standard, unbounded strcpy utility. When the custom timezone abbreviation exceeds 24 characters, the memory copy overruns the allocated heap slot, corrupting adjacent chunk structures and heap pointers.
An analysis of the vulnerable source code in formatting.c highlights the omission of bounds validation during string operations. The vulnerable path maps directly to the formatting cases DCH_TZ and DCH_tz in the engine.
/* Vulnerable code implementation */
case DCH_TZ:
INVALID_FOR_INTERVAL;
if (tmtcTzn(in))
{
/* Convert to lowercase and copy without validation */
char *p = asc_tolower_z(tmtcTzn(in));
strcpy(s, p); // Unbounded copy onto heap-allocated pointer 's'
pfree(p);
s += strlen(s);
}
break;The fix, applied in commit 3d724bf4fde67a2931733a5143b7d6c12b23990c, introduces a strict length check. The timezone abbreviation length is validated against the calculated product of the format node length (n->key->len) and the DCH_MAX_ITEM_SIZ constant. If the incoming string length exceeds this boundary, execution halts instantly.
/* Patched code implementation */
case DCH_TZ:
INVALID_FOR_INTERVAL;
if (tmtcTzn(in))
{
/* ASCII-only downcasing with safe size checks */
char *p = asc_tolower_z(tmtcTzn(in));
if (strlen(p) <= n->key->len * DCH_MAX_ITEM_SIZ)
strcpy(s, p);
else
ereport(ERROR,
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("time zone format value too long")));
pfree(p);
s += strlen(s);
}
break;This safe comparison prevents any unbounded write condition. If an overlength abbreviation is present in the session context, the engine raises an ERRCODE_DATETIME_VALUE_OUT_OF_RANGE error, avoiding any memory corruption and safely aborting the SQL command transaction.
Security research demonstrates that CVE-2026-14669 can be reliably weaponized over standard SQL connections to bypass ASLR. The exploit path utilizes standard PostgreSQL wire protocol commands and is executed in four sequential stages.
In the first stage, the client configures the session to use SQL_ASCII encoding and sets a custom timezone with an abbreviation length of 43 bytes. By initiating a binary-format COPY operation against adjacent to_char outputs, the attacker corrupts the varlena length header of the second column on the heap. When the server processes the database payload, it transmits a large block of out-of-bounds heap memory back to the client, leaking catalog pointers that expose the database base executable address (PIE base).
-- Corrupt adjacent varlena header to disclose server memory addresses
SET TIME ZONE '<AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\x04\x01\x01>-10';
COPY (SELECT to_char(now(), 'TZ'), to_char(now(), 'TZ')) TO STDOUT (FORMAT binary);In the second stage, the attacker forces an invalid free error using a combined formatting sequence to_char(now(), 'TZtz'). The glibc allocator's diagnostic error message returns a raw pointer location on the heap, allowing the client to map the memory layout. The third stage uses SQL operations to place a forged MemoryContextCallback structure into heap memory, setting its execution handler to system and its argument pointer to the target shell command.
In the fourth and final stage, the query execution closes. This clean-up triggers PostgreSQL's internal garbage collection function MemoryContextReset(). The routine parses the forged memory structure, following the corrupt callback pointers, and executes the specified shell command. The execution runs under the server process privileges, completing the compromise.
The impact of successful exploitation is critical, compromising the target system's confidentiality, integrity, and availability. Attackers gain arbitrary code execution capabilities at the operating system level, inheriting the security context of the postgres server daemon.
With command execution established, the attacker can access, modify, or delete any data managed by the database server. They can also read sensitive configurations, inspect system files, and write backdoors. This enables potential lateral movement across internal network segments that interface with the database server.
In shared hosting, containerized, or cloud environments, this heap overflow acts as a direct container escape vector. Even users with restricted schema read access can escalate their privileges to host-level command execution, bypassing typical SQL authorization boundaries entirely.
The primary remediation strategy is the immediate application of official patches released by the PostgreSQL development group. Systems should be upgraded to the corrected versions across the supported branches: 18.5+, 17.11+, 16.15+, 15.19+, or 14.24+.
For systems where binary updates cannot be immediately deployed, administrators can apply defensive monitoring configurations. Sessions should be continuously audited for long or complex timezone settings. Security teams should deploy logging rules to track unusual queries matching custom timezone expressions or unexpected database allocator errors.
Database access should follow the principle of least privilege. Minimize client access to sensitive database servers, deploy network-level access control lists, and segment the database layer from public internet interfaces to reduce overall exploit exposure.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
PostgreSQL PostgreSQL Global Development Group | >= 18.0, < 18.5 | 18.5 |
PostgreSQL PostgreSQL Global Development Group | >= 17.0, < 17.11 | 17.11 |
PostgreSQL PostgreSQL Global Development Group | >= 16.0, < 16.15 | 16.15 |
PostgreSQL PostgreSQL Global Development Group | >= 15.0, < 15.19 | 15.19 |
PostgreSQL PostgreSQL Global Development Group | >= 14.0, < 14.24 | 14.24 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-122 |
| Attack Vector | Network |
| CVSS Score | 8.8 |
| EPSS Score | 0.00609 |
| Impact | Remote Code Execution |
| Exploit Status | poc |
| KEV Status | Not Listed |
The software performs an operation on a memory buffer allocated on the heap, but it writes more data than the buffer can accommodate, corrupting adjacent memory space.
A heap-based buffer overflow vulnerability in Pillow PyPI binary wheels (versions 11.1.0 to 12.x) allows remote code execution or application crash via crafted JPEG 2000 files processed by the bundled libopenjp2 library.
CVE-2026-109618 (dubbed PHP2Shell) is a critical vulnerability in the PHP engine core resulting from improper out-of-memory exception handling via longjmp(). When request allocation fails mid-processing, non-local control flow bypasses cleanup procedures, leaving memory structures uninitialized or in a use-after-free state during request shutdown.
CVE-2026-109619 (PHP2Shell) is a critical Use-After-Free vulnerability in the core PHP engine caused by improper global state cleanup during out-of-memory exception handling across persistent worker requests.
In Python virtualenv prior to version 21.14.9, activation script generators and configuration writers use Path.exists() before writing files. Because Path.exists() resolves symbolic links, it returns False for dangling symlinks. Consequently, virtualenv skips unlinking pre-planted symbolic links or hard links, writing data directly to target locations outside the intended virtual environment directory.
A remote code execution vulnerability exists in Microsoft .NET due to untrusted data deserialization within the PresentationCore component. The flaw stems from implicit auto-conversion flags during clipboard data retrieval operations.
An out-of-bounds write vulnerability in Microsoft .NET Framework, .NET runtime, and Visual Studio allows unauthenticated remote attackers to execute arbitrary code via crafted pixel-shader bytecode or auto-converted clipboard payloads.