12-Year-Old PostgreSQL Vulnerability Enables Database, Server Takeover

In a recent report, cybersecurity firm Cyera has unveiled a significant vulnerability affecting PostgreSQL, a widely-used open-source relational database system. This flaw, tracked as CVE-2026-6471, has been present in releases since 2014 and poses a serious risk, allowing attackers with minimal privileges to potentially seize control of databases and servers.

Understanding the Vulnerability

PostgreSQL supports both relational (SQL) and non-relational (JSON) queries, making it a popular choice among enterprises and developers alike. The vulnerability, dubbed PostGREShell, carries a CVSS score of 7.2 and can be exploited for remote code execution and privilege escalation.

The root of the issue lies in a missing authorization within the database’s logical decoding mechanism. Attackers possessing ‘Replication’ privileges can leverage this flaw to load any file accessible to the operating system account that runs the PostgreSQL server, utilizing the logical decoding plugin.

Cyera elaborates that PostgreSQL employs a dedicated replication protocol to synchronize multiple replicas of a primary database for backup and recovery purposes. Any connected backup tool, server, pipeline, or monitoring utility is typically granted an account with the Replication attribute, which is essential for this process.

Changes made to the database are recorded as table events through local replication, allowing external tools to read them by creating a logical replication slot. This involves naming an output plugin that PostgreSQL loads to format the data stream.

When a plugin is loaded, PostgreSQL executes its initialization function with the privileges of the server process. To mitigate potential abuse, non-superuser accounts are restricted to loading plugins from an admin-controlled directory. However, Cyera discovered a critical oversight: the plugin name is passed directly to the loader without any validation or sanitization.

This oversight permits an attacker to specify a full filesystem path, which is then processed by dlopen(), a C/C++ function responsible for dynamically loading shared libraries. Cyera notes that the replication protocol’s parser is lenient, accepting various characters in double-quoted plugin names, including slashes, backslashes, dots, and even Windows UNC paths.

Exploiting this vulnerability allows an attacker to load and execute arbitrary files through dlopen(), with the execution occurring under the privileges of the postgres system user. As Cyera explains, “Code loaded via dlopen() runs in the same address space as PostgreSQL, with no sandbox and no checks on internal API calls. The server simply trusts any code that was loaded.”

Once the malicious code is executed, it can call internal functions to elevate the attacker’s privileges to that of a superuser, modifying the pg_authid catalog table to grant itself permanent superuser status. This grants the attacker unrestricted access to all tables across every database, the ability to execute operating system commands, read sensitive keys, and write files to any location accessible by the postgres process.

Moreover, the plugin can establish backdoor mechanisms, enabling password-less connections, self-replication to stable locations, and re-registration for loading into new backends, even reinstating superuser privileges if they are revoked.

Cyera emphasizes the severity of this vulnerability, stating, “PostGREShell turns the Replication credential nobody worries about into code execution, superuser, and a persistent backdoor on the database behind much of the internet.” All versions from 9.4 through 18 are affected, with confirmation of the flaw in version 18.2. Given that logical replication has become a standard component in production environments, the vulnerable pathway is likely present in numerous PostgreSQL deployments.

To address this critical issue, CVE-2026-6471 has been patched in PostgreSQL versions 18.6, 17.11, 16.15, 15.19, and 14.24. Organizations are strongly encouraged to update their PostgreSQL instances promptly, conduct audits of their Replication accounts, and remove the Replication attribute from any accounts that do not require it.

Related:

Tech Optimizer
12-Year-Old PostgreSQL Vulnerability Enables Database, Server Takeover