SQL injection in elixir-ecto postgrex
Key facts
- Attack vector
- Local
- Privileges required
- None
- User interaction
- None
- Attack complexity
- Low
- Attack requirements
- Present
- Impact type
- SQL injection
- Confidentiality · integrity · availability
- None · None · Low
- Fix status
- Fixed
Attack profile from CVSS 4.0 · CNA. Fix status from CNA. Impact type from CWE-89.
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.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- Poc
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| elixir-ecto | postgrex | 0.16.0 to before 0.22.3 | 0.22.3 | Patch available | CNA |
- postgrex Vendorelixir-ecto Affected 0.16.0 to before 0.22.3 Fixed in 0.22.3 Patch available CNA
CPE names CNA · 1
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:elixir-ecto:postgrex:*:*:*:*:*:*:*:* | — | — | elixir-ecto |
- cpe:2.3:a:elixir-ecto:postgrex:*:*:*:*:*:*:*:* Versions — — ·elixir-ecto
Remediation
- Fix · CNA postgrex (elixir-ecto) Fixed in 0.22.3
Timeline
- 2026-10-02 Threatist record created from CVE-2026-58225
References
More elixir-ecto vulnerabilities
- TI-2026-47460 SQL injection via the :comment option in Postgrex.stream/4 CVSS 4.0MEDIUM 5.9
- TI-2026-85063 Unbounded query cache growth from interpolated JSON paths and splice lists in Ecto CVSS 4.0HIGH 8.9
- TI-2026-25179 SQL injection via channel name in Postgrex.Notifications.listen/3 and unlisten/3 CVSS 4.0HIGH 7.5
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences