Description
SQL Injection vulnerability in elixir-ecto postgrex allows an attacker who can influence a LISTEN channel name to inject SQL into the reconnect replay query, causing a denial of service of the notification connection.

Postgrex.Notifications sanitizes channel names with quote_channel/1, which doubles double quotes so the name is safe inside a double-quoted identifier. This protects the single-statement LISTEN and UNLISTEN paths. On every (re)connect, however, handle_connect/1 replays all registered channels at once by concatenating their LISTEN statements and wrapping them in a dollar-quoted anonymous code block (DO $$BEGIN ... END$$). quote_channel/1 does not escape the $$ dollar-quote delimiter that opens and closes this block.

The listen/3 guards only reject null bytes and names longer than 63 bytes, so a channel name containing $$ passes validation unchanged. Once such a name is embedded, its $$ prematurely terminates the outer dollar-quoted string and PostgreSQL parses the remainder as additional top-level statements. Because handle_connect/1 runs on every (re)connect, the malformed replay query is rejected each time and the notification connection never re-establishes its subscriptions, silently dropping notifications for every channel sharing that connection.

An application is affected when it passes untrusted input (for example a tenant or user identifier) as a channel name to Postgrex.Notifications.listen/3. The double-quote doubling prevents forming a fully valid injected statement, so arbitrary SQL execution is not possible, but the corrupted query reliably breaks the shared notification connection for all tenants, resulting in denial of service.

This issue affects postgrex: from 0.16.0 before 0.22.3.
Published: 2026-07-10
Score: 2.1 Low
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

A flaw in the way Postgrex.Notifications builds reconnection queries allows an attacker who can influence a LISTEN channel name to insert unescaped dollar-quote delimiters. The injected delimiters terminate the outer DO $$ block, causing PostgreSQL to parse the remainder as unrelated statements and to reject the replayed LISTEN commands. Because the vulnerable path cannot inject arbitrary SQL, the immediate visible effect is that the shared notification connection never re‑establishes its subscriptions, silently dropping all notifications for channels sharing that connection. The weakness is a classic SQL injection scenario (CWE‑89) that, in this context, manifests as a denial of service rather than data exfiltration or code execution.

Affected Systems

The vulnerability affects the elixir‑ecto Postgrex library, specifically versions from 0.16.0 up to but not including 0.22.3. Any application using Postgrex.Notifications.listen/3 with untrusted input for the channel name is susceptible.

Risk and Exploitability

The CVSS base score is 2.1, indicating low severity, and the EPSS score is unavailable. The issue is not listed in the CISA KEV catalog. The likely attack vector is application‑controlled input; an attacker controlling a tenant or user identifier that is passed untrusted to listen/3 can trigger the denial of service. Once triggered, the problem persists on every reconnect until the problematic channel name is removed or the code is patched. The risk to confidentiality or integrity is low, but the availability impact can be significant for workflows relying on notifications.

Generated by OpenCVE AI on July 11, 2026 at 11:13 UTC.

Remediation

Vendor Workaround

Validate channel names before passing untrusted input to Postgrex.Notifications.listen/3. Reject any name that contains the dollar-quote delimiter ($$), or restrict channel names to a safe character set such as alphanumeric characters and underscores.


OpenCVE Recommended Actions

  • Update Postgrex to version 0.22.3 or later, which includes the escape of the dollar‑quote delimiter in reconnect replay queries.
  • Validate or sanitize channel names before calling Postgrex.Notifications.listen/3; reject names that contain the dollar‑quote delimiter ($$) or limit names to alphanumeric characters and underscores.
  • Restart or redeploy the application after applying the patch or introducing validation to re‑establish all notification subscriptions.

Generated by OpenCVE AI on July 11, 2026 at 11:13 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

Fri, 10 Jul 2026 12:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Fri, 10 Jul 2026 11:15:00 +0000

Type Values Removed Values Added
Description SQL Injection vulnerability in elixir-ecto postgrex allows an attacker who can influence a LISTEN channel name to inject SQL into the reconnect replay query, causing a denial of service of the notification connection. Postgrex.Notifications sanitizes channel names with quote_channel/1, which doubles double quotes so the name is safe inside a double-quoted identifier. This protects the single-statement LISTEN and UNLISTEN paths. On every (re)connect, however, handle_connect/1 replays all registered channels at once by concatenating their LISTEN statements and wrapping them in a dollar-quoted anonymous code block (DO $$BEGIN ... END$$). quote_channel/1 does not escape the $$ dollar-quote delimiter that opens and closes this block. The listen/3 guards only reject null bytes and names longer than 63 bytes, so a channel name containing $$ passes validation unchanged. Once such a name is embedded, its $$ prematurely terminates the outer dollar-quoted string and PostgreSQL parses the remainder as additional top-level statements. Because handle_connect/1 runs on every (re)connect, the malformed replay query is rejected each time and the notification connection never re-establishes its subscriptions, silently dropping notifications for every channel sharing that connection. An application is affected when it passes untrusted input (for example a tenant or user identifier) as a channel name to Postgrex.Notifications.listen/3. The double-quote doubling prevents forming a fully valid injected statement, so arbitrary SQL execution is not possible, but the corrupted query reliably breaks the shared notification connection for all tenants, resulting in denial of service. This issue affects postgrex: from 0.16.0 before 0.22.3.
Title SQL injection via unescaped dollar-quote in Postgrex.Notifications reconnect replay causes notification denial of service
First Time appeared Elixir-ecto
Elixir-ecto postgrex
Weaknesses CWE-89
CPEs cpe:2.3:a:elixir-ecto:postgrex:*:*:*:*:*:*:*:*
Vendors & Products Elixir-ecto
Elixir-ecto postgrex
References
Metrics cvssV4_0

{'score': 2.1, 'vector': 'CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N'}


Subscriptions

Elixir-ecto Postgrex
cve-icon MITRE

Status: PUBLISHED

Assigner: EEF

Published:

Updated: 2026-07-10T12:50:40.297Z

Reserved: 2026-06-29T18:54:08.633Z

Link: CVE-2026-58225

cve-icon Vulnrichment

Updated: 2026-07-10T11:47:03.399Z

cve-icon NVD

No data.

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-07-11T11:15:04Z

Weaknesses
  • CWE-89

    Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')