Ecto
Unbounded query cache growth from interpolated JSON paths and splice lists in Ecto
Allocation of Resources Without Limits or Throttling vulnerability in elixir-ecto ecto allows an unauthenticated remote attacker to exhaust memory in the application and in the database server by sending requests with distinct JSON keys or list lengths where the application interpolates them into json_extract_path/2, field[^key] or splice/1. Ecto caches prepared queries per repository in an ETS table with no size limit and no eviction. Interpolated JSON path elements become part of the query expression instead of its parameters, and splice/1 expands into one placeholder per element, so every distinct key or list length creates a new cache entry. With ecto_sql each entry is also a new prepared statement on the database connection that runs it. None of this memory is released until the processes restart. This issue affects ecto: from 3.4.0 before 3.14.3.
Affected versions and mitigation
From the CVE record and the vendor's references.Affected
- >= 3.4.0, < 3.14.3
Fixed in 3.14.3
- >= cb2f03964dac324a9771f84f5088e395326e6de8, < eef014ad090d27d1a5b69c0e32a50eabd44ab3bb
Fixed in eef014ad090d27d1a5b69c0e32a50eabd44ab3bb
Mitigation
Upgrade Ecto to 3.14.3 or later. Queries with interpolated JSON path elements or an interpolated splice/1 list are no longer cached, the same as running them with query_cache: false, so distinct keys and list lengths don't add cache entries.
Workaround
Pass the path as a query parameter so it is not part of the cache key. With PostgreSQL: fragment("? #> ?", i.meta, type(^path, {:array, :string})). Alternatively, disable the cache for these queries with Repo.all(query, query_cache: false), or restrict keys and list lengths to a known set before building the query.
References
Timeline
Days relative to CVE publicationNo public PoC found yet; not in CISA KEV.
PoC repositories
Found on GitHub.No PoC repositories found yet.