EEF-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.

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 ecto to a version that resolves this vulnerability.

    Fixed in 3.14.3
  3. Configuration

    Disable the query cache for affected queries by using Repo.all(query, query_cache: false).

    Ecto Repo queries query_cache = false
  4. Compensating control

    Restrict JSON keys and list lengths to a known set before building queries, and pass JSON paths as query parameters rather than interpolating request-controlled path elements.

Event History

Nov 4, 2026
CVE Published
via OSV·01:57 PM
Data Sourced
via OSV·01:57 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which applications are exposed to remote exploitation?

Applications using affected Ecto versions are exposed when unauthenticated request input can control JSON path keys or list lengths that are interpolated into json_extract_path/2, field[^key], or splice/1. Each distinct key or list length can create a separate cached query entry.

2

Does exploiting this require authentication or user interaction?

No. The issue is described as exploitable by an unauthenticated remote attacker, with no user interaction required, when the application exposes the affected interpolation patterns to request-controlled input.

3

What additional impact occurs when ecto_sql is in use?

With ecto_sql, each newly cached query also becomes a prepared statement on the database connection that executes it. This can exhaust memory in both the application and the database server.

4

How can operators recognize that they may be under attack or already affected?

Look for sustained growth in the repository's ETS prepared-query cache and, when using ecto_sql, growth in prepared statements on database connections. Entries created through these distinct query shapes are not released until the relevant processes restart.

5

What can be done if an immediate upgrade is not possible?

Restarting the affected processes releases the accumulated cache entries and prepared statements, but it does not prevent recurrence. Reducing or removing request-controlled interpolation into the affected JSON-path and splice constructs is necessary to stop new distinct cache entries from being created.

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