CVE-2026-32687: SQL injection via channel name in Postgrex.Notifications.listen/3 and unlisten/3

Published May 12, 2026
·
Updated

Summary

SQL injection in Postgrex.Notifications.listen/3: the channel argument is interpolated straight into LISTEN "..." / UNLISTEN "..." without escaping the " character. Any caller that lets a user influence the channel name (e.g. a pub/sub bridge that uses a tenant id or topic slug as the channel) and the name is not sanitized can execute arbitrary SQL on the notifications connection.

Only those using the Postgrex.Notifications directly or via a dependency, with a non-sanitized channel name are vulnerable. Ecto does not use Postgrex.Notifications by default, but you must validate if any other dependency does.

Details

PostgreSQL escapes a " inside a quoted identifier by doubling it to "". Postgrex doesn't do that doubling, so a " inside channel closes the identifier early and everything after it is parsed as SQL on the same connection.

The notifications connection runs as whatever DB role the app is configured with. Unlike the Postgrex.query/4 API, there's no extended-protocol guard here: LISTEN/UNLISTEN are sent as simple queries, so multi-statement payloads work and the attacker can chain ; CREATE TABLE …, ; DROP …, ; CREATE ROLE …, etc.

Impact

SQL injection on the notifications connection. Affects any application that calls Postgrex.Notifications.listen/3 (or unlisten/3) with a channel name derived from untrusted input. Executes as the configured DB user with no protocol-level limit on what can be chained, so the realistic blast radius is read/modify/destroy on any data the app's DB role can reach.

Fix

Upgrade to latest Postgrex v0.22.2 or later. Altenratively, sanitize any user input given as channel name by making sure it doesn't include quotes as well as null bytes (not strictly required, but recommended):

elixir if String.contains?(channelname, ["\"", "\0"]) do raise "bad channel name" end

Other sources

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') vulnerability in elixir-ecto postgrex ('Elixir.Postgrex.Notifications' module) allows SQL Injection.

The channel argument passed to 'Elixir.Postgrex.Notifications':listen/3 and 'Elixir.Postgrex.Notifications':unlisten/3 is interpolated directly into LISTEN "..." / UNLISTEN "..." SQL statements without escaping the " character. An attacker who can influence the channel name can inject a " to break out of the quoted identifier and append arbitrary SQL. Because the notifications connection uses the PostgreSQL simple query protocol, multi-statement payloads are accepted, allowing DDL and DML commands to be chained (e.g. ; DROP TABLE ...; --). The same unsanitized interpolation also occurs in handleconnect/1 when replaying LISTEN commands after a reconnect.

This vulnerability is associated with program file lib/postgrex/notifications.ex and program routines 'Elixir.Postgrex.Notifications':listen/3, 'Elixir.Postgrex.Notifications':unlisten/3, 'Elixir.Postgrex.Notifications':handleconnect/1.

This issue affects postgrex: from 0.16.0 before 0.22.2, from pkg:github/elixir-ecto/postgrex@266b530faf9bde094e31e0e4ab851f933fadc0f5 before 0.22.2.

NVD

Affected Software

4 affected componentsFixes available
hex/postgrex>=0.16.0<0.22.2
github/elixir-ecto/postgrex>=266b530faf9bde094e31e0e4ab851f933fadc0f5<0.22.2
erlang/postgrex>=0.16.0<0.22.2
0.22.2
elixir-ecto Postgrex>=0.16.0<0.22.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade erlang/postgrex to a version that resolves this vulnerability.

    Fixed in 0.22.2
  2. Upgrade

    Upgrade elixir-ecto/postgrex to a version that resolves this vulnerability.

    Fixed in 0.22.2
  3. Configuration

    Before calling Postgrex.Notifications.listen/3 or unlisten/3, validate the channel name derived from untrusted input. Reject/raise if String.contains?(channel_name, ['"', '\0']) (i.e., ensure the channel name does not include quotes (") and null bytes (\0)).

    Elixir.Postgrex.Notifications listen/unlisten channel name validation = reject if channel contains '"' or '\0'

Event History

May 12, 2026
CVE Published
via MITRE·02:18 PM
Data Sourced
via MITRE·02:18 PM
DescriptionWeakness
Data Sourced
via NVD·03:16 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·03:16 PM
RemedyAffected Software
May 18, 2026
Advisory Published
via GitHub·05:53 PM
Data Sourced
via GitHub·05:53 PM
DescriptionWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-32687?

CVE-2026-32687 is classified as a high-severity SQL injection vulnerability.

2

How do I fix CVE-2026-32687?

To fix CVE-2026-32687, upgrade Postgrex to version 0.22.2 or later.

3

Which versions of Postgrex are affected by CVE-2026-32687?

CVE-2026-32687 affects Postgrex versions between 0.16.0 and 0.22.2.

4

What can be exploited in CVE-2026-32687?

CVE-2026-32687 can be exploited via SQL injection through improper handling of the channel name argument.

5

Is CVE-2026-32687 part of Elixir.Ecto's functionality?

Yes, CVE-2026-32687 specifically affects the Elixir.Postgrex.Notifications module within Elixir.Ecto.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203