CVE-2026-81318: Distinct-query aggregate drops the tenant schema prefix, leaking across tenants in AshSql

Published Aug 30, 2026
·
Updated

Incorrect Authorization vulnerability in ash-project ashsql allows a caller in a schema-based multitenant application to receive aggregate values computed from another tenant's rows.

When an aggregate is computed over a distinct query, AshSql.AggregateQuery.addsingleaggs/5 rebuilds the outer query from query.from.source alone, which is only the {table, schema} tuple and does not carry query.prefix or query.from.prefix. For strategy(:context) multitenancy those hold the tenant schema, so the rebuilt outer query reads the repo's default schema while the inner correlated subquery still reads the tenant schema, and the two are joined only on primary key. The aggregate, and any relationship join added off the prefix-less binding, is then computed against the wrong tenant's rows. The neighbouring limit and exists branches instead wrap the query with subquery/1, which preserves the prefix.

This issue affects ashsql: from 0.1.0 before 0.7.1.

Affected Software

1 affected component
Ash ash_sql<0.7.1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade ash-project ash_sql to a version that resolves this vulnerability.

    Fixed in 0.7.1

Event History

Aug 30, 2026
CVE Published
via MITRE·11:56 AM
Data Sourced
via MITRE·11:56 AM
DescriptionWeakness
Data Sourced
via NVD·12:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which deployments are exposed to this issue?

Applications using ash_sql versions from 0.1.0 before 0.7.1 are affected when they use schema-based multitenancy with strategy(:context) and compute aggregates over distinct queries. The issue concerns tenant schema prefixes carried in query.prefix or query.from.prefix.

2

What conditions are required for data from another tenant to be returned?

A caller must trigger an aggregate computed over a distinct query in an affected schema-based multitenant application. The rebuilt outer query can then read the repository default schema while the correlated subquery reads the tenant schema, with rows joined only by primary key.

3

Are all aggregate query paths affected?

No. The described issue is specific to the distinct-query aggregate path in AshSql.AggregateQuery.add_single_aggs/5. The neighboring limit and exists branches use subquery/1, which preserves the tenant prefix.

4

What version resolves the issue?

Upgrade ash_sql to version 0.7.1 or later. Versions before 0.7.1, starting with 0.1.0, are identified as affected.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203