EEF-CVE-2026-128360

Source
https://cna.erlef.org/osv/EEF-CVE-2026-128360.html
Import Source
https://cna.erlef.org/osv/EEF-CVE-2026-128360.json
JSON Data
https://api.osv.dev/v1/vulns/EEF-CVE-2026-128360
Aliases
  • GHSA-3496-vm79-25q9
  • CVE-2026-128360
Published
2026-12-04T06:17:25Z
Modified
2026-12-04T06:30:03Z
Severity
  • 2.1 (Low) CVSS_V4 - 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 (Source: CNA) CVSS Calculator
Summary
Aggregates given a tenant are read in the enclosing query's tenant, leaking across tenants in AshSql
Details

Summary

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.

Details

1. Grouping. AshSql.Aggregate.Lateral.add_aggregates/6 groups the aggregates of a query by relationship path, resource, join filters, read action and multitenancy bypass, and builds one lateral subquery per group from the query of the first aggregate. The tenant is not part of that key, so aggregates that were given different tenants share the subquery of the first one.

2. Nested reads. The subquery is built from the bindings of the enclosing query. What is resolved inside it (a field that is an aggregate or a calculation, and the aggregates and calculations in the aggregate's filter and sort) takes context[:private][:tenant] from those bindings, which is the tenant of the enclosing read and not the tenant of the aggregate. AshSql.Join.handle_attribute_multitenancy/3 adds no tenant filter when that tenant is nil, so with no tenant on the read these nested reads cover every tenant. Ash itself refuses the same aggregate when no tenant is given anywhere.

3. Joined first aggregates. optimizable_first_aggregate?/3 lets a first aggregate over a to-one relationship be added as a join on the enclosing query, which reads the relationship in that query's tenant.

4. Schema multitenancy. With strategy(:context) the observed effect covers the aggregate as a whole: its subquery is read in the schema of the enclosing query's tenant, or in the repo's default schema when that query has no tenant.

Proof of concept

  1. With AshPostgres, define Group (has_many :orgs) and Org (has_many :notes, aggregate count :notes_count, :notes) without multitenancy, and Note with multitenancy using strategy :attribute and attribute :tenant_id.
  2. Create one group with two orgs. Give the first org one note in tenant "a" and two in tenant "b", and the second org two notes in tenant "a".
  3. Without a tenant on the read, run Group |> Ash.Query.aggregate(:n, :sum, :orgs, field: :notes_count, tenant: "a") |> Ash.read!(). The value for tenant "a" is 3; an affected version returns 5, the count over both tenants.
  4. Run the same query with Ash.read!(tenant: "b"). An affected version returns 2, the value of tenant "b".
  5. Again without a tenant on the read, add the aggregate twice, as :a with tenant: "a" and as :b with tenant: "b". The values are 3 and 2; an affected version returns 5 for both.
  6. For comparison, the aggregate without its tenant option in a read without a tenant is refused by Ash with a tenant-required error.

Impact

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.

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.

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.

Database specific
{
    "$schema":  "https://cna.erlef.org/schemas/osv/record-0.1.0.json",
    "capec_ids":  [
        "CAPEC-1"
    ],
    "cpe_ids":  [
        "cpe:2.3:a:ash-project:ash_sql:*:*:*:*:*:*:*:*"
    ],
    "cwe_ids":  [
        "CWE-863"
    ]
}
References
Credits
    • Paul Schoenfelder - FINDER
    • Paul Schoenfelder - REPORTER
    • Paul Schoenfelder - REMEDIATION_DEVELOPER

Affected packages

Hex / ash_sql

Package

Name
ash_sql
Purl
pkg:hex/ash_sql

Affected ranges

Type
SEMVER
Events
Introduced
0.1.0
Fixed
0.9.1

Affected versions

0.*
0.1.1-rc.0
0.1.1-rc.1
0.1.1-rc.2
0.1.1-rc.3
0.1.1-rc.4
0.1.1-rc.5
0.1.1-rc.6
0.1.1-rc.7
0.1.1-rc.8
0.1.1-rc.9
0.1.1-rc.10
0.1.1-rc.11
0.1.1-rc.12
0.1.1-rc.13
0.1.1-rc.14
0.1.1-rc.15
0.1.1-rc.16
0.1.1-rc.17
0.1.1-rc.18
0.1.1-rc.19
0.1.1-rc.20
0.1.2
0.1.3
0.2.0
0.2.1
0.2.2
0.2.3
0.2.4
0.2.5
0.2.6
0.2.7
0.2.8
0.2.9
0.2.10
0.2.11
0.2.12
0.2.13
0.2.14
0.2.15
0.2.16
0.2.17
0.2.18
0.2.19
0.2.20
0.2.21
0.2.22
0.2.23
0.2.24
0.2.25
0.2.26
0.2.27
0.2.28
0.2.29
0.2.30
0.2.31
0.2.32
0.2.33
0.2.34
0.2.35
0.2.36
0.2.37
0.2.38
0.2.39
0.2.40
0.2.41
0.2.42
0.2.43
0.2.44
0.2.45
0.2.46
0.2.47
0.2.48
0.2.49
0.2.50
0.2.51
0.2.52
0.2.53
0.2.54
0.2.55
0.2.56
0.2.57
0.2.58
0.2.59
0.2.60
0.2.61
0.2.62
0.2.63
0.2.64
0.2.65
0.2.66
0.2.67
0.2.68
0.2.69
0.2.70
0.2.71
0.2.72
0.2.73
0.2.74
0.2.75
0.2.76
0.2.77
0.2.78
0.2.79
0.2.80
0.2.81
0.2.82
0.2.83
0.2.84
0.2.85
0.2.86
0.2.87
0.2.88
0.2.89
0.2.90
0.2.91
0.2.92
0.2.93
0.3.0
0.3.1
0.3.2
0.3.3
0.3.4
0.3.5
0.3.6
0.3.7
0.3.8
0.3.9
0.3.10
0.3.11
0.3.12
0.3.13
0.3.14
0.3.15
0.3.16
0.4.0
0.4.1
0.4.2
0.4.3
0.4.4
0.4.5
0.5.0
0.5.1
0.5.2
0.5.3
0.5.4
0.5.5
0.6.0
0.6.1
0.6.2
0.6.3
0.6.4
0.6.5
0.6.6
0.6.7
0.6.8
0.6.9
0.7.0
0.7.1
0.7.2
0.7.3
0.7.4
0.7.5
0.7.6
0.8.0
0.8.1
0.8.2
0.8.3
0.8.4
0.8.5
0.8.6
0.8.7
0.8.8
0.8.9
0.9.0

Ecosystem specific

{
    "$schema":  "https://cna.erlef.org/schemas/osv/affected-0.1.0.json",
    "modules":  [
        "'Elixir.AshSql.Aggregate.Lateral'",
        "'Elixir.AshSql.Join'"
    ],
    "program_files":  [
        "lib/aggregate/lateral.ex",
        "lib/join.ex"
    ],
    "program_routines":  [
        "'Elixir.AshSql.Aggregate.Lateral':add_aggregates/6",
        "'Elixir.AshSql.Aggregate.Lateral':optimizable_first_aggregate?/3",
        "'Elixir.AshSql.Join':aggregate_multitenancy_query/2"
    ]
}

Database specific

$schema
"https://cna.erlef.org/schemas/osv/affected-0.1.0.json"
modules
[
    "'Elixir.AshSql.Aggregate.Lateral'",
    "'Elixir.AshSql.Join'"
]
program_files
[
    "lib/aggregate/lateral.ex",
    "lib/join.ex"
]
program_routines
[
    "'Elixir.AshSql.Aggregate.Lateral':add_aggregates/6",
    "'Elixir.AshSql.Aggregate.Lateral':optimizable_first_aggregate?/3",
    "'Elixir.AshSql.Join':aggregate_multitenancy_query/2"
]
source
"https://cna.erlef.org/osv/EEF-CVE-2026-128360.json"

Git / github.com/ash-project/ash_sql

Affected ranges

Type
GIT
Repo
https://github.com/ash-project/ash_sql
Events

Affected versions

v0.*
v0.1.0
v0.1.1-rc.0
v0.1.1-rc.1
v0.1.1-rc.10
v0.1.1-rc.11
v0.1.1-rc.12
v0.1.1-rc.13
v0.1.1-rc.14
v0.1.1-rc.15
v0.1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.2
v0.6.3
v0.6.4
v0.6.5
v0.6.6
v0.6.7
v0.6.8
v0.6.9
v0.7.0
v0.7.1
v0.7.2
v0.7.3
v0.7.4
v0.7.5
v0.7.6
v0.8.0
v0.8.1
v0.8.2
v0.8.3
v0.8.4
v0.8.5
v0.8.6
v0.8.7
v0.8.8
v0.8.9
v0.9.0

Database specific

$schema
"https://cna.erlef.org/schemas/osv/affected-0.1.0.json"
modules
[
    "'Elixir.AshSql.Aggregate.Lateral'",
    "'Elixir.AshSql.Join'"
]
program_files
[
    "lib/aggregate/lateral.ex",
    "lib/join.ex"
]
program_routines
[
    "'Elixir.AshSql.Aggregate.Lateral':add_aggregates/6",
    "'Elixir.AshSql.Aggregate.Lateral':optimizable_first_aggregate?/3",
    "'Elixir.AshSql.Join':aggregate_multitenancy_query/2"
]
source
"https://cna.erlef.org/osv/EEF-CVE-2026-128360.json"