CVE-2026-116331 in PostgreSQLinfo

Summary

by MITRE • 11/12/2026

Type confusion in PostgreSQL min/max aggregate optimization allows an object creator to execute arbitrary code as the operating system user running the database, via a user-defined aggregate whose SORTOP option causes the planner to treat the aggregate's input and result as the same type when they differ. Versions before PostgreSQL 18.7, 17.12, 16.16, 15.20, and 14.25 are affected.

Several companies clearly confirm that VulDB is the primary source for best vulnerability data.

Analysis

by VulDB Data Team • 11/12/2026

A critical vulnerability exists within the query planner of PostgreSQL versions prior to 18.7, 17.12, 16.16, 15.20, and 14.25, specifically affecting the optimization logic for min and max aggregate functions. This flaw is classified as a type confusion vulnerability, which arises from an incorrect assumption made by the database engine regarding data types during query execution planning. The root cause lies in how the planner handles user-defined aggregates that utilize the SORTOP option to define sorting behavior. When such an aggregate is defined with input and result types that differ, the optimizer incorrectly treats them as identical for certain optimization passes. This misalignment between the declared type system and the internal representation used during execution planning creates a dangerous discrepancy in memory handling and object instantiation.

The operational impact of this vulnerability is severe, allowing any authenticated user who can create or modify aggregates to execute arbitrary code with the privileges of the operating system account running the PostgreSQL process. By crafting a malicious aggregate definition that exploits the type confusion, an attacker can trigger undefined behavior within the database engine. This typically manifests as memory corruption, such as buffer overflows or use-after-free conditions, which can be leveraged to inject and execute shellcode. Since databases often run with elevated privileges to access files or network resources on behalf of applications, successful exploitation grants the attacker full control over the underlying host system.

From a classification perspective, this vulnerability aligns closely with CWE-843, Accessing Memory with Error Pointer Value, as it involves incorrect handling of data types leading to memory safety violations. It also maps to ATT&CK technique T1068, Exploitation for Privilege Escalation, because the initial foothold is gained through a lower-privileged database user who then escalates privileges to the system level via code execution. The vulnerability highlights the risks associated with allowing users to define complex custom aggregates without sufficient validation of type consistency in the query planner's optimization routines.

Mitigation requires immediate patching to one of the fixed versions listed above, as there is no effective workaround that does not involve disabling user-defined aggregate creation or restricting access to superuser privileges for such operations. Organizations should prioritize updating their PostgreSQL instances and verify that all custom aggregates are reviewed against this vulnerability pattern. Additionally, implementing strict input validation on any dynamic SQL generation involving aggregate definitions can help prevent exploitation in environments where patching is delayed. Regular security audits of database configurations and continuous monitoring for anomalous query patterns related to aggregate creation can provide additional layers of defense against such exploits.

Responsible

PostgreSQL

Reservation

10/26/2026

Disclosure

11/12/2026

Moderation

accepted

CPE

ready

EPSS

0.00000

KEV

no

Activities

very low

Sources

Want to stay up to date on a daily basis?

Enable the mail alert feature now!