SQL injection via unescaped dollar-quote in Postgrex.Notifications reconnect replay causes notification denial of service
elixir-ecto postgrex
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| elixir-ecto postgrex |
| No fix yet |
| elixir-ecto postgrex |
| No fix yet |
Original 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.