12-year PostgreSQL bug lets attackers seize databases, servers

A 12-year-old PostgreSQL flaw lets accounts with Replication privileges load arbitrary plugins via logical decoding, enabling remote code execution, superuser escalation and persistent backdoors.

Researchers at Cyera reported a vulnerability in PostgreSQL, tracked as CVE-2026-6471 and nicknamed PostGREShell, that allows accounts with Replication privileges to load arbitrary plugins. The flaw can lead to remote code execution, escalation to superuser and persistent backdoors. Cyera assigned a CVSS score of 7.2.

The bug affects PostgreSQL releases dating back to 2014. It originates in the replication protocol used for logical decoding, where the database accepts an output plugin name provided by external tools. Accounts with the Replication attribute are commonly used by backup tools, pipelines and monitoring utilities.

When a tool requests logical decoding it names an output plugin that PostgreSQL loads and runs with the server process privileges. Non-superuser accounts are meant to be restricted to an admin-controlled plugin directory, but Cyera found that PostgreSQL passes the plugin name to the loader without validation or sanitization. An attacker can supply a full filesystem path and bypass directory checks.

The loader call uses dlopen(), the standard function for dynamically loading shared libraries. Cyera reported that the replication protocol parser accepts slashes, backslashes, dots, directory traversal sequences and even Windows UNC paths inside a quoted plugin name, then hands the path to dlopen(). Code loaded this way runs inside PostgreSQL’s process with access to internal APIs and no sandboxing.

Once arbitrary code runs as the postgres system user it can call internal functions to become the session bootstrap superuser and write directly to pg_authid, the catalog table that records superuser status. That change grants persistent superuser privileges, allowing access to any table, execution of operating-system commands, reading of private keys and writing of files wherever the postgres process has access.

Cyera demonstrated that a malicious plugin can install persistence measures: enabling passwordless logins, copying itself to a stable location, registering to be reloaded in new backends and reapplying superuser changes if they are reverted.

The firm confirmed the issue on PostgreSQL 18.2 and reported that every version from 9.4 through 18 is affected. PostgreSQL maintainers released patches in versions 18.6, 17.11, 16.15, 15.19 and 14.24. Administrators are advised to upgrade to those or later releases immediately.

Cyera recommended auditing accounts with the Replication attribute and removing that privilege from any account that does not require it. Organizations should inspect server file systems and the pg_authid catalog for unauthorized changes and review backup and monitoring tools that hold replication credentials.

Cyera wrote: “PostGREShell turns the Replication credential nobody worries about into code execution, superuser, and a persistent backdoor on the database behind much of the internet.” PostgreSQL is an open source relational database used by tens of thousands of companies, and logical replication is commonly enabled in production environments.

Articles by this author