CVE-2026-58225: CWE-89 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') in elixir-ecto postgrex
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.
AI Analysis
Technical Summary
The vulnerability in elixir-ecto postgrex involves improper neutralization of special elements used in SQL commands (CWE-89). Specifically, the quote_channel/1 function doubles double quotes to sanitize channel names for single-statement LISTEN and UNLISTEN commands, but it does not escape the $$ dollar-quote delimiter used in the reconnect replay query wrapped in a dollar-quoted anonymous code block. An attacker controlling a channel name containing $$ can prematurely terminate the dollar-quoted block, causing PostgreSQL to parse the remainder as additional top-level statements. This malformed query is rejected on every reconnect, preventing notification subscriptions from being re-established and causing a denial of service. The vulnerability affects postgrex versions from 0.16.0 before 0.22.3.
Potential Impact
The impact is a denial of service on the notification connection for all tenants sharing the connection. The malformed reconnect replay query caused by injection of $$ in channel names prevents the notification connection from re-subscribing to channels, silently dropping notifications. Arbitrary SQL execution is not possible due to partial sanitization of channel names.
Mitigation Recommendations
Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until a fix is available, avoid passing untrusted input as channel names to Postgrex.Notifications.listen/3, especially input containing the $$ delimiter. Monitor vendor channels for updates and apply official patches once released.
CVE-2026-58225: CWE-89 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') in elixir-ecto postgrex
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.
CVSS v4.0
Score 2.1low
Affected software
cpe:2.3:a:elixir-ecto:postgrex:*:*:*:*:*:*:*:*Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The vulnerability in elixir-ecto postgrex involves improper neutralization of special elements used in SQL commands (CWE-89). Specifically, the quote_channel/1 function doubles double quotes to sanitize channel names for single-statement LISTEN and UNLISTEN commands, but it does not escape the $$ dollar-quote delimiter used in the reconnect replay query wrapped in a dollar-quoted anonymous code block. An attacker controlling a channel name containing $$ can prematurely terminate the dollar-quoted block, causing PostgreSQL to parse the remainder as additional top-level statements. This malformed query is rejected on every reconnect, preventing notification subscriptions from being re-established and causing a denial of service. The vulnerability affects postgrex versions from 0.16.0 before 0.22.3.
Potential Impact
The impact is a denial of service on the notification connection for all tenants sharing the connection. The malformed reconnect replay query caused by injection of $$ in channel names prevents the notification connection from re-subscribing to channels, silently dropping notifications. Arbitrary SQL execution is not possible due to partial sanitization of channel names.
Mitigation Recommendations
Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until a fix is available, avoid passing untrusted input as channel names to Postgrex.Notifications.listen/3, especially input containing the $$ delimiter. Monitor vendor channels for updates and apply official patches once released.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- EEF
- Date Reserved
- 2026-06-29T18:54:08.633Z
- Cvss Version
- 4.0
- State
- PUBLISHED
- Remediation Level
- null
Threat ID: 6a50d4f468715ace437a1833
Added to database: 07/10/2026, 11:18:12 UTC
Last enriched: 07/10/2026, 11:32:29 UTC
Last updated: 07/10/2026, 12:18:18 UTC
Views: 5
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.