CVE-2026-118391: Unbounded query cache growth from interpolated JSON paths and splice lists in Ecto

Published Nov 4, 2026
·
Updated

Summary

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 jsonextractpath/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 ectosql 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.

Details

1. Cache keys (lib/ecto/query/builder.ex, lib/ecto/query/planner.ex)

escapejsonpath/2 checks interpolated path elements with jsonpathelement!/1, and a whole interpolated path with jsonpath!/1, at runtime and places the resulting strings and integers in the {:jsonextractpath, [], [field, path]} expression instead of in the query parameters. Ecto.Query.Planner builds the cache key from the query expressions, so every distinct path is a distinct key. splice(^list) keeps the values as parameters but expands into one placeholder per element. castandmergeparams/5 marks {:in, } parameters as not cacheable but keeps {:splice, } parameters cacheable, so every distinct list length is a distinct key, and the entry grows with the length.

2. Cache storage (lib/ecto/query/planner.ex, lib/ecto/repo/supervisor.ex)

Ecto.Query.Planner.query/6 stores each new query with :ets.insertnew/2 in the table that Ecto.Repo.Supervisor creates with newquerycache/1, and nothing removes entries. ectosql renders the path into the SQL text, for example WHERE ((i0."meta"#>array['color']::text[]) = $1), and Postgrex prepares a named statement for each new SQL text on the connection that runs it.

3. Effect

Each request with a new key or list length adds memory that is never released, in the BEAM, where the cache is shared by the whole repository, and with ectosql in the database server, where prepared statements are kept per connection. Large keys amplify this: every 1 MB of request data retained about 2 MB in the application and 3 MB in PostgreSQL. The query cache was disabled for values/2 sources after a similar report, but not for these two cases.

Proof of concept

Reproduced on Ecto main (ad8fda5) with ectosql 3.14.0, Postgrex 0.22.4 and PostgreSQL 18.4, on Elixir 1.20.4 and Erlang/OTP 29, with poolsize: 1.

1. Define a handler that filters by a JSON key from the request: Repo.all(from i in Item, where: jsonextractpath(i.meta, ^[key]) == ^value, select: i.id). 2. Send 2,000 requests with the same key. The query cache has 1 entry and the connection 1 prepared statement; PostgreSQL backend memory goes from 2 MB to 3 MB. 3. Send 2,000 more requests with distinct short keys. The cache has 2,001 entries and the connection 2,001 prepared statements; backend memory is 21 MB. 4. Send 200 requests with a distinct 500 KB key each (100 MB in total). BEAM binary memory grows by 191 MB and PostgreSQL backend memory by 289 MB, measured after garbage collecting every process. 5. Repeating a key that was already seen adds nothing. fragment("? IN (?)", i.id, splice(^ids)) with list lengths 1 to 300 adds 300 cache entries, while i.id in ^ids with the same lengths adds 1.

Impact

An unauthenticated client can make the application and its database keep memory from every request that carries a new JSON key or list length, when the application passes it into an interpolated JSON path or splice/1. Nothing frees that memory until the processes restart. In the proof of concept, 200 requests with 100 MB of keys in total left 191 MB in the BEAM and 289 MB in the PostgreSQL backend of one connection. Sustained requests exhaust memory in the application node, the database server, or both.

Workarounds

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, querycache: false), or restrict keys and list lengths to a known set before building the query.

Configurations

The application must pass request data into an interpolated JSON path (jsonextractpath(field, ^path), jsonextractpath(field, [^key]) or field[^key]), or a request-controlled list into splice/1, and run the query through a repository with the default querycache: true.

Solutions

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 querycache: false, so distinct keys and list lengths don't add cache entries.

Other sources

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 jsonextractpath/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 ectosql 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.

— MITRE

Affected Software

1 affected componentFixes available
erlang/ecto>=3.4.0<3.14.3
3.14.3

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade erlang/ecto to a version that resolves this vulnerability.

    Fixed in 3.14.3
  2. Upgrade

    Upgrade elixir-ecto/ecto to a version that resolves this vulnerability.

    Fixed in 3.14.3
  3. Configuration

    Disable caching for affected queries by running them with Repo.all(query, query_cache: false).

    Ecto query execution query_cache = false
  4. Compensating control

    Restrict JSON keys and list lengths to a known set before building queries, especially values interpolated into json_extract_path/2, field[^key], or splice/1.

  5. Operational

    Restart affected application processes and database connections to release memory retained by existing cached queries and prepared statements.

Event History

Nov 4, 2026
CVE Published
via MITRE·01:57 PM
Data Sourced
via MITRE·01:57 PM
RemedyDescriptionWeakness
Data Sourced
via OSV·01:57 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via NVD·02:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which applications are exposed?

Applications using ecto versions 3.4.0 through before 3.14.3 are affected when request-controlled values are interpolated into json_extract_path/2, field[^key], or splice/1. An unauthenticated attacker must be able to send requests that cause distinct JSON keys, JSON paths, or list lengths to reach those query constructions.

2

Are applications affected if they do not interpolate attacker-controlled values into these query features?

The described cache growth requires distinct interpolated JSON path elements or splice/1 list lengths to produce distinct query expressions. The provided information does not indicate that ordinary parameterized query values alone create the vulnerable cache entries.

3

Why can this impact both the application and the database?

Each distinct query expression is retained in Ecto's per-repository ETS query cache without a size limit or eviction. When ecto_sql is used, each cached expression also creates a prepared statement on the database connection that executes it, consuming database-server memory as well.

4

What can be done if patching cannot happen immediately?

Restarting the affected processes releases the retained memory, but it does not prevent the issue from recurring if requests can continue to generate distinct keys, paths, or list lengths. Limit or stop untrusted input from being interpolated into the affected query constructs until an update can be applied.

5

How can teams recognize that they may already be affected?

The condition produces continually accumulating per-repository ETS query-cache entries and, with ecto_sql, accumulating prepared statements on database connections. Memory is not released until the relevant processes restart.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203