CVE-2026-140867: Aggregates in Ash skip the read policies of the records they read on several query paths, disclosing counts and values of hidden records
Incorrect authorization vulnerability in Ash allows an actor to read counts, sums and attribute values of related records they cannot read via aggregates.
Ash.Actions.Read (lib/ash/actions/read/read.ex) authorized an aggregate in two passes. Ash.Filter.relationshipfilters/7 built a policy filter for each relationship it found an aggregate reading, and authorizeaggregate/11 looked each filter up and applied none when it found none. An aggregate the first pass did not reach ran without its destination's read policy. That covered an aggregate or calculation given as the field: of Ash.aggregate/3, the aggregates inside a calculation used as an aggregate's field, an aggregate in another aggregate's filter, sort or join filter, and an aggregate in a combination or in the sort of an atomic bulk update or destroy. Ash.count/2, Ash.exists/2 and Ash.aggregate/3 also ignored a read policy that is decided against the records, and an aggregate reached on these paths over a multitenant resource required no tenant.
This issue affects ash: from 2.17.22 before 3.39.1.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 3.39.1
Event History
Frequently Asked Questions
Which applications are exposed to this issue?
Applications using ash versions from 2.17.22 before 3.39.1 are affected. Exposure exists where untrusted or lower-privileged actors can invoke reads, calculations, aggregates, or atomic bulk update or destroy operations that evaluate aggregates over related records protected by read policies.
What access does an attacker need to obtain unauthorized data?
The attacker needs an actor context that is allowed to invoke a vulnerable query path but is denied read access to the related destination records. They can potentially obtain counts, sums, existence results, or attribute values from those hidden records through aggregates.
Are multitenant resources affected differently?
Yes. On the affected aggregate paths, a multitenant destination resource could be queried without a tenant being required, in addition to its read policy not being applied.
How can I identify potentially affected query paths in my application?
Review uses of Ash.count/2, Ash.exists/2, and Ash.aggregate/3, especially where aggregates are supplied as a field or are nested in calculations, filters, sorts, join filters, combinations, or atomic bulk update or destroy sorts. Prioritize paths that traverse relationships into resources with restrictive read policies or tenant requirements.
What version should be deployed to remediate the issue?
Upgrade ash to version 3.39.1 or later. The provided affected range ends before 3.39.1.