SQL Injection Vulnerability in PostgreSQL 17 and 18 Affecting ALTER SUBSCRIPTION Command
Summary
ALPINE-CVE-2026-6638: SQL injection in PostgreSQL logical replication ALTER SUBSCRIPTION ... Affects postgresql17 versions < 17.10-r0. Fixed in 17.10-r0. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
PostgreSQL is a powerful, open-source object-relational database system known for its robustness, extensibility, and standards compliance. It supports a wide variety of workloads, from single machines to data warehouses or web services with many concurrent users. The vulnerability in question affects the ALTER SUBSCRIPTION command, which is used in logical replication to manage subscriptions to publications. This vulnerability allows unauthorized SQL execution under certain conditions, posing a significant risk to database integrity.
Vulnerability Detail
The vulnerability identified as CVE-2026-6638 is an SQL injection flaw that occurs during the execution of the ALTER SUBSCRIPTION command in PostgreSQL's logical replication feature. This flaw allows a subscriber table creator to execute arbitrary SQL commands using the credentials of the subscription's publication side. The attack is triggered during the next REFRESH PUBLICATION operation, which can lead to unauthorized data manipulation or exposure. The affected versions include PostgreSQL 16, 17, and 18, specifically those prior to versions 18.4, 17.10, and 16.14. Versions before PostgreSQL 16 are not affected.
How To Fix
Minimum fixed version
17.10-r0
This is the first release that contains the fix.
sudo apk add --upgrade postgresql17
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, consider restricting access to the ALTER SUBSCRIPTION command to trusted users only. This can help mitigate the risk of exploitation until the package is updated. Additionally, review and audit the permissions granted to users who can create subscriber tables.
Conclusion
The SQL injection vulnerability CVE-2026-6638 in PostgreSQL poses a significant risk to database integrity through unauthorized SQL execution. It is crucial to update to the latest patched versions of PostgreSQL to mitigate this risk. Users should also consider implementing access restrictions as a temporary workaround.
See every vulnerability recorded for postgresql17 →
FAQ
CVE-2026-6638 is an SQL injection vulnerability in PostgreSQL's ALTER SUBSCRIPTION command that allows unauthorized SQL execution.
PostgreSQL versions 16, 17, and 18 are affected, specifically those before versions 18.4, 17.10, and 16.14.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
The CVSS score for this vulnerability is 3.7, indicating a moderate level of severity.
If immediate upgrading is not possible, restrict access to the ALTER SUBSCRIPTION command and review user permissions as a temporary measure.
References
Related vulnerabilities
Recent vulnerabilities recorded for postgresql17.