# CVE-2026-66838: SQL injection via the :comment option in Postgrex.stream/4

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.9
- **CVSS:** 5.9 (v4.0, CNA) `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`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Attack requirements: Present; Privileges required: None; User interaction: None; Confidentiality impact: High; Integrity impact: Low; Availability impact: None; Confidentiality impact on other systems: None; Integrity impact on other systems: None; Availability impact on other systems: None
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.41% (percentile 27, 2026-11-28)
- **CWE:** CWE-89
- **Published:** 2026-08-07T12:20:02.376Z
- **Modified:** 2026-11-20T06:17:36.523Z

## Who should check

- Anyone running elixir-ecto postgrex \>= 0.19.3, \< 0.22.4
- Anyone running elixir-ecto postgrex \>= 4971a2722fa72f8e1b54a2c403cad4c43916e36d, \< \*

## Description

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.

## Affected and fixed versions

- elixir-ecto postgrex: \>= 0.19.3, \< 0.22.4 (cvelist)
- elixir-ecto postgrex: \>= 4971a2722fa72f8e1b54a2c403cad4c43916e36d, \< \* (cvelist)

## Mitigation

- Upgrade postgrex to 0.22.4 or later.
- Vendor workaround: Reject any :comment value containing \*/ or a null byte before passing it to Postgrex.stream/4 or Ecto.Repo.stream/2. Alternatively, build comments only from trusted values.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2026-66838. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2026-66838.md
Affected: elixir-ecto postgrex >= 0.19.3, < 0.22.4; elixir-ecto postgrex >= 4971a2722fa72f8e1b54a2c403cad4c43916e36d, < *
Fixed in: elixir-ecto postgrex 0.22.4

Steps:
1. Search this machine and project for elixir-ecto postgrex: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2026-66838 being exploited?

There is no confirmed exploitation: CVE-2026-66838 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.41% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2026-66838?

Medium: CVSS 5.9 (v4.0, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2026-66838?

elixir-ecto postgrex \>= 0.19.3, \< 0.22.4; elixir-ecto postgrex \>= 4971a2722fa72f8e1b54a2c403cad4c43916e36d, \< \*.

### Is there a fix for CVE-2026-66838?

Yes. Fixed in elixir-ecto postgrex 0.22.4. Upgrade postgrex to 0.22.4 or later. Vendor workaround: Reject any :comment value containing \*/ or a null byte before passing it to Postgrex.stream/4 or Ecto.Repo.stream/2. Alternatively, build comments only from trusted values.

### How do I check if I'm affected by CVE-2026-66838?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- vendor: <https://github.com/elixir-ecto/ecto/security/advisories/GHSA-3gww-3f36-2388>
- patch: <https://cna.erlef.org/cves/CVE-2026-66838.html>
- patch: <https://osv.dev/vulnerability/EEF-CVE-2026-66838>
- patch: <https://github.com/elixir-ecto/postgrex/commit/4971a2722fa72f8e1b54a2c403cad4c43916e36d>
- patch: <https://github.com/elixir-ecto/postgrex/commit/4011be852c99dc61ddb98cb01aa41e8775a0e3dd>
- patch: <https://github.com/elixir-ecto/postgrex/commit/e1ecba618ddea4cee2556bd6ad9b6285e05f9d3c>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2026-66838>

HTML: <https://flawdb.com/CVE-2026-66838> · JSON: <https://flawdb.com/api/v1/entries/CVE-2026-66838>
