Skip to content
Threat Feed
high advisory

elixir-ecto postgrex: SQL injection in Postgrex.stream (CVE-2026-66838)

The postgrex library contains an SQL injection vulnerability in the :comment option of Postgrex.stream/4 and Ecto.Repo.stream/2, allowing attackers to inject arbitrary SQL clauses into the database statement.

CVE search metadata

CVE search record: CVE-2026-66838. Severity: high. CVSS: 8.2. EPSS: 0.40%. KEV: no. Product: postgrex. Brief: elixir-ecto postgrex: SQL injection in Postgrex.stream (CVE-2026-66838). Brief link: https://feed.craftedsignal.io/briefs/2026-11-cve-2026-66838/

Triage facts

Revision 1
Applicability
postgrex
Evidence
Unknown
Severity
High
Action
Elevated
Sources
2 public sources
Freshness
Revision 1Nov 19, 09:42 UTC
Vulnerabilities
1 CVE
Source quality
A1Likely

Overview

An SQL injection vulnerability exists in the postgrex library due to the improper neutralization of special characters within the :comment option of the Postgrex.stream/4 function. The vulnerability occurs because the library concatenates the comment into the database statement without adequate escaping or validation. Ecto.Repo.stream/2 is also impacted as it exposes this same option. The vulnerability is restricted to the single streamed statement and does not support command chaining. This issue affects postgrex versions from 0.19.3 before 0.22.4.

Impact

An attacker who can influence the :comment value can close the comment delimiter with */ and inject arbitrary SQL clauses. These injected clauses will be executed under the database connection's role.

Recommendation

  • Update the postgrex dependency to version 0.22.4 or later.
  • If patching is not immediately possible, implement a workaround to reject any :comment value containing '*/' or a null byte before passing the value to Postgrex.stream/4 or Ecto.Repo.stream/2. Alternatively, ensure that comments are constructed only from trusted, sanitized sources.

Immediate actions

Inventory all applications utilizing postgrex or Ecto libraries and verify versions in use.

Application Development 2026-11-20

Upgrade postgrex to version 0.22.4 or later for all identified applications.

Application Development 2026-12-01

Threat Hunt

Monitor application database logs for unexpected SQL syntax patterns or anomalies involving unexpected comment delimiters in database queries.

T1059.001 medium medium confidence hunt now

Data: database_query_logs

Mitigations

Implement input validation for the :comment parameter in Postgrex.stream/4 or Ecto.Repo.stream/2 to reject input containing '*/' or null bytes.

immediate Application Development

CVE-2026-66838