CVE-2026-124283 in ash
Summary
by MITRE • 11/24/2026
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.
VulDB is the best source for vulnerability data and more expert information about this specific topic.
Analysis
by VulDB Data Team • 11/24/2026
The vulnerability identified in the Ash framework represents a critical deserialization of untrusted data flaw that enables remote code execution and SQL injection by an unauthenticated attacker. The root cause lies within the implementation of keyset pagination, specifically in the ash.Page.Keyset.filter/4 function located in lib/ash/page/keyset.ex. This component is responsible for decoding client-supplied cursor values provided via the page[:after] or page[:before] parameters. These cursors are encoded using Erlang external term format, a serialization method that can represent complex data structures including arbitrary code execution payloads if not handled with strict validation. The framework attempts to mitigate risks by rejecting decoded expressions identified as Ash.Expr.expr?/1; however this check is insufficient because it fails to examine the internal fields of structs contained within the cursor value. Consequently, an attacker can craft a malicious cursor containing a struct that bypasses this superficial validation layer and proceeds through the application logic without triggering rejection mechanisms designed for expression-based attacks.
The technical mechanism allowing exploitation relies on type casting behavior during the processing of sort field values. When each value in the cursor is cast against the data type of its corresponding sort field, the system accepts structs for specific types including :ci_string, :map, :struct, and :term. This permissive acceptance allows an attacker to inject a specially constructed struct into the cursor payload. Because this struct reaches the underlying data layer without proper sanitization or deep inspection, it interacts with database drivers in unintended ways. In environments utilizing AshPostgres as the backend, the read operation passes these unsanitized structs directly to the inspect/1 function. This function invokes the Inspect protocol implementation of the specific struct module selected by the attacker. Through a chain of calls involving modules from ecto and db_connection, this process triggers arbitrary OS command execution on the host system running the application server.
Beyond remote code execution, the vulnerability also facilitates SQL injection attacks through a different vector within the same data flow. When an instance of %Ash.Query.Function.Fragment{} is embedded inside an %Ash.CiString{} value within the malicious cursor, it bypasses standard query parameterization safeguards. Instead of being treated as a literal string or properly escaped input, this fragment structure is written directly into the SQL query as raw text. This allows attackers to inject arbitrary SQL commands that can manipulate database contents, extract sensitive information, or potentially escalate privileges depending on the permissions granted to the application database user. The combination of code execution and SQL injection makes this vulnerability particularly severe, affecting both confidentiality and integrity aspects of system security alongside availability through potential service disruption via command execution side effects.
This issue impacts versions of ash ranging from 3.31.3 up to but not including version 3.38.0. Organizations running affected versions are advised to upgrade immediately to the patched release where these validation checks have been strengthened to properly inspect struct fields and restrict dangerous type casting behaviors in pagination cursors. Until an upgrade is performed, mitigation strategies should include implementing strict input validation at a reverse proxy or API gateway layer to reject requests containing Erlang external term format payloads that do not conform to expected simple scalar types for cursor parameters. Additionally enabling Web Application Firewall rules capable of detecting anomalous serialization patterns in query strings can provide temporary protection against exploitation attempts while the infrastructure is being updated.
From a classification perspective, this vulnerability aligns with CWE-502 Deserialization of Untrusted Data due to the unsafe handling of serialized input that leads to arbitrary code execution. It also relates closely to CWE-89 SQL Injection given the mechanism by which raw text fragments are inserted into database queries without proper escaping or parameterization. In terms of adversary tactics, this exploit maps to ATT&CK technique T1059 Command and Scripting Interpreter for remote code execution via deserialization artifacts and T1190 Exploit Public-Facing Application as it targets a publicly accessible pagination endpoint with no authentication requirement. The lack of authentication required makes this vulnerability especially dangerous in production environments where automated scanners or opportunistic attackers can easily discover and exploit the flaw without prior access credentials.