Skip to content

deps: Update dependency ecto to v3.14.3 [SECURITY] - #87

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/hex-ecto-vulnerability
Open

renovate[bot] wants to merge 1 commit into
mainfrom
renovate/hex-ecto-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Type Update Change
ecto (source) prod minor 3.10.1 → 3.14.3

Unbounded query cache growth from interpolated JSON paths and splice lists in Ecto

CVE-2026-118391 / EEF-CVE-2026-118391 / GHSA-cxjx-vmm2-qr8r

More information

Details

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

Details

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

escape_json_path/2 checks interpolated path elements with json_path_element!/1, and a whole interpolated path with json_path!/1, at runtime and places the resulting strings and integers in the {:json_extract_path, [], [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. cast_and_merge_params/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.insert_new/2 in the table that Ecto.Repo.Supervisor creates with new_query_cache/1, and nothing removes entries. ecto_sql 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 ecto_sql 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 ecto_sql 3.14.0, Postgrex 0.22.4 and PostgreSQL 18.4, on Elixir 1.20.4 and Erlang/OTP 29, with pool_size: 1.

  1. Define a handler that filters by a JSON key from the request: Repo.all(from i in Item, where: json_extract_path(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, query_cache: 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 (json_extract_path(field, ^path), json_extract_path(field, [^key]) or field[^key]), or a request-controlled list into splice/1, and run the query through a repository with the default query_cache: 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 query_cache: false, so distinct keys and list lengths don't add cache entries.

Severity

  • CVSS Score: 8.9 / 10 (High)
  • Vector String: CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:H

References

This data is provided by OSV.


Release Notes

elixir-ecto/ecto (ecto)

v3.14.3

Compare Source

Bug fixes
  • [Ecto.Query] Include the prefix of queries given to join in the query cache key
  • [Ecto.Query] Keep hints of queries given to join, as well as the hints given to the join itself
  • [Ecto.Query] Do not cache queries with interpolated JSON paths, splice/1, and constant/1, as each distinct value would create a new query cache entry (CVE-2026-118391)
  • [Ecto.Query] Keep interpolated true filters that a later or_where depends on

v3.14.2

Compare Source

Enhancements
  • [Ecto.Schema] Allow configuring :writable and :on_writable_violation for the :inserted_at field generated by timestamps/1
Bug fixes
  • [Ecto.Changeset] Fix changed?/3 for removed one-to-one relations
  • [Ecto.Changeset] Fix stale belongs_to keys in apply_changes/1
  • [Ecto.Changeset] Preserve prepare_changes callbacks in merge/2
  • [Ecto.Changeset] Preserve the default :on_cast function in relation type metadata
  • [Ecto.Query] Fix source field caching for map updates
  • [Ecto.Repo] Propagate the caller's Logger level to preload tasks
  • [Ecto.Repo] Enforce writable fields after prepare_changes callbacks
  • [Ecto.Schema] Fix autogeneration options for composite types
  • [Ecto.Schema] Avoid compile-time dependencies on modules named in @derive
  • [Ecto.Type] Normalize DateTime casts to UTC (note: reverted in the next release)

v3.14.1

Compare Source

Enhancements
  • [Ecto.Schema] Allow embedded_schema to have non-virtual :any fields
  • [Ecto.Schema] Add :on_writable_violation option for fields (a default can be specified with @on_writable_violation)
  • [Ecto.UUID] Add helper functions for UUIDv7
Bug fixes
  • [Ecto.Query] Warn on parentheses in query field access
  • [Ecto.Query] Expand macros in window frames
  • [Ecto.Query] Fix data-modifying CTE planner cache traversal
  • [Ecto.Query] Fix splice parameters in dynamic expressions
  • [Ecto.Query] Fix subquery order in query builders
  • [Ecto.Query] Fix wrong placeholder numbering when a from source is a {fragment, schema} tuple
  • [Ecto.Repo] Do not reflect changes ignored due to :writable in returned struct
  • [Ecto.Repo] Fix placeholder type mismatch check on insert_all with placeholders

v3.14.0

Compare Source

Enhancements
  • [Ecto.Adapter] Accept a counter option in prepare_query/3
  • [Ecto.Changeset] Add Ecto.Changeset.reorder_assoc/2
  • [Ecto.Query] Allow from and joins with {fragment, Schema} source
  • [Ecto.Repo] Raise an error on query-like keyword opts to Repo functions
  • [Ecto.Repo] Support :replace_changed on upserts to enable HOT updates in PostgreSQL
  • [Ecto.Repo] Add :query_cache option to selectively bypass query cache
  • [Ecto.Schema] Add :on_join_through_conflict option for
  • [Ecto.Type] Add Ecto.Type.trim/2 and allow developers to configure how values are trimmed on cast with the :trim_values option
  • [Ecto.UUID] Support UUIDv7
  • [mix.exs] Require decimal v3
  • [mix ecto.create] Set timezone by default when creating new databases
Bug fixes
  • [Ecto.Repo] Correctly extract passwords with colons from URL
  • [Ecto.Repo] Redact repo config from SASL progress reports
  • [Ecto.Repo] Preload custom queries with order_by now take precedence over :preload_order. The :preload_order option is now only applied when no custom query with ordering is provided.

v3.13.6

Compare Source

Enhancements
  • [mix.exs] Relax decimal requirement

v3.13.5

Compare Source

Enhancements
  • [Ecto.Query] Support selecting a subset of a subquery as a struct

v3.13.4

Compare Source

Bug fixes
  • [Ecto.Changeset] Ensure empty binaries are trimmed
  • [Ecto.Repo] Ensure rollback applies to dynamic repos
  • [Ecto.Type] Properly format :in composite types

v3.13.3

Compare Source

Enhancements
  • [Ecto.Query] Accept a list of things to exclude in exclude
Bug fixes
  • [Ecto.Query] Allow 2-arity functions as preload function in query
  • [Ecto.Query] Remove soft deprecated literal warning
  • [Ecto.Schema] Do not consider space and newlines as empty for binary types

v3.13.2

Compare Source

Bug fixes
  • [Ecto.Query] Fix regression which made queries with multiple joins expensive to compile
  • [Ecto.Repo] Fix detection of missing primary key on associations with only nil entries
  • [Ecto.Query] Fix macro expansion in over clause's order_by

v3.13.1

Compare Source

Bug fixes
  • [Ecto.Repo] Do not automatically apply HOT updates on upsert with replace. It is the user responsibility to make sure they do not overlap

v3.13.0

Compare Source

Requires Elixir v1.14+.

Enhancements
  • [Ecto] Support Elixir's built-in JSON
  • [Ecto.Enum] Add Ecto.Enum.cast_value/3
  • [Ecto.Query] Allow schema to be used for values list types
  • [Ecto.Query] Allow strings in field/2
  • [Ecto.Query] Add identifier/1 in queries
  • [Ecto.Query] Add constant/1 in queries
  • [Ecto.Query] Allow exclude/2 to remove windows
  • [Ecto.Query] Allow source fields in json_extract_path
  • [Ecto.Repo] Add Ecto.Repo.prepare_transaction/2 user callback
  • [Ecto.Repo] Add Ecto.Repo.all_by/3
  • [Ecto.Repo] Add Ecto.Repo.transact/2
  • [Ecto.Repo] Allow HOT updates on upsert queries in Postgres by removing duplicate fields during replace_all_except
  • [Ecto.Schema] Support @schema_redact: :all_except_primary_keys module attribute
Bug fixes
  • [Ecto.Query] Allow select merging maps with all nil values
  • [Ecto.Query] map/2 in queries now always returns a map on joins, even on left joins, for consistency with from sources
  • [Ecto.Schema] Fix an issue where Ecto could warn an association did not exist, when it did
Soft deprecations (no warnings emitted)
  • [Ecto.Repo] Ecto.Repo.transaction/2 is soft-deprecated in favor of Ecto.Repo.transact/1
  • [Ecto.Query.API] literal/1 is deprecated in favor of identifier/1

v3.12.6

Compare Source

Fix deprecations on Elixir v1.19.

v3.12.5

Compare Source

Bug fixes
  • [Ecto.Query] Raise when empty list is given to values/2
  • [Ecto.Query] Fix inspecting dynamic/2 with interpolated named bindings
  • [Ecto.Query] Plan sources before creating plan_subquery closure
  • [Ecto.Repo] Remove read-only changes from returned record during insert/update
  • [Ecto.Repo] Cascade :allow_stale options to assocs

v3.12.4

Compare Source

Enhancements
  • [Ecto.Repo] Document new :pool_count option
Bug fixes
  • [Ecto.Repo] Make Ecto.Repo.reload respect source

v3.12.3

Compare Source

Bug fixes
  • [Ecto.Changeset] Allow associations to be cast/put inside of embedded schema changesets

v3.12.2

Compare Source

Bug fixes
  • [Ecto.Query] Allow :prefix to be set to any term
  • [Ecto.Repo] Avoid overwriting ssl opts from url if already set in config

v3.12.1

Compare Source

Enhancements
  • [Ecto.Type] Add Ecto.Type.parameterized?/2
Bug fixes
  • [Ecto.Enum] Fix dialyzer specification
  • [Ecto.Query] Remove incorrect subquery parameter check

v3.12.0

Compare Source

Enhancements
  • [Ecto.Changeset] Allow {message, opts} to be given as message for several validation APIs
  • [Ecto.Query] Introduce is_named_binding guard
  • [Ecto.Query] Subqueries are now supported in distinct, group_by, order_by and window expressions
  • [Ecto.Query] Allow select_merge to be used in more insert_all and subquery operations by merging distinct fields
  • [Ecto.Query] Allow literal maps inside dynamic/2
  • [Ecto.Query] Support macro expansion at the root level of order_by
  • [Ecto.Query] Support preloading subquery sources in from and join
  • [Ecto.Query] Allow map updates with dynamic values in select
  • [Ecto.Query] Allow any data structure that implements the Enumerable protocol on the right side of in
  • [Ecto.Repo] Support 2-arity preload functions that receive ids and the association metadata
  • [Ecto.Repo] Allow HOT updates on upsert queries in Postgres by removing duplicate fields during replace_all
  • [Ecto.Repo] insert_all supports queries with only source
  • [Ecto.Repo] insert_all supports queries with the update syntax
  • [Ecto.Repo] Support :allow_stale on Repo struct/changeset operations
  • [Ecto.Schema] Allow schema fields to be read-only via :writable option
  • [Ecto.Schema] Add :defaults_to_struct option to embeds_one
  • [Ecto.Schema] Support :duration type which maps to Elixir v1.17 duration
  • [Ecto.Type] Bubble up custom cast errors of the inner type for {:map, type} and {:array, type}
  • [Ecto.Type] Add Ecto.Type.cast!/2
Bug fixes
  • [Ecto.Query] Ignore query prefix in CTE sources
  • [Ecto.Query] Fix a bug of preload when a through association is used in a join and has a nested separate query preload. Now the association chain is no longer preloaded and we simply preload directly onto the loaded through association.
  • [Ecto.Query] Fix inspection when select has map/struct modifiers
  • [Ecto.Query] Disable query cache for values lists
  • [Ecto.Repo] Convert fields to their sources in insert_all
  • [Ecto.Repo] Raise if empty list is given to {:replace, fields}
  • [Ecto.Repo] Validate :prefix is a string/binary, warn otherwise
  • [Ecto.Repo] Remove compile dependency on :preload_order MFA in has_many
Adapter changes
  • distinct, group_by, order_by and window expressions use the new Ecto.Query.ByExpr
    struct rather than the old Ecto.Query.QueryExpr struct
Potential incompatibilities
  • [Ecto.Changeset] Associations inside embeds have always been read-only. We now raise if you try to cast them inside a changeset (this was reverted in v3.12.3)
  • [Ecto.ParameterizedType] Parameterized types are now represented internally as {:parameterized, {mod, state}}. While this representation is private, projects may have been relying on it, and therefore they need to adapt accordingly. Use Ecto.ParameterizedType.init/2 to instantiate parameterized types.
  • [Ecto.Query] Drop :array_join join type. It was added for Clickhouse support but it is no longer used
  • [Ecto.Query] Validate :prefix is a string/binary (this was reverted in v3.12.2)

v3.11.2

Compare Source

Bug fixes
  • [Ecto.Query] Fix compatibility with upcoming Elixir v1.17
  • [Ecto.Repo] Do not hide failures when preloading if the parent process is trapping exits

v3.11.1

Compare Source

Enhancements
  • [Ecto.Query] Allow module attributes to be given to in operator
Bug fixes
  • [Ecto.Query] Fix interpolating strings and atoms as map keys
  • [Ecto.Query] Plan subqueries in having
  • [Ecto.Query] Fix late binding with composite types

v3.11.0

Compare Source

Enhancements
  • [Ecto.Association] Allow preload_order to take MFAs for many_to_many associations. This allows ordering by the join table
  • [Ecto.Query] Add :operation option to with_cte/3. This allows CTEs to perform updates and deletes
  • [Ecto.Query] Support splice(^...) in fragment
  • [Ecto.Query] Add prepend_order_by/3
  • [Ecto.Query] Allow selected_as/1 and selected_as/2 to take interpolated names
  • [Ecto.Query] Allow map update syntax to work with nil values in select
  • [Ecto.Query] Allow hints to inject SQL using unsafe_fragment
  • [Ecto.Query] Support values/2 lists
  • [Ecto.Repo] Add :on_preload_spawn option to preload/3
  • [Ecto.Schema] Support :load_in_query option for embeds
  • [Ecto.Schema] Support :returning option for delete
Bug fixes
  • [Ecto.Association] Ensure parent prefix is passed to on_delete queries
  • [Ecto.Changeset] Ensure duplicate primary keys are always detected for embeds
  • [Ecto.Embedded] Raise ArgumentError when specifying an autogenerated :id primary key
  • [Ecto.Query] Ensure subquery selects generate unique cache keys
  • [Ecto.Query] Raise on literal non-base binary/uuids in query
  • [Ecto.Repo] Reset belongs_to association if foreign key update results in a mismatch
Adapter changes
  • Adapters now receive nil for encoding/decoding
  • Adapters now receive type instead of {:maybe, type} as the first argument to loaders/2
Deprecations
  • [Ecto.Query] Keyword hints are no longer supported. Please use unsafe_fragment inside of hints instead

v3.10.3

Compare Source

Enhancements
  • [Ecto.Query] Allow dynamic field/2 in type/2
Bug fixes
  • [Ecto.Changesets] Limit the largest integer to less than 32 digits
  • [Ecto.Type] Limit the largest integer to less than 32 digits

v3.10.2

Compare Source

Enhancements
  • [Ecto.Changeset] Support a three-arity function with position on cast_assoc and cast_embed
  • [Ecto.Changeset] Add support for maps in validate_length/3
  • [Ecto.Changeset] Add :nulls_distinct option to unsafe_validate_unique
  • [Ecto.Query] Support array_join type for ClickHouse adapter
  • [Ecto.Query.API] Support parameterized and custom map types in json path validation
Bug fixes
  • [Ecto.Repo] Respect parent prefix in Repo.aggregate
  • [Ecto.Query.API] Fix late binding in json_extract_path
Deprecations
  • Deprecate MFAs on :with

Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate
renovate Bot requested a review from a team as a code owner December 2, 2026 08:24
@renovate
renovate Bot requested review from khvn26 and removed request for a team December 2, 2026 08:24
@codspeed

codspeed Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing renovate/hex-ecto-vulnerability (ecc65de) with main (4c73902)

Open in CodSpeed

@renovate
renovate Bot force-pushed the renovate/hex-ecto-vulnerability branch from a3ebdb4 to ecc65de Compare December 3, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants