{"id":"CVE-2026-124283","aliases":["EEF-CVE-2026-124283","GHSA-m5v6-3qwf-6w9r"],"title":"Code execution and SQL injection via struct-wrapped values in a forged keyset pagination cursor in Ash","titleSource":"EEF","descriptionSource":"OSV","description":"## Summary\n\nDeserialization of Untrusted Data vulnerability in ash-project ash allows an unauthenticated attacker to execute arbitrary code or inject SQL through a forged keyset pagination cursor.\n\n`Ash.Page.Keyset.filter/4` in `lib/ash/page/keyset.ex` decodes the client-supplied `page[:after]` or `page[:before]` cursor from Erlang external term format and rejects decoded expressions with `Ash.Expr.expr?/1`. That check does not examine the fields of a struct. The cast of each value against the type of its sort field accepts structs for the `:ci_string`, `:map`, `:struct` and `:term` types. A struct in the cursor value for such a sort field therefore reaches the data layer. With AshPostgres, the read passes such a struct to `inspect/1`, which runs the `Inspect` implementation of the struct module that the attacker selected. A chain of struct modules from `ecto` and `db_connection` then calls a function that the cursor names, which permits OS command execution. An `%Ash.Query.Function.Fragment{}` inside an `%Ash.CiString{}` value is written into the SQL query as raw text.\n\nThis issue affects ash: from 3.31.3 before 3.38.0.\n\n## Details\n\n**1. Cursor decoding**\n\nA keyset cursor is the Base64 form of `:erlang.term_to_binary/1` over the list of sort values of one record. `decode_values/3` in `lib/ash/page/keyset.ex` decodes a client-supplied cursor with `Ash.Helpers.non_executable_binary_to_term/2` and `[:safe]`. This refuses functions and new atoms. It accepts a map with a `__struct__` key, so the client selects the struct module of each decoded value. When `keyset_signing_secret` is unset, Ash does not authenticate the cursor.\n\n**2. Expression check**\n\n`check_no_expression/1` calls `Ash.Expr.expr?/1` on the decoded term. `Ash.Expr.expr?/1` in `lib/ash/expr/expr.ex` returns `true` for expression structs and descends into lists, tuples and maps that are not structs. For a struct that is not an expression it returns `false` and does not examine the fields. Such a struct passes the check, and so does any value inside it.\n\n**3. Type cast**\n\n`cast_values/3` casts each decoded value with `Ash.Type.cast_input/3` against the type of its sort field. Strict types such as `:integer` reject a struct. Four built-in types accept one. `Ash.Type.CiString.cast_input/2` returns any `%Ash.CiString{}` unchanged, and its `string` field can hold any term. `Ash.Type.Map.cast_input/2` and `Ash.Type.Struct.cast_input/2` accept any map, which includes any struct. `Ash.Type.Term.cast_input/2` accepts any term.\n\n**4. Query construction**\n\n`do_filters/4` puts the value into the keyset filter as the right side of a comparison with the sort field. In `ash_sql`, the clause of `AshSql.Expr` for an `%Ash.CiString{}` value compiles the `string` field as a nested expression.\n\n**5. Code execution**\n\nA value that holds a struct inside a map, or inside a tuple in an `%Ash.CiString{}`, becomes a query parameter. Parameter encoding fails, and the read passes the value to `inspect/1` before `Ash.read/2` returns. `inspect/1` runs the `Inspect` implementation of each struct module in the value. An `%Ecto.Query.DynamicExpr{}` whose `binding` field holds a `%DBConnection.Stream{}` makes `Inspect` call `Enum.map/2` on the stream. The `Enumerable` implementation of `DBConnection.Stream` calls `DBConnection.reduce/3`, which applies the `:log` module, function and arguments from the `opts` field of the struct. The cursor supplies that field. A function from the OTP standard library that applies a further module, function and argument list makes the call fully attacker-controlled, which includes OS command execution.\n\n**6. SQL injection**\n\nAn `%Ash.CiString{}` whose `string` field holds an `%Ash.Query.Function.Fragment{}` with `raw:` arguments becomes literal SQL text in the `WHERE` clause. This works for each of the four types, because each accepts the `%Ash.CiString{}` struct.\n\n## Proof of concept\n\n1. Define an AshPostgres resource with a `:ci_string` attribute and a read action with `pagination keyset?: true`. Leave `keyset_signing_secret` unset.\n2. Read one page sorted on the `:ci_string` attribute and decode the `keyset` of a record with `Base.decode64!/1` and `:erlang.binary_to_term/1`. The term is a list with the `%Ash.CiString{}` sort value and the primary key.\n3. Build an `%Ecto.Query.DynamicExpr{}` whose `binding` field is a `%DBConnection.Stream{}`. Set the `query` field of the stream to an atom, and put a `:log` entry with a module, function and argument list into its `opts` field.\n4. Replace the first element of the list with an `%Ash.CiString{}` whose `string` field is a one-element tuple that holds the struct from step 3.\n5. Encode the list with `:erlang.term_to_binary/1` and `Base.encode64/1`, and pass the result as `page: [after: cursor]` to the same read.\n6. The read returns an invalid filter value error. Before it returns, the application calls the function from the `:log` entry.\n\nFor the SQL injection, use an `%Ash.Query.Function.Fragment{}` with `raw:` arguments as the `string` field in step 4. The read succeeds, and the query contains the raw text in the `WHERE` clause.\n\n## Impact\n\nAn unauthenticated client that can supply a keyset cursor selects the struct modules of the decoded values. Through protocol implementations in `ecto` and `db_connection`, the client makes the application call a function of its choice, and can execute OS commands with the privileges of the BEAM OS user.\n\nAn unauthenticated client that can supply a keyset cursor adds SQL text to the query of the read action. The text runs with the database privileges of the application.\n\n## Workarounds\n\nOn ash 3.37.0 or later, set `config :ash, keyset_signing_secret` to a long random string. Ash then rejects each cursor that it did not sign, before it decodes the cursor. Cursors issued before the change become invalid.\n\n## Configurations\n\nA read action must declare `keyset? true` in its `pagination` block, and the application must pass a client-supplied value as the `:after` or `:before` page option. The sort must include a field of type `:ci_string`, `:map`, `:struct` or `:term`. `config :ash, :keyset_signing_secret` must be unset, which is the default. Both results were demonstrated with the AshPostgres data layer. The code execution was demonstrated with `ecto` 3.14.3 and `db_connection` 2.10.2 loaded.","severity":"high","score":8.9,"published":"2026-11-24T02:34:31.916Z","modified":"2026-11-25T17:23:02.736Z","withdrawn":false,"knownExploited":false,"affected":[{"ecosystem":"Hex","name":"ash","sources":[{"name":"OSV · EEF-CVE-2026-124283","url":"https://osv.dev/vulnerability/EEF-CVE-2026-124283"}],"ranges":[{"events":[{"introduced":"3.31.3"},{"fixed":"3.38.0"}],"type":"SEMVER"}],"versions":["3.31.3","3.32.0","3.32.1","3.32.2","3.32.3","3.33.0","3.33.1","3.33.10","3.33.11","3.33.2","3.33.3","3.33.4","3.33.5","3.33.6","3.33.7","3.33.8","3.33.9","3.34.0","3.34.1","3.34.2","3.34.3","3.34.4","3.34.5","3.34.6","3.35.0","3.36.0","3.36.1","3.37.0","3.37.1","3.37.2","3.37.3","3.37.4","3.37.5","3.37.6","3.37.7"],"fixed":["3.38.0"]}],"sourceAffected":[{"ranges":[{"events":[{"introduced":"91874dd5435bc0ffebd8a254acfa573b39b74520"},{"fixed":"8da3fe514975ac93682f8377c5439baefaf50bad"}],"type":"GIT","repo":"https://github.com/ash-project/ash"}],"versions":["v3.37.7","v3.37.6","v3.37.5","v3.37.4","v3.37.3","v3.37.2","v3.37.1","v3.37.0","v3.36.1","v3.36.0","v3.35.0","v3.34.6","v3.34.5","v3.34.4","v3.34.3","v3.34.2","v3.34.1","v3.34.0","v3.33.11","v3.33.10","v3.33.9","v3.33.7","v3.33.6","v3.33.5","v3.33.4","v3.33.3","v3.33.2","v3.33.1","v3.32.3","v3.32.2","v3.32.1","v3.31.3"]}],"references":["https://github.com/ash-project/ash/security/advisories/GHSA-m5v6-3qwf-6w9r","https://cna.erlef.org/cves/CVE-2026-124283.html","https://osv.dev/vulnerability/EEF-CVE-2026-124283","https://cna.erlef.org/cves/CVE-2026-67579.html","https://github.com/ash-project/ash/commit/91874dd5435bc0ffebd8a254acfa573b39b74520","https://github.com/ash-project/ash/commit/8da3fe514975ac93682f8377c5439baefaf50bad","https://hex.pm/packages/ash"],"sources":[{"name":"CVE","id":"CVE-2026-124283","modified":"2026-11-24T18:19:09.008Z","url":"https://www.cve.org/CVERecord?id=CVE-2026-124283"},{"name":"OSV","id":"EEF-CVE-2026-124283","modified":"2026-11-25T17:23:02.736365034Z","url":"https://osv.dev/vulnerability/EEF-CVE-2026-124283"}],"assessments":[{"source":"EEF","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","score":8.9},{"source":"OSV","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","score":8.9}],"cve":{"records":[{"id":"CVE-2026-124283","source":"EEF","state":"PUBLISHED","reasons":[],"replacements":[],"disputed":false,"unsupportedWhenAssigned":false,"reserved":"2026-11-23T21:43:54.819Z","published":"2026-11-24T02:34:31.916Z","modified":"2026-11-24T18:19:09.008Z"}],"publishers":[{"name":"EEF","role":"CNA","organizationId":"6b3ad84c-e1a6-4bf7-a703-f496b71e49db","modified":"2026-11-24T04:37:51.717Z"},{"name":"CISA-ADP","role":"ADP","organizationId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","modified":"2026-11-24T18:19:09.008Z"}],"references":[{"url":"https://github.com/ash-project/ash/security/advisories/GHSA-m5v6-3qwf-6w9r","tags":["vendor-advisory","related"],"source":"EEF"},{"url":"https://cna.erlef.org/cves/CVE-2026-124283.html","tags":["related"],"source":"EEF"},{"url":"https://osv.dev/vulnerability/EEF-CVE-2026-124283","tags":["related"],"source":"EEF"},{"url":"https://cna.erlef.org/cves/CVE-2026-67579.html","tags":["related"],"source":"EEF"},{"url":"https://github.com/ash-project/ash/commit/91874dd5435bc0ffebd8a254acfa573b39b74520","tags":["related"],"source":"EEF"},{"url":"https://github.com/ash-project/ash/commit/8da3fe514975ac93682f8377c5439baefaf50bad","tags":["patch"],"source":"EEF"},{"url":"https://github.com/ash-project/ash/security/advisories/GHSA-m5v6-3qwf-6w9r","tags":["exploit"],"source":"CISA-ADP"}],"weaknesses":[{"id":"CWE-89","description":"CWE-89 Improper Neutralization of Special Elements used in an SQL Command","source":"EEF"},{"id":"CWE-502","description":"CWE-502 Deserialization of Untrusted Data","source":"EEF"}],"applicability":[{"source":"EEF","statements":[{"nodes":[{"cpeMatch":[{"criteria":"cpe:2.3:a:ash-project:ash:*:*:*:*:*:*:*:*","versionEndExcluding":"3.38.0","versionStartIncluding":"3.31.3","vulnerable":true}],"negate":false,"operator":"OR"}],"operator":"AND"}]}],"prioritization":[{"source":"CISA-ADP","type":"SSVC","role":"CISA Coordinator","timestamp":"2026-11-24T18:18:42.866795Z","decisions":[{"name":"Exploitation","value":"poc"},{"name":"Automatable","value":"no"},{"name":"Technical Impact","value":"total"}]}]},"products":[{"vendor":"ash-project","name":"ash","platforms":[],"versions":[{"version":"3.31.3","status":"affected","lessThan":"3.38.0","versionType":"semver"}],"defaultStatus":"unaffected","packageURL":"pkg:hex/ash","packageIdentity":{"ecosystem":"Hex","name":"ash"},"cpes":["cpe:2.3:a:ash-project:ash:*:*:*:*:*:*:*:*"],"source":"EEF","url":"https://www.cve.org/CVERecord?id=CVE-2026-124283"},{"vendor":"ash-project","name":"ash","platforms":[],"versions":[{"version":"91874dd5435bc0ffebd8a254acfa573b39b74520","status":"affected","lessThan":"8da3fe514975ac93682f8377c5439baefaf50bad","versionType":"git"}],"defaultStatus":"unaffected","packageURL":"pkg:github/ash-project/ash","cpes":["cpe:2.3:a:ash-project:ash:*:*:*:*:*:*:*:*"],"source":"EEF","url":"https://www.cve.org/CVERecord?id=CVE-2026-124283"}],"remediation":[{"text":"On ash 3.37.0 or later, set config :ash, keyset_signing_secret to a long random string. Ash then rejects each cursor that it did not sign, before it decodes the cursor. Cursors issued before the change become invalid.","source":"EEF","url":"https://www.cve.org/CVERecord?id=CVE-2026-124283"}],"observedAt":"2026-11-25T17:45:43.497Z","kev":{"status":"not-listed","checkedAt":"2026-11-28T22:45:30.745Z"},"coverage":[{"source":"NVD","status":"no-result","checkedAt":"2026-11-24T02:45:32.068Z","attemptedAt":"2026-11-24T02:45:32.068Z"},{"source":"GHSA","status":"no-result","checkedAt":"2026-11-24T02:45:31.605Z","attemptedAt":"2026-11-24T02:45:31.605Z"},{"source":"EUVD","status":"no-result","checkedAt":"2026-11-24T02:45:32.068Z","attemptedAt":"2026-11-24T02:45:32.068Z"},{"source":"EPSS","status":"no-result","checkedAt":"2026-11-24T02:45:32.068Z","attemptedAt":"2026-11-24T02:45:32.068Z"}],"evidence":[],"aiSummary":{"text":"Ash versions from 3.31.3 before 3.38.0 have a Deserialization of Untrusted Data vulnerability, allowing an unauthenticated attacker to execute arbitrary code or inject SQL through a forged keyset pagination cursor. The attacker must have access to the application and be able to supply a keyset cursor.","model":"@cf/meta/llama-3.3-70b-instruct-fp8-fast","generatedAt":"2026-11-25T17:46:04.341Z","sources":[{"name":"CVE","url":"https://www.cve.org/CVERecord?id=CVE-2026-124283"},{"name":"OSV","url":"https://osv.dev/vulnerability/EEF-CVE-2026-124283"}]}}