high

CVE

CVE-2026-124283, CVE-2026-67579

CWE

CWE-502, CWE-89

Affected Surface

  • Hex `ash` 3.31.3 up to but not including 3.38.0 (CVE-2026-124283); fixed in 3.38.0, released 24 November 2026
  • Hex `ash` 1.17.0 up to but not including 3.31.3 (CVE-2026-67579, published 12 August 2026)
  • Phoenix, AshJsonApi and AshGraphql applications that pass a client-supplied `page[after]` / `page[before]` or GraphQL `after` / `before` cursor to a read action with `keyset? true`, with `config :ash, :keyset_signing_secret` unset (the default)

TL;DR

Ash is a declarative application framework for Elixir, with about 2.5 million all-time downloads on Hex and around 72,000 a week. Its keyset pagination hands clients an opaque cursor, which is the Base64 form of :erlang.term_to_binary/1 over the sort values of the last record, and decodes it again when the client asks for the next page. Unless the app sets config :ash, :keyset_signing_secret, nothing authenticates that cursor.

That design has now produced two CVEs from the Erlang Ecosystem Foundation’s CNA:

  • CVE-2026-67579 (published 12 August 2026, CVSS 4.0 7.5, found by Jisung Chae). Ash 1.17.0 to 3.31.2 decoded a forged %Ash.Query.Call{} expression from the cursor and spliced it into the filter. On AshPostgres that meant SQL injection; on the ETS and Simple data layers, an in-process function call.
  • CVE-2026-124283 (published 24 November 2026, CVSS 4.0 8.9, found by Jonatan Männchen of the EEF). The 3.31.3 fix rejected decoded terms that are expressions, but its check doesn’t look inside other structs. Wrapping the payload in an %Ash.CiString{} or a map gets it past the check and into AshPostgres. There, a chain of structs from ecto and db_connection makes the app call a function named in the cursor, which reaches OS command execution, and an %Ash.Query.Function.Fragment{} becomes raw SQL in the WHERE clause.

Ash 3.38.0, released on 24 November, stops decoding Erlang terms from unsigned cursors altogether and encodes them as JSON. There is no 3.37.x backport.

What to do now:

  1. Upgrade ash to 3.38.0.
  2. If you can’t upgrade today and are on 3.37.0 or later, set config :ash, keyset_signing_secret to a long random value in runtime config. Ash then rejects every cursor it didn’t sign before decoding it. Existing cursors become invalid.
  3. If you are below 3.31.3, you are exposed to CVE-2026-67579 as well, regardless of sort field types. Upgrade.

Affected packages and projects

EcosystemPackageAffected versionsFixed version
Hexash3.31.3 to 3.37.x (CVE-2026-124283)3.38.0
Hexash1.17.0 to 3.31.2 (CVE-2026-67579)3.31.3 (incomplete), 3.38.0

CVE-2026-124283 needs all of these:

  • a read action with pagination keyset?: true
  • a client-supplied value passed as the :after or :before page option, which AshJsonApi does for page[after] and page[before] and AshGraphql does for keyset and Relay after / before arguments
  • a sort that includes a field of type :ci_string, :map, :struct or :term
  • config :ash, :keyset_signing_secret unset, which is the default

The EEF demonstrated both results with the AshPostgres data layer, and the code execution with ecto 3.14.3 and db_connection 2.10.2 loaded. Both are standard dependencies of AshPostgres. The CVSS vector is 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. The CNA scored the attack vector as local, but the cursor arrives as an ordinary query parameter, so treat any internet-facing API with keyset pagination as reachable without authentication. FIRST’s EPSS model gave CVE-2026-67579 a score of 0.0061 on 23 November; CVE-2026-124283 had no score yet.

Technical analysis

1. The 3.31.3 decoder

This is decode_values/3 in lib/ash/page/keyset.ex as shipped in 3.37.7:

defp verify(bytes, nil), do: {:ok, bytes}

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
end

defp check_no_expression(term) do
  if Ash.Expr.expr?(term) do
    :error
  else
    :ok
  end
end

With no signing key, verify/2 passes the bytes straight through. binary_to_term/2 with [:safe] refuses funs and atoms that don’t already exist, but any map with a __struct__ key built from existing atoms decodes fine, and in a running Phoenix app every module name of every loaded dependency is an existing atom. So the client picks the struct module of every value in the cursor.

CVE-2026-67579 sent an %Ash.Query.Call{} directly; 3.31.3 added check_no_expression/1 to stop it. The EEF’s analysis shows why that isn’t enough: Ash.Expr.expr?/1 returns true for expression structs and recurses into lists, tuples and plain maps, but for any other struct it returns false without looking at the fields. Anything nested inside a non-expression struct passes.

2. Four sort types accept a struct

cast_values/3 then casts each value with Ash.Type.cast_input/3 against the sort field’s type. Strict types like :integer reject a struct. Four built-in types don’t:

  • Ash.Type.CiString.cast_input/2 returns any %Ash.CiString{} unchanged, and its string field can hold any term.
  • Ash.Type.Map and Ash.Type.Struct accept any map, which includes every struct.
  • Ash.Type.Term accepts anything.

do_filters/4 places the value on the right side of the keyset comparison, and the read goes to the data layer.

3. Two outcomes on AshPostgres

SQL injection. ash_sql compiles the string field of an %Ash.CiString{} as a nested expression. An %Ash.Query.Function.Fragment{} with raw: arguments in that field is written into the WHERE clause as literal SQL, which runs with the app’s database privileges. Because all four types accept an %Ash.CiString{}, this works for any of them.

Code execution. A struct inside a map, or inside a tuple in an %Ash.CiString{}, becomes a query parameter that can’t be encoded. On that failure the read calls inspect/1 on the value before returning the error, and inspect/1 runs the Inspect implementation of each struct module in it. The EEF chain is:

  1. %Ecto.Query.DynamicExpr{} whose binding field holds a %DBConnection.Stream{}. Its Inspect implementation calls Enum.map/2 on the binding.
  2. Enumerable for DBConnection.Stream calls DBConnection.reduce/3.
  3. DBConnection.reduce/3 applies the :log module, function and arguments from the stream’s opts, which the cursor supplies.
  4. An OTP standard library function that applies a further MFA makes the final call fully attacker-controlled, including OS commands as the BEAM user.

The request itself returns an “invalid filter value” error, so the app looks like it rejected a bad cursor while the payload has already run.

4. The 3.38.0 fix

Commit 8da3fe5 (“encode unsigned keysets as JSON instead of ETF”) splits decoding by whether a secret is configured:

result =
  if signing_key do
    decode_signed_term(values, signing_key)
  else
    decode_json(values)
  end

# JSON can only decode to plain data, so this never produces a struct, function
# or atom
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

Without a secret, Ash dumps each sort value with Ash.Type.dump_to_embedded/3, encodes the list as JSON, and on the way back casts each value with Ash.Type.coerce/3, the same path a client-supplied filter takes. If a value doesn’t survive that round trip unchanged, the record gets no keyset, and a keyset page read raises an ArgumentError telling you to make the type round-trip or set the signing secret. With a secret, Ash still uses Erlang terms but only decodes them after the HMAC verifies, so every term it decodes came from the app.

Two side effects matter when you deploy it. Unsigned cursors issued by older versions are Erlang terms, not JSON, so they now fail as invalid keysets, and clients holding one will need to start pagination over. Apps that sort keyset reads on a custom type without a JSON round trip will see that ArgumentError until they set keyset_signing_secret.

IOCs

There is no malware or network infrastructure here. Exploitation leaves its traces in request logs. Forged cursors are longer than normal ones and, once Base64-decoded, contain module names that never belong in sort values:

  • Elixir.Ecto.Query.DynamicExpr
  • Elixir.DBConnection.Stream
  • Elixir.Ash.Query.Function.Fragment
  • Elixir.Ash.Query.Call (CVE-2026-67579)

A burst of Ash.Error.Page.InvalidKeyset or “invalid filter value” errors on keyset endpoints is also worth a look. No public exploit or in-the-wild use had been reported as of 24 November 2026.

Detection and remediation

Check the version you run and whether you’re in the vulnerable configuration:

grep -E '"ash":' mix.lock
grep -rn 'keyset?' lib/ | grep -v '#'
grep -rn 'keyset_signing_secret' config/

List the attribute types your keyset-paginated resources can sort on, and look for :ci_string, :map, :struct, :term or their modules (Ash.Type.CiString, Ash.Type.Map, Ash.Type.Struct, Ash.Type.Term):

grep -rnE 'attribute :[a-z_]+, *(:ci_string|:map|:struct|:term|Ash\.Type\.(CiString|Map|Struct|Term))' lib/

Hunt for forged cursors in access logs. This decodes page[after] / page[before] values and prints any that name suspicious modules:

grep -oE 'page(%5B|\[)(after|before)(%5D|\])=[^& ]+' access.log \
  | sed -E 's/.*=//' \
  | python3 -c '
import sys, base64, urllib.parse
bad = (b"DynamicExpr", b"DBConnection.Stream", b"Function.Fragment", b"Query.Call")
for line in sys.stdin:
    v = urllib.parse.unquote(line.strip())
    try:
        raw = base64.b64decode(v + "=" * (-len(v) % 4))
    except Exception:
        continue
    if any(b in raw for b in bad):
        print(v[:120])
'

Remediate:

  1. mix deps.update ash to 3.38.0, then run your pagination tests. Expect old cursors to be rejected.

  2. Set a signing secret anyway, in runtime config so it isn’t compiled into the release:

    # config/runtime.exs
    config :ash, keyset_signing_secret: System.fetch_env!("ASH_KEYSET_SIGNING_SECRET")
  3. If any forged cursor shows up in your logs, treat the host as compromised: rotate the database credentials and every secret the BEAM process could read, and review the database for changes made through the app’s role.

Timeline

  • 12 August 2026: GHSA-3gq3-9xm3-c8v3 and CVE-2026-67579 published. Ash 3.31.3 adds check_no_expression/1 (commit 91874dd).
  • 19 November 2026: The EEF updates the CVE-2026-67579 record.
  • 24 November 2026, 02:29 UTC: GHSA-m5v6-3qwf-6w9r published for CVE-2026-124283, naming commit 91874dd as the introducing commit.
  • 24 November 2026, 02:57 UTC: Ash 3.38.0 published on Hex with fix commit 8da3fe5.
  • 24 November 2026: The EEF CNA publishes CVE-2026-124283.

References

From research to remediation

Check whether this pattern exists in your codebase

Turn this research into a remediation workflow. Use AI-native static analysis to find similar application vulnerabilities and generate review-ready fixes.

References