Ash Framework Forged Cursor RCE, Fixed in 3.38.0 (CVE-2026-124283)
Ash 3.31.3 to 3.37.x lets a forged keyset cursor run OS commands or inject SQL; CVSS 8.9 High, fixed in 3.38.0.
TL;DR
- Ash decodes a client-supplied keyset cursor into Erlang terms, and its expression check never looks inside a struct. A forged cursor carries a struct of the attacker's choosing into the query.
- Ash 3.31.3 through 3.37.7 are affected when a read action enables keyset pagination, sorts on a
:ci_string,:map,:structor:termfield, and no signing secret is set. - The Erlang Ecosystem Foundation rates it CVSS v4.0 8.9 High and published the record on 2026-11-24. No exploitation is known, and the CVE is not in CISA KEV as of 2026-11-24.
- Upgrade to Ash 3.38.0. On 3.37.0 or later, a keyset signing secret also closes the path, but it invalidates every cursor issued before the change.
Am I affected?
All of these conditions must hold for an application to be exposed:
- It resolves the
ashpackage at a version from 3.31.3 to 3.37.7. - A read action declares
keyset?: truein its pagination block, and the application passes the client's:afteror:beforepage option toAsh.read/2. - The action's sort includes a field whose type is
:ci_string,:map,:structor:term. config :ash, :keyset_signing_secretis unset, which is the default.
An application that sets a signing secret is not exposed to this CVE. An application that uses offset pagination, or that never accepts a client-supplied cursor, is also not exposed. The third condition decides whether a forged value survives the type cast, so an integer, date, UUID or string sort field rejects it.
The advisory demonstrated both outcomes against the AshPostgres data layer. Applications on another data layer are not shown to be exploitable, and the advisory does not claim they are.
| Branch | Affected versions | Fixed version |
|---|---|---|
| ash 3.37.x | 3.37.0 through 3.37.7 | 3.38.0 |
| ash 3.31.3 through 3.36.x | 3.31.3 and every later 3.x release before 3.37.0 | 3.38.0 |
| ash 3.31.2 and earlier | Not affected by this CVE; the earlier CVE-2026-67579 was fixed in 3.31.3 | Not applicable |
Ash 3.38.0 was published to Hex on 2026-11-24 and is the current release. Ash recorded 72,101 downloads in the last week and 2,505,214 in total. The decoding path is therefore deployed in a large part of the Elixir web application ecosystem.
The CVE record rates the flaw CVSS v4.0 8.9 High with the vector CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H. It sets the attack vector to local and marks attack requirements as present, while the advisory describes an unauthenticated client that supplies a cursor. Whether that client is remote depends on how the application exposes the read action.
Check the resolved version in the project:
mix deps | grep -E '^\* ash '
grep -n '"ash":' mix.lock
Check the version that a running release loaded:
bin/my_app eval 'Application.load(:ash); IO.puts(Application.spec(:ash, :vsn))'
Check whether a signing secret is set in the running node:
bin/my_app eval 'IO.inspect(Application.get_env(:ash, :keyset_signing_secret))'
A nil result means the secret is unset. Find the read actions that accept a client cursor:
grep -rnE "keyset\?:\s*true" lib/
grep -rnE "page:.*(after|before)" lib/
Find the attribute types that keep a struct alive through the cast:
grep -rnE "attribute +:[a-z_]+, +:(ci_string|term|struct|map)" lib/
How do I fix it?
Upgrade ash to 3.38.0, which replaces the encoding of unsigned keyset cursors with JSON and decodes them to plain data. The release is announced in the GitHub advisory and committed in 8da3fe5.
- Raise the dependency and fetch the new release:
mix deps.update ash
mix deps.get
- Confirm that the project resolves 3.38.0:
mix deps | grep -E '^\* ash '
- Rebuild and restart the release. A running BEAM node keeps the old module until it restarts, and a container must be rebuilt and recreated, not only pulled.
The upgrade changes the cursor format for applications without a signing secret. Cursors issued before the upgrade are rejected, so clients that are paginating must start again from the first page. Plan the deploy for a low-traffic moment, or set a signing secret first and keep signed cursors valid across the upgrade.
If the upgrade cannot happen now, the available workaround depends on the installed minor version:
- On 3.37.0 or later, set
config :ash, :keyset_signing_secret, "<random string>"and restart the application. Ash then verifies an HMAC on every cursor and rejects a forged one before it decodes it. Every cursor issued before the change becomes invalid. - On 3.31.3 through 3.36.x, no configuration closes the path. Either upgrade, or stop accepting a client-supplied
:afteror:beforevalue on read actions that sort on a:ci_string,:map,:structor:termfield. - On every branch, remove the permissive sort types from actions that take a client cursor where the application does not need them. A sort on an integer, date, UUID or string field rejects the forged struct at the cast.
The workaround does not repair the decoding path. The supported fix is the upgrade.
What is the root cause?
A keyset cursor is an Erlang term that the client sends back, and Ash decodes it with :erlang.binary_to_term/2 before it validates the value. The validation that was added for the earlier cursor injection, CVE-2026-67579, checks whether the decoded term is an Ash expression. That check never inspects the fields of a struct.
The decoding is in lib/ash/page/keyset.ex at tag v3.37.7, lines 204 to 219:
defp decode_values(values, key, signing_key) do
max_byte_size =
if signing_key do
:infinity
else
Application.get_env(:ash, :max_keyset_byte_size, @default_max_keyset_byte_size)
end
with {:ok, decoded} <- Base.decode64(values),
{:ok, message} <- verify(decoded, signing_key),
:ok <- check_keyset_size(message, max_byte_size),
term <- non_executable_binary_to_term(message, [:safe]),
:ok <- check_no_expression(term) do
{:ok, term}
else
_ ->
{:error, Ash.Error.Page.InvalidKeyset.exception(value: values, key: key)}
end
verify/2 returns the decoded bytes unchanged when no signing key is configured. The decoder is Ash.Helpers.non_executable_binary_to_term/2, which calls binary_to_term/2 with [:safe] and then walks the result. The walk accepts atoms, numbers, bitstrings, pids, references, lists, tuples and maps, and raises on anything else, so a fun is refused. A struct passes the walk, because a struct is a map and its __struct__ key is an atom.
The expression check is at lines 244 to 250:
defp check_no_expression(term) do
if Ash.Expr.expr?(term) do
:error
else
:ok
end
end
Ash.Expr.expr?/1 is in lib/ash/expr/expr.ex. It recognises a fixed list of expression structs and descends into lists, tuples and plain maps:
def expr?(value)
when is_struct(value, Ash.Query.Not) or is_struct(value, Ash.Query.BooleanExpression) or
is_struct(value, Ash.Query.Call) or is_struct(value, Ash.Query.Ref) or
is_struct(value, Ash.Query.Exists) or
is_struct(value, Ash.Query.Parent) or
is_struct(value, Ash.Query.UpsertConflict) or
is_struct(value, Ash.CustomExpression) or
(is_struct(value) and is_map_key(value, :__predicate__?)) do
true
end
def expr?(value) when is_map(value) and not is_struct(value) do
Enum.any?(value, fn {key, value} ->
expr?(key) || expr?(value)
end)
end
A struct that is not on the list falls through to the last clause and returns false. The is_map clause explicitly excludes structs. A forged cursor can therefore carry any struct from any library loaded in the node, and the fields of that struct are never examined.
The value then reaches the query builder, which casts it against the type of the sort field. That cast is in the same file, and it calls Ash.Type.cast_input/3 for the field type:
defp cast_value(resource, field, value) do
case field_type(resource, field) do
{type, constraints} ->
case Ash.Type.cast_input(type, value, constraints) do
{:ok, casted} -> {:ok, casted}
_ -> :error
end
:error ->
{:ok, value}
end
end
Four built-in types accept a struct here. Ash.Type.CiString.cast_input/2 at lib/ash/type/ci_string.ex line 256 returns an existing %Ash.CiString{} unchanged:
def cast_input(%Ash.CiString{} = value, _), do: {:ok, value}
The string field of that struct can hold any term. :map and :struct accept any map, which includes a struct, and :term accepts anything. A struct inside such a value therefore becomes the right side of the keyset comparison.
The sink is in the AshPostgres data layer. The advisory traces it: when parameter encoding fails, the read passes the value to inspect/1 before it returns the error. Ecto's Inspect implementation for Ecto.Query.DynamicExpr reads the struct's binding field and maps over it, as lib/ecto/query/inspect.ex shows at tag v3.14.3:
defimpl Inspect, for: Ecto.Query.DynamicExpr do
def inspect(%DynamicExpr{binding: binding} = dynamic, opts) do
binding =
Enum.map(binding, fn
{{:^, _, [as]}, bind} when is_atom(as) -> {as, bind}
other -> other
end)
Enum.map/2 calls the Enumerable implementation of the value. %DBConnection.Stream{} implements it in lib/db_connection.ex at tag v2.10.2, and its reduce/3 hands over to DBConnection.reduce/3, which runs the stream's :log entry through apply/3:
defimpl Enumerable, for: DBConnection.Stream do
def count(_), do: {:error, __MODULE__}
def member?(_, _), do: {:error, __MODULE__}
def slice(_), do: {:error, __MODULE__}
def reduce(stream, acc, fun), do: DBConnection.reduce(stream, acc, fun)
end
defp log({mod, fun, args}, entry), do: apply(mod, fun, [entry | args])
The cursor supplies the stream's opts, so the attacker chooses the module, the function and the argument list in the :log entry. The advisory states that one further standard-library function in that chain forwards a module, a function and an argument list of its own, which makes the call fully attacker-controlled.
The same decoded value also serves the SQL injection. An %Ash.Query.Function.Fragment{} placed inside the string field of an %Ash.CiString{} is compiled by ash_sql as raw SQL text, so the fragment lands in the WHERE clause of the generated query.
How is it exploited?
An unauthenticated client sends a base64 cursor that decodes to a list of sort values. One of those values is a struct chosen from the modules the application has loaded. The type cast keeps the struct, the query builder passes it to the data layer, and the data layer hands it to inspect/1.
- Find a read action that uses keyset pagination and sorts on a
:ci_string,:map,:structor:termfield. Such an action acceptspage: [after: cursor]orpage: [before: cursor]. - Read one page and decode the
keysetvalue of a record withBase.decode64!/1and:erlang.binary_to_term/1. The term is a list that holds the sort value and the primary key. - Build an
%Ecto.Query.DynamicExpr{}whosebindingfield holds a%DBConnection.Stream{}. Set the stream'squeryfield to an atom and put a:logentry with a module, a function and an argument list into itsoptsfield. - Replace the sort value with an
%Ash.CiString{}whosestringfield holds that struct, or with another type from the four that accept a struct. - Encode the list with
:erlang.term_to_binary/1, encode it withBase.encode64/1, and send it aspage: [after: cursor]. - The application calls the function named in the
:logentry before the read returns an invalid filter value error.
For the SQL injection, the same position holds an %Ash.Query.Function.Fragment{} with raw: arguments instead. The read succeeds, and the generated statement contains the attacker's text in its WHERE clause.
The advisory publishes these steps as a proof of concept. It does not publish a program that carries them out, and no exploit program is public. The mitigation for the underlying decoding is the same for both outcomes, because the signing secret rejects the cursor before it is decoded.
How does the attack flow?
A forged cursor decodes into a struct that the expression check skips, survives the type cast, and reaches a data-layer function call that the cursor itself names.
page[after]"] --> B["binary_to_term with :safe
builds attacker-chosen struct"] B --> C["Ash.Expr.expr? returns false
struct fields not examined"] C --> D["Type cast keeps the struct
ci_string, map, struct or term"] D --> E["AshPostgres calls inspect/1
on the failed parameter"] E --> F["Inspect maps over binding
DBConnection.Stream reduce"] F --> G["apply/3 runs the module,
function and args from cursor"] G --> H["OS command as the BEAM user,
or raw SQL in the query"]
What can an attacker do?
An attacker who can supply a cursor to an exposed read action runs a function of their choice in the application's BEAM node. That includes operating system commands with the privileges of the BEAM user. The advisory also demonstrates raw SQL being written into the generated query.
- Run operating system commands. The chain ends in
apply/3with a module, a function and arguments chosen by the cursor. The command runs as the account that owns the BEAM process. - Read secrets and data. The process holds the database credentials, the application's configured secrets and the contents of its memory. Every file that the BEAM account can read is exposed.
- Run SQL as the application's database user. The injected text is part of the read statement. It can read tables and call database functions that the application user may use.
These conditions are all required. A read action must enable keyset pagination. The application must pass a client-supplied :after or :before value to it. The sort must include a :ci_string, :map, :struct or :term field. No keyset signing secret may be configured. The data layer must be AshPostgres, which is the configuration the advisory demonstrated. An application that meets only some of these conditions is not shown to be exposed.
Why does the fix work?
The fix stops decoding a client-supplied cursor as an Erlang term when no signing secret is configured. Unsigned keysets are now JSON, and JSON can only produce plain data, so a struct cannot be smuggled through the decoder.
- with {:ok, decoded} <- Base.decode64(values),
- {:ok, message} <- verify(decoded, signing_key),
- :ok <- check_keyset_size(message, max_byte_size),
- term <- non_executable_binary_to_term(message, [:safe]),
- :ok <- check_no_expression(term) do
- {:ok, term}
+ result =
+ if signing_key do
+ decode_signed_term(values, signing_key)
+ else
+ decode_json(values)
+ end
The new unsigned path is small, and it rejects anything that is not a decoded list:
defp decode_json(encoded) do
with :ok <- check_keyset_size(encoded),
{:ok, json} <- Base.decode64(encoded),
{:ok, decoded} when is_list(decoded) <- Jason.decode(json) do
{:ok, :json, decoded}
else
_ -> :error
end
end
Each decoded value is then cast back with Ash.Type.coerce/3, the same coercion that a client-supplied filter value goes through, instead of Ash.Type.cast_input/3. The encoder writes each sort value with Ash.Type.dump_to_embedded/3 and Jason.encode/1, and a record whose value has no JSON form gets no keyset unless a signing secret is configured.
Signed keysets keep the Erlang term format, because a valid HMAC proves that the application produced the cursor. That path still verifies the signature first, and it keeps the expression check and the size check as defense in depth.
The patch covers the decoding path for unsigned cursors in lib/ash/page/keyset.ex, which is the place where a client value is turned into a term. The same release also changes the encoder, so cursors issued by an affected release no longer decode after the upgrade.
How do I check if I was compromised?
No indicators of compromise are published for CVE-2026-124283, and a forged cursor is a normal HTTP request until it executes. Start with the application's error log, where both outcomes leave a trace.
Search for keyset errors on read actions:
grep -Ei "invalid keyset|invalid filter value" /var/log/my_app/error.log
Search the web server log for keyset parameters. A cursor is base64 that begins with g2w, the encoding of an Erlang list term:
grep -Ei "page(%5B|\[)(after|before)(%5D|\])=g2w" /var/log/nginx/access.log
A legitimate cursor also begins with g2w, so a hit is a lead, not proof. Correlate the request with an error from the first search, or with a read action that uses one of the permissive sort types.
Look for processes that the BEAM node started and does not normally start:
ps --ppid "$(pgrep -f beam.smp | head -n1)" -o pid,lstart,args
On a host with auditd, search for process-execution records that name the BEAM executable:
ausearch -m execve -ts recent 2>/dev/null | grep -i "beam.smp"
A hit is a lead. The injected function can start any program, and the request itself may be the only record of the attempt. Review the node's environment and its database credentials if an exposed action sorted on a permissive type. Also review any file that the BEAM user could read.
Timeline
- 2026-08-12: Ash 3.31.3 shipped the expression check that fixed CVE-2026-67579, and that release is the lower bound of the new range.
- 2026-08-12: CVE-2026-67579 was published for the earlier filter-expression injection through a forged keyset cursor.
- 2026-10-22: Ash 3.37.0 added the
keyset_signing_secretoption. - 2026-11-24: The fix commit and the GitHub advisory were published at 02:29 UTC, and the CVE record followed at 02:34 UTC.
- 2026-11-24: Ash 3.38.0 was published to Hex at 02:57 UTC.
FAQ
Does a forged cursor need a valid signature?
No. Ash only verifies a signature when keyset_signing_secret is configured, and the option is unset by default. Without the secret, verify/2 returns the decoded bytes unchanged and the term decoder runs on the client's input.
Is every Ash application affected?
No. The action must use keyset pagination, accept a client-supplied cursor, sort on a :ci_string, :map, :struct or :term field, and run without a signing secret. The advisory demonstrated both outcomes with AshPostgres.
Can I keep client cursors without upgrading?
Yes on 3.37.0 or later, by setting keyset_signing_secret. Ash then rejects an unsigned or modified cursor before decoding it, and every cursor issued before the change stops working. On 3.31.3 through 3.36.x there is no configuration fix, so the choice is to upgrade or to stop accepting client cursors on the permissive sort types.
Does the SQL injection work on every data layer?
The advisory demonstrated the SQL injection and the command execution with AshPostgres. It does not report a result for other data layers, so treat those as unproven rather than safe.
Will 3.38.0 break pagination for my users?
It will invalidate cursors that clients already hold when no signing secret is configured, because unsigned keysets move from the Erlang term format to JSON. Clients restart from the first page, and a sort value without a JSON form needs keyset_signing_secret to keep a keyset at all.
Is there a public exploit?
The advisory includes a six-step proof of concept and no exploit program. No in-the-wild exploitation is reported, and the CVE is not in CISA KEV as of 2026-11-24.
References
- CVE-2026-124283 record, published 2026-11-24 (checked November 24, 2026): https://www.cve.org/CVERecord?id=CVE-2026-124283
- Erlang Ecosystem Foundation CNA record for CVE-2026-124283, published 2026-11-24 (checked November 24, 2026): https://cna.erlef.org/cves/CVE-2026-124283.html
- GitHub advisory GHSA-m5v6-3qwf-6w9r, published 2026-11-24 (checked November 24, 2026): https://github.com/ash-project/ash/security/advisories/GHSA-m5v6-3qwf-6w9r
- Fix commit 8da3fe514975, "fix: encode unsigned keysets as JSON instead of ETF", committed 2026-11-24 (checked November 24, 2026): https://github.com/ash-project/ash/commit/8da3fe514975ac93682f8377c5439baefaf50bad
- Ash 3.38.0 release, published 2026-11-24 (checked November 24, 2026): https://github.com/ash-project/ash/releases/tag/v3.38.0
- Vulnerable keyset decoder at tag v3.37.7 (checked November 24, 2026): https://github.com/ash-project/ash/blob/v3.37.7/lib/ash/page/keyset.ex
- Expression check at tag v3.37.7 (checked November 24, 2026): https://github.com/ash-project/ash/blob/v3.37.7/lib/ash/expr/expr.ex
- CiString type at tag v3.37.7 (checked November 24, 2026): https://github.com/ash-project/ash/blob/v3.37.7/lib/ash/type/ci_string.ex
- Fixed keyset module at tag v3.38.0 (checked November 24, 2026): https://github.com/ash-project/ash/blob/v3.38.0/lib/ash/page/keyset.ex
- CVE-2026-67579 record, published 2026-08-12 (checked November 24, 2026): https://www.cve.org/CVERecord?id=CVE-2026-67579
- Ecto Inspect implementation at tag v3.14.3 (checked November 24, 2026): https://github.com/elixir-ecto/ecto/blob/v3.14.3/lib/ecto/query/inspect.ex
- DBConnection stream and log handling at tag v2.10.2 (checked November 24, 2026): https://github.com/elixir-ecto/db_connection/blob/v2.10.2/lib/db_connection.ex
- Hex package page for ash, download counts on 2026-11-24 (checked November 24, 2026): https://hex.pm/packages/ash
- Ash pagination documentation at tag v3.38.0 (checked November 24, 2026): https://github.com/ash-project/ash/blob/v3.38.0/documentation/topics/advanced/pagination.livemd
- CISA Known Exploited Vulnerabilities catalog, checked for CVE-2026-124283 on 2026-11-24: https://www.cisa.gov/known-exploited-vulnerabilities-catalog
Keep reading
