Executive brief
ash_sql is a library for querying data in multi-tenant applications where different customers' data is isolated by database schema. A flaw in aggregate query processing causes the library to compute sums, counts, and other aggregates against the wrong tenant's data when a distinct query is used, exposing one tenant's metrics to another tenant. This could lead to unauthorized disclosure of business-sensitive aggregate information across tenant boundaries.
Technical details
The vulnerability exists in ash_sql's AggregateQuery.add_single_aggs/5 function, which rebuilds the outer query from only the {table, schema} tuple without preserving query.prefix and query.from.prefix—fields that hold the tenant schema in strategy(:context) multitenancy. As a result, the rebuilt outer query reads from the repository's default schema while the inner correlated subquery still reads the tenant's schema; they are joined only on primary key, causing aggregates to be computed against another tenant's rows. The neighbouring limit and exists code branches correctly use subquery/1 to preserve the prefix. The issue affects all versions from 0.1.0 up to and including 0.7.0; version 0.7.1 and later contain the fix.
Affected products
- ash-project ash_sql 0.1.0 to 0.7.0
Timeline
- 2026-08-30: disclosed