CVE-2026-32687: Postgrex SQL Injection Vulnerability
HIGHCVE-2026-32687 is a HIGH sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Postgrex libraries in the Hex ecosystem. The issue involves channel-name sql injection in `postgrex.notifications.listen/3`. Remediation is available by upgrading affected packages to version 0.22.2.
CVE-2026-32687 at a Glance
How to Fix CVE-2026-32687
To remediate this vulnerability, upgrade all affected Postgrex dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade postgrex to 0.22.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for postgrex
How to Check if You Are Affected
To determine whether your application is affected by CVE-2026-32687, inspect your project dependencies for Postgrex:
inspect dependencies for postgrex
Analyze the terminal output to locate any version of Postgrex in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.22.2), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Postgrex, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-32687 Affected Postgrex Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
postgrex
|
Hex |
≥ 0.16.0
< 0.22.2
|
0.22.2
|
References
Frequently Asked Questions
What is CVE-2026-32687?
Which Postgrex versions are affected?
What version fixes CVE-2026-32687?
Is postgrex affected?
What CWE is associated with CVE-2026-32687?
How can I check Hex dependencies for CVE-2026-32687?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-r73h-97w8-m54h",
"modified" : "2026-05-18T17:53:17Z",
"published" : "2026-05-18T17:53:17Z",
"aliases" : [ "CVE-2026-32687" ],
"summary" : "Postgrex: Channel-name SQL injection in `Postgrex.Notifications.listen/3`",
"details" : "### Summary\n\nSQL 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.\n\nOnly 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.\n\n### Details\n\nPostgreSQL 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.\n\nThe 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.\n\n### Impact\n\nSQL 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.\n\n### Fix\n\nUpgrade 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):\n\n```elixir\nif String.contains?(channel_name, [\"\\\"\", \"\\0\"]) do\n raise \"bad channel name\"\nend\n```",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Hex",
"name" : "postgrex"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.16.0"
}, {
"fixed" : "0.22.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/elixir-ecto/ecto/security/advisories/GHSA-r73h-97w8-m54h"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-32687"
}, {
"type" : "WEB",
"url" : "https://github.com/elixir-ecto/postgrex/commit/7cdedbd4316bb65f82e6a9a4f922c0ac491cb770"
}, {
"type" : "WEB",
"url" : "https://cna.erlef.org/cves/CVE-2026-32687.html"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/elixir-ecto/ecto"
}, {
"type" : "WEB",
"url" : "https://osv.dev/vulnerability/EEF-CVE-2026-32687"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-89" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-05-18T17:53:17Z",
"nvd_published_at" : "2026-05-12T15:16:12Z"
}
}