Skip to main content

Postgrex CVE-2026-66838

| EUVDEUVD-2026-54476 MEDIUM
SQL Injection (CWE-89)
2026-08-07 EEF
5.9
CVSS 4.0 · Vendor: EEF
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Identify application forwarding external input to :comment in Postgrex.stream/4
  2. Delivery
    Craft value containing */ to close SQL comment delimiter
  3. Exploit
    Append UNION or clause payload to injected string
  4. Execution
    Postgrex concatenates unsanitized comment into Parse message
  5. Persist
    PostgreSQL executes injected clause under connection role
  6. Impact
    Attacker reads sensitive rows from response stream

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Parameterized queries, prepared statements
MITRE ATT&CK

2 techniques across 2 tactics: Initial Access, Persistence

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Exploitation requires that the application passes an externally influenced string as the :comment keyword option to Postgrex.stream/4 or Ecto.Repo.stream/2. The :comment option is optional and not enabled by default; applications that do not use it, or that supply only hard-coded developer strings, are not exploitable. The injected SQL is confined to a single streamed statement - no statement chaining is possible due to PostgreSQL Parse message semantics - limiting attainable impact to UNION-based data exfiltration or WHERE/RETURNING clause manipulation within that one query, bounded by the database connection role's privileges. A specific application architecture must be present: the streaming API in active use, the comment value reachable by external influence, and the Postgrex version in the affected range (0.19.3 to 0.22.3). Applications using only Postgrex.query/4 or other non-streaming execution paths are not affected regardless of version.

Impact

The CVSS 4.0 score of 5.9 (Medium) is consistent with the realistic threat model. AV:L indicates the attacker must control an application-internal value - the :comment argument - rather than send a crafted network packet directly to the database. AT:P (attack requirements present) is the most important constraint: two simultaneous conditions must hold - the application must invoke the streaming API, and the :comment value must be derived from externally influenced input - an unusual architectural pattern absent from most Ecto applications. PR:N reflects that no database-level credentials are required from the attacker, though this must not be misread as network-unauthenticated exploitation; local or application-layer influence over the comment value is still necessary. Confidentiality impact is High: successful injection could return arbitrary rows accessible to the connection role. Integrity impact is Low and bounded by the single-statement constraint. No KEV listing and no public proof-of-concept have been identified, confirming this as a real but low-immediacy risk - the attack surface is narrow and the preconditions are uncommon. EPSS data is not available in the provided intelligence. There is no conflict between the CVSS signal and the description.

Exploit ScenarioDerived

A developer instruments their Ecto streaming queries by passing a per-request trace identifier as the :comment option - for example, forwarding an HTTP header value directly to Ecto.Repo.stream/2 for log correlation. An attacker supplies the header value */ UNION SELECT username, password_hash FROM users --, which Postgrex appends verbatim to the Parse message, closing the intended SQL comment and appending the UNION clause. The injected query executes under the application's database connection role, returning credential data that the attacker can observe in the application's response stream. No independent public proof-of-concept exists beyond the patch commit's test case, which demonstrates the exact injection pattern.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.2% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Aug 07, 2026

SQL injection in Postgrex (elixir-ecto's PostgreSQL driver) versions 0.19.3 through 0.22.3 allows an attacker who controls the :comment option passed to Postgrex.stream/4 or Ecto.Repo.stream/2 to close the SQL comment delimiter with */ and inject arbitrary SQL clauses into the streamed statement, executing them under the existing database connection's role. The root cause is a missing call to the comment_not_present!/1 guard in stream/4, an oversight absent from every other execution path in the library. No public exploit code has been identified and no active exploitation appears in the CISA KEV catalog; the CVSS 4.0 vector (AV:L, AT:P) signals that exploitation requires specific, non-default application architecture.

RemediationAI

Upgrade Postgrex to version 0.22.4 or later, which adds the missing comment_not_present!/1 call to the stream/4 code path; the fix is confirmed in upstream commits https://github.com/elixir-ecto/postgrex/commit/e1ecba618ddea4cee2556bd6ad9b6285e05f9d3c and https://github.com/elixir-ecto/postgrex/commit/4011be852c99dc61ddb98cb01aa41e8775a0e3dd. If an immediate upgrade is not feasible, audit all call sites of Postgrex.stream/4 and Ecto.Repo.stream/2 and ensure the :comment option value is always a hard-coded developer string - never derived from user-supplied input, request parameters, tenant identifiers, or any other external source; this eliminates the injection surface without patching. As a secondary application-layer control, strip or reject any occurrence of */ in comment values before they reach the API, though this is less reliable than the upstream fix since new call sites may be added without following the convention.

Affected VersionsENISA

postgrex 4971a2722fa72f8e1b54a2c403cad4c43916e36d <*
postgrex 0.19.3 <0.22.4

Affected Packages

euvd postgrex fix: 0.22.4

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in euvd

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

Postgrex is the primary PostgreSQL driver for the Elixir ecosystem, used directly and as the backing adapter for Ecto (the widely-used Elixir data mapping and query layer). The :comment option exists to embed tracing or diagnostic metadata into the SQL comment prepended to each statement. Postgrex implements this by string-concatenating the caller-supplied comment into the statement text sent in the PostgreSQL wire-protocol Parse message. Every other execution entry point (query, execute, prepare, etc.) calls the internal comment_not_present!/1 validator, which raises an error if the comment string contains the */ delimiter-closing sequence or null bytes. The stream/4 function - and by extension Ecto.Repo.stream/2 - never invoked this guard, leaving the code path unprotected. CWE-89 (Improper Neutralization of Special Elements in SQL Commands) applies directly: user-supplied data reaches the SQL layer without sanitization. Critically, PostgreSQL's Parse message accepts exactly one command, so the injected clauses are constrained to modifying the single streamed statement (e.g., appending UNION, WHERE, or RETURNING clauses) - multi-statement chaining is architecturally prevented. Affected CPE: cpe:2.3:a:elixir-ecto:postgrex:*:*:*:*:*:*:*:* from 0.19.3 to 0.22.3.

Know when Postgrex gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (EEF) PRIMARY 5.9 MEDIUM
CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N
vuln.today AI 5.7 MEDIUM

AV:L because attacker must control an application-internal argument; AC:H for the dual precondition of streaming API use and externally influenced comment; C:H for full data access within connection role scope.

3.1 AV:L/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
4.0 AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N

Primary rating from Vendor (EEF).

CVSS VectorVendor: EEF

Attack Vector
Local
Attack Complexity
Low
Attack Requirements
Present
Privileges Required
None
User Interaction
None
Vulnerable system: Confidentiality
High
Vulnerable system: Integrity
Low
Vulnerable system: Availability
None
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

DescriptionCVE.org

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') vulnerability in elixir-ecto postgrex allows SQL Injection via the :comment option of Postgrex.stream/4. An attacker who can influence that value can close the comment delimiter with */ and extend the streamed statement with their own clauses, which execute under the connection's role. Ecto exposes the same option through Ecto.Repo.stream/2.

Postgrex appends the comment by concatenating it into the statement text sent in the Parse message, without escaping or rejecting */. The option is validated by comment_not_present!/1 at every other execution point; stream/4 never calls it. Because Parse accepts a single command, the injection is confined to the streamed statement and further statements cannot be chained.

This issue affects postgrex: from 0.19.3 before 0.22.4.

Threat Intelligence Overview

EPSS Score
0.2%
Top 94% exploitable
Prevalence
Low
Elixir/Ecto ecosystem library, niche relative to mainstream language stacks
Social Media
1
Sightings
Data Quality
7 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment CIRCL GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.2%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation
Poc
System Exposure· derived
Small
Automatable
No
Human Impact· derived
Medium
Technical Impact
Partial

Priority Score

30
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +30
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

SQL injection exploits the way applications construct database queries by mixing user input directly into SQL statements.

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy