# PostgreSQL Security Flaw Allows Code Execution via Replication Attribute; Patch Now Available
A recently disclosed vulnerability in the PostgreSQL database system has prompted the project to release critical security updates. The flaw, identified under a specific CVE designation, carries a CVSS score of 7.2 and has been present in the codebase for over a decade — dating back to the introduction of logical decoding in PostgreSQL 9.4, which was released in 2014.
## Understanding the Vulnerability
The security issue lies in how PostgreSQL handles logical decoding output plugins when a user account carries the REPLICATION attribute. Under certain conditions, a replication-enabled account can cause the database server to load and execute arbitrary code under the operating-system user that runs the PostgreSQL backend process.
The root cause traces back to how plugin names are handled during replication slot creation. When a CREATE_REPLICATION_SLOT command is issued, the plugin name is passed directly to the function responsible for loading the corresponding library. Unlike other database operations, the replication path bypasses PostgreSQL’s standard path restriction mechanism, which normally confines non-superusers to a single, administrator-controlled directory. The protocol’s parser is notably permissive, accepting virtually any character within a double-quoted plugin name — including path separators and directory traversal sequences like “../”. This means that an unvalidated, full filesystem path can reach the library loader without being sanitized.
## Affected Versions and Attack Scenarios
Any installation running a PostgreSQL version prior to the latest patched releases is considered vulnerable. The affected branches include:
– PostgreSQL 17 and earlier
– PostgreSQL 16 and earlier
– PostgreSQL 15 and earlier
– PostgreSQL 14 and earlier
The patched versions — 18.6, 17.11, 16.15, 15.19, and 14.24 — contain the fix.
The vulnerability becomes exploitable when the server is configured with wal_level set to logical, a setting commonly used by backup tools, standby servers, change data capture pipelines, and various monitoring systems. Accounts carrying the REPLICATION attribute are also common in these environments, which significantly broadens the attack surface.
An attacker exploiting this flaw on a Windows system can potentially retrieve a malicious library from a remote machine by leveraging Server Message Block (SMB) protocols over port 445, without needing to write anything directly to the target disk. On Linux and macOS systems, similar remote exploitation requires that Network File System (NFS) automounting be enabled. In other environments, the attacker would need a pre-existing method to place a file on the server’s filesystem.
Once the malicious library is loaded, the code executes inside the database backend process with the privileges of the postgres operating-system user. Security researchers demonstrated a proof-of-concept scenario where the loaded plugin modified the role catalog to grant superuser privileges to the replication account and established multiple persistence mechanisms designed to survive server restarts.
## The Fix: A Whitelist Approach
The fix, committed on August 13, introduces a new server parameter called output_plugin_libraries. This parameter functions as a whitelist, specifying which shared libraries are permitted to be loaded as logical decoding output plugins. By default, it is configured to allow only ‘pgoutput’ and ‘test_decoding’ — the two plugins that ship as standard PostgreSQL components.
This design choice reflects a careful balancing act. The development team explicitly considered whether the existing LOAD restriction could simply be applied to the replication path, but decided against it. Applying the standard LOAD restrictions retroactively would have required all third-party output plugins to be installed within the $libdir/plugins directory, potentially breaking existing deployments.
The whitelist approach allows administrators to lock down plugin loading without disrupting configurations that were already working correctly. When an administrator applies the update, any logical decoding operation that references a plugin not listed in output_plugin_libraries will be refused. The server logs will record an error message indicating that the specified library may not be used as an output plugin, and the documentation provides a hint pointing to the relevant configuration setting.
## Steps for Administrators
Organizations running PostgreSQL are urged to take the following remediation steps promptly:
**Identify current plugins in use.** Before applying updates, run the query SELECT DISTINCT plugin FROM pg_replication_slots WHERE plugin IS NOT NULL; to determine which output plugins are actively in use. This query only returns plugins that were successfully used at some point in time, which may not cover all plugins that could potentially be loaded.
**Apply the appropriate patch.** Upgrade to one of the fixed versions: 18.6, 17.11, 16.15, 15.19, or 14.24. Equivalent security packages distributed through managed cloud services and Linux distributions are also available.
**Configure the whitelist.** After updating, add any non-default output plugins to the output_plugin_libraries parameter. The configuration can be reloaded using either pg_ctl reload or by executing SELECT pg_reload_conf(). A full server restart is not necessary for the changes to take effect.
**Account for upgrades during version migration.** When migrating from version 17 or later using pg_upgrade, set the output_plugin_libraries parameter on the new cluster before running the pg_upgrade –check command. The upgrade check will fail if the parameter list does not include the plugins from the old cluster’s replication slots.
## Vendor and Distribution Support
Several major Linux distributions and cloud providers have issued their own security advisories and patches. Amazon RDS provides fixed packages across all five supported branches. Debian and SUSE have also released updated packages, with Debian’s advisory specifically noting that additional configuration changes are required for certain extensions, including the widely used wal2json and decoderbufs packages. Ubuntu addressed the issue through USN-8653-1, which covered versions 22.04, 24.04, and 26.04 LTS.
## Remaining Concerns
While the main vulnerability has been addressed, a gap remains in the fix related to the pg_createsubscriber command. This utility creates replication slots using the pgoutput plugin without first checking whether that plugin name is present in the output_plugin_libraries parameter. As a result, the –dry-run mode of the command succeeds even when the whitelist configuration would prevent actual conversion, potentially leading to confusing failures for administrators who expect the dry-run check to catch the problem.
Additionally, as of early September, the vulnerability was not yet listed in CISA’s Known Exploited Vulnerabilities catalog, and no public proof-of-concept code had been found in public repositories at that time. Despite the absence of active exploitation in the wild, the severity of the flaw and the long window during which it was present make prompt patching essential.
## Interim Mitigation Steps
Until the patch can be applied, administrators can reduce exposure by taking several defensive measures:
– Strip the REPLICATION attribute from any accounts that do not explicitly require it.
– Restrict replication entries in the pg_hba.conf file to known, trusted IP addresses.
– Block outbound SMB traffic on port 445 and NFS traffic on port 2049 from database servers using firewall rules.
– Disable autofs and other automounting services on database servers where they are not necessary.
## Frequently Asked Questions (FAQ)
**What is CVE-2026-6471?**
CVE-2026-6471 is a security vulnerability in PostgreSQL that allows a user account with the REPLICATION attribute to load and execute arbitrary code as the operating-system user running the database server, under specific conditions involving logical decoding.
**Which PostgreSQL versions are affected?**
All versions prior to PostgreSQL 18.6, 17.11, 16.15, 15.19, and 14.24 are affected. The vulnerability has existed since logical decoding was introduced in PostgreSQL 9.4 in 2014.
**What makes this vulnerability dangerous?**
The flaw allows code execution at the operating-system level inside the database backend process, running as the postgres user. An attacker could escalate privileges, modify the role catalog, or establish persistent backdoors that survive server restarts.
**How is the vulnerability exploited?**
Exploitation requires an account with the REPLICATION attribute and a server configured with wal_level set to logical. A malicious plugin name is passed during replication slot creation, bypassing standard path restrictions and loading an arbitrary library from a controlled location.
**What is the output_plugin_libraries parameter?**
It is a new whitelist parameter introduced in the patched releases that restricts which shared libraries can be loaded as logical decoding output plugins. By default, only ‘pgoutput’ and ‘test_decoding’ are permitted.
**Do I need to restart my server after applying the fix?**
No. The output_plugin_libraries parameter can be reloaded dynamically using pg_ctl reload or SELECT pg_reload_conf() without requiring a server restart.
**Are cloud-managed PostgreSQL services affected?**
Amazon RDS has released patches for all five affected branches. Administrators of managed PostgreSQL instances should verify that their service provider has applied the updates.
**What should I do if I use wal2json or decoderbufs?**
These plugins are not included in the default whitelist. After updating, you must explicitly add ‘wal2json’ or ‘decoderbufs’ to the output_plugin_libraries parameter and reload the configuration.
**Is there a known proof of concept?**
As of early September, no public proof-of-concept code was found in public repositories, and the vulnerability was not listed in CISA’s KEV catalog. However, given the severity and the long exposure window, administrators should treat this as urgent.
## Conclusion
The PostgreSQL security team’s response to CVE-2026-6471 demonstrates the importance of proactive defense in database systems that have been in active use for over a decade. The introduction of the output_plugin_libraries whitelist represents a pragmatic solution that balances security hardening with backward compatibility, acknowledging that retrofitting stricter restrictions into a long-standing system can have far-reaching consequences for existing deployments.
The vulnerability highlights a broader lesson about the attack surface introduced by features like logical decoding, which are essential for modern data pipeline architectures but introduce pathways for code execution that were not present in simpler replication models. As change data capture and logical replication become increasingly central to enterprise data strategies, the security implications of plugin loading and library execution must receive the same rigorous scrutiny as query processing and authentication.
Administrators should prioritize patching affected PostgreSQL instances immediately, review their replication slot configurations, and apply the interim mitigation measures in the meantime. The fact that exploitation requires the REPLICATION attribute and logical wal_level does not diminish the urgency — these conditions are common in production environments that rely on replication for high availability, disaster recovery, and real-time data synchronization.
Thank you for reading



