CVE-2026-128360 PUBLISHED

Aggregates given a tenant are read in the enclosing query's tenant, leaking across tenants in AshSql

Assigner: EEF
Reserved: 03.12.2026 Published: 04.12.2026 Updated: 04.12.2026

Incorrect Authorization vulnerability in ash_sql allows a caller in a multitenant application to receive aggregate values computed from another tenant's rows.

An aggregate can be given a tenant with the tenant option of Ash.Query.aggregate/5. AshSql.Aggregate.Lateral.add_aggregates/6 read only part of such an aggregate in that tenant. A field that is an aggregate or calculation, and what the aggregate's filter and sort refer to, were read in the tenant of the enclosing query, and with no tenant on that query they were read across every tenant. Aggregates over the same relationship were grouped into one lateral join without regard to their tenants, and with strategy(:context) multitenancy the aggregate was read in the schema of the enclosing query.

This issue affects ash_sql: from 0.1.0 before 0.9.1.

Metrics

CVSS Vector: CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N
CVSS Score: 2.1

Product Status

Vendor ash-project
Product ash_sql
Versions Default: unaffected
  • affected from 0.1.0 to 0.9.1 (excl.)
Vendor ash-project
Product ash_sql
Versions Default: unaffected
  • affected from dd092ed273dec7bd2194352f24a39229fc8ae68b to 3bc558e984379448ede1db615ce16faea7e313e8 (excl.)

Affected Configurations

An application must use a data layer built on ash_sql (verified with AshPostgres), have a resource with multitenancy, and build an aggregate with the tenant option (Ash.Query.aggregate/5 or Ash.Query.Aggregate.new/4) inside a read that has no tenant or a different tenant. With the :attribute strategy the aggregate must also have a field, filter or sort that refers to an aggregate or calculation over the multitenant resource, or share its relationship with an aggregate that was given a different tenant. With the :context strategy any such aggregate over the multitenant resource is affected. Aggregates that take their tenant from the read are not affected.

Workarounds

Set the tenant on the read (Ash.Query.set_tenant/2 or the tenant option of the read) instead of on the aggregate, so that both are read in the same tenant. Aggregates that have to be read in different tenants can be run as separate reads, one per tenant.

Credits

  • Paul Schoenfelder finder
  • Paul Schoenfelder reporter
  • Paul Schoenfelder remediation developer

References

Problem Types

  • CWE-863 Incorrect Authorization CWE

Impacts

  • A user of the application receives counts, sums, lists or first values computed from rows of a tenant other than the one the application asked for, and from the rows of every tenant when the enclosing read has no tenant. No input from the user is needed beyond reaching the read that builds the aggregate.