Code execution and SQL injection via struct-wrapped values in a forged keyset pagination cursor in Ash
No exploitation in the wild has been reported. Fixed in 3.38.0 and 8da3fe514975ac93682f8377c5439baefaf50bad.
Deserialization 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. 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. This issue affects ash: from 3.31.3 before 3.38.0.
Affected
Vendors, products and packages with version ranges
| Vendor | Product | Versions | Fixed |
|---|---|---|---|
| ash-project | >=3.31.3 <3.38.0, >=91874dd5435bc0ffebd8a254acfa573b39b74520 <8da3fe514975ac93682f8377c5439baefaf50bad | 3.38.0, 8da3fe514975ac93682f8377c5439baefaf50bad |
Timeline
Every event on this vulnerability
Embed
A live severity badge for an advisory, README or ticket