2.1low
SQL injection via unescaped dollar-quote in Postgrex.Notifications reconnect replay causes notification denial of service
- Severity
- 2.1low CVSS:4.0 by EEF
- Exploit likelihood
- 0.24% (higher than 16% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- EEF
- Also known as
- EEF-CVE-2026-58225GHSA-4mw9-4qgj-m97w
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| postgrex | from 0.16.0 before 0.22.3 | CVE List |
| elixir-ecto/postgrex | from 266b530faf9bde094e31e0e4ab851f933fadc0f5 before * | CVE List |
| postgrex (Hex) | from 0.16.0 before 0.22.3 | Erlang Ecosystem Foundation |
| https://github.com/elixir-ecto/postgrex | from 266b530faf9bde094e31e0e4ab851f933fadc0f5 before 795c6062f62c4394272ff4b89170688857b4f841, before 797d395906c0a1d28bea55e3a2b03ce75c827f55 | Erlang Ecosystem Foundation |
All scores
| EEF | 2.1low CVSS:4.0 | 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 |
| Erlang Ecosystem Foundation | Not scored CVSS:4.0 | 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 |
Classification
SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.
What each source says
CVE List
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.
Erlang Ecosystem Foundation
Summary
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.
Workarounds
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.
NVD (es)
Vulnerabilidad de inyección SQL en elixir-ecto postgrex permite a un atacante que puede influir en el nombre de un canal LISTEN inyectar SQL en la consulta de repetición de reconexión, causando una denegación de servicio de la conexión de notificación. Postgrex.Notifications sanea los nombres de los canales con quote_channel/1, que duplica las comillas dobles para que el nombre sea seguro dentro de un identificador entre comillas dobles. Esto protege las rutas LISTEN y UNLISTEN de una sola declaración. En cada (re)conexión, sin embargo, handle_connect/1 reproduce todos los canales registrados a la vez concatenando sus declaraciones LISTEN y envolviéndolas en un bloque de código anónimo entre comillas de dólar (DO $$BEGIN ... END$$). quote_channel/1 no escapa el delimitador de comillas de dólar $$ que abre y cierra este bloque. Las guardas de listen/3 solo rechazan bytes nulos y nombres de más de 63 bytes, por lo que un nombre de canal que contenga $$ pasa la validación sin cambios. Una vez que dicho nombre está incrustado, su $$ termina prematuramente la cadena externa entre comillas de dólar y PostgreSQL analiza el resto como declaraciones de nivel superior adicionales. Debido a que handle_connect/1 se ejecuta en cada (re)conexión, la consulta de repetición malformada es rechazada cada vez y la conexión de notificación nunca restablece sus suscripciones, descartando silenciosamente las notificaciones para cada canal que comparte esa conexión. Una aplicación se ve afectada cuando pasa una entrada no confiable (por ejemplo, un identificador de inquilino o usuario) como nombre de canal a Postgrex.Notifications.listen/3. La duplicación de comillas dobles impide formar una declaración inyectada completamente válida, por lo que la ejecución arbitraria de SQL no es posible, pero la consulta corrupta rompe de forma fiable la conexión de notificación compartida para todos los inquilinos, lo que resulta en una denegación de servicio. Este problema afecta a postgrex: desde 0.16.0 antes de 0.22.3.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-58225 changed 2026-11-24 | CVE Terms of Use |
| Erlang Ecosystem Foundation | EEF-CVE-2026-58225 changed 2026-11-26 | CC-BY-4.0 |
| NVD | CVE-2026-58225 changed 2026-11-24 | Public domain |