{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-128360","assignerOrgId":"6b3ad84c-e1a6-4bf7-a703-f496b71e49db","state":"PUBLISHED","assignerShortName":"EEF","dateReserved":"2026-12-03T22:25:11.094Z","datePublished":"2026-12-04T06:17:25.604Z","dateUpdated":"2026-12-04T06:17:25.604Z"},"containers":{"cna":{"affected":[{"collectionURL":"https://repo.hex.pm","cpes":["cpe:2.3:a:ash-project:ash_sql:*:*:*:*:*:*:*:*"],"defaultStatus":"unaffected","modules":["'Elixir.AshSql.Aggregate.Lateral'","'Elixir.AshSql.Join'"],"packageName":"ash_sql","packageURL":"pkg:hex/ash_sql","product":"ash_sql","programFiles":["lib/aggregate/lateral.ex","lib/join.ex"],"programRoutines":[{"name":"'Elixir.AshSql.Aggregate.Lateral':add_aggregates/6"},{"name":"'Elixir.AshSql.Aggregate.Lateral':optimizable_first_aggregate?/3"},{"name":"'Elixir.AshSql.Join':aggregate_multitenancy_query/2"}],"repo":"https://github.com/ash-project/ash_sql","vendor":"ash-project","versions":[{"lessThan":"0.9.1","status":"affected","version":"0.1.0","versionType":"semver"}]},{"collectionURL":"https://github.com","cpes":["cpe:2.3:a:ash-project:ash_sql:*:*:*:*:*:*:*:*"],"defaultStatus":"unaffected","modules":["'Elixir.AshSql.Aggregate.Lateral'","'Elixir.AshSql.Join'"],"packageName":"ash-project/ash_sql","packageURL":"pkg:github/ash-project/ash_sql","product":"ash_sql","programFiles":["lib/aggregate/lateral.ex","lib/join.ex"],"programRoutines":[{"name":"'Elixir.AshSql.Aggregate.Lateral':add_aggregates/6"},{"name":"'Elixir.AshSql.Aggregate.Lateral':optimizable_first_aggregate?/3"},{"name":"'Elixir.AshSql.Join':aggregate_multitenancy_query/2"}],"repo":"https://github.com/ash-project/ash_sql","vendor":"ash-project","versions":[{"lessThan":"3bc558e984379448ede1db615ce16faea7e313e8","status":"affected","version":"dd092ed273dec7bd2194352f24a39229fc8ae68b","versionType":"git"}]}],"configurations":[{"lang":"en","supportingMedia":[{"base64":false,"type":"text/html","value":"<p>An application must use a data layer built on ash_sql (verified with AshPostgres), have a resource with <code>multitenancy</code>, and build an aggregate with the <code>tenant</code> option (<code>Ash.Query.aggregate/5</code> or <code>Ash.Query.Aggregate.new/4</code>) inside a read that has no tenant or a different tenant. With the <code>:attribute</code> 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 <code>:context</code> strategy any such aggregate over the multitenant resource is affected. Aggregates that take their tenant from the read are not affected.</p>"},{"base64":false,"type":"text/markdown","value":"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."}],"value":"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."}],"cpeApplicability":[{"nodes":[{"cpeMatch":[{"criteria":"cpe:2.3:a:ash-project:ash_sql:*:*:*:*:*:*:*:*","versionEndExcluding":"0.9.1","versionStartIncluding":"0.1.0","vulnerable":true}],"negate":false,"operator":"OR"}],"operator":"AND"}],"credits":[{"lang":"en","type":"finder","value":"Paul Schoenfelder"},{"lang":"en","type":"reporter","value":"Paul Schoenfelder"},{"lang":"en","type":"remediation developer","value":"Paul Schoenfelder"}],"dateAssigned":"2026-12-04T00:03:44.000Z","datePublic":"2026-12-04T06:17:23.000Z","descriptions":[{"lang":"en","supportingMedia":[{"base64":false,"type":"text/html","value":"<p>Incorrect Authorization vulnerability in ash_sql allows a caller in a multitenant application to receive aggregate values computed from another tenant's rows.</p>\n<p>An aggregate can be given a tenant with the <code>tenant</code> option of <code>Ash.Query.aggregate/5</code>. <code>AshSql.Aggregate.Lateral.add_aggregates/6</code> 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 <code>strategy(:context)</code> multitenancy the aggregate was read in the schema of the enclosing query.</p>\n<p>This issue affects ash_sql: from 0.1.0 before 0.9.1.</p>"},{"base64":false,"type":"text/markdown","value":"Incorrect Authorization vulnerability in ash_sql allows a caller in a multitenant application to receive aggregate values computed from another tenant's rows.\n\nAn 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.\n\nThis issue affects ash_sql: from 0.1.0 before 0.9.1."}],"value":"Incorrect Authorization vulnerability in ash_sql allows a caller in a multitenant application to receive aggregate values computed from another tenant's rows.\n\nAn 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.\n\nThis issue affects ash_sql: from 0.1.0 before 0.9.1."}],"impacts":[{"capecId":"CAPEC-1","descriptions":[{"lang":"en","supportingMedia":[{"base64":false,"type":"text/html","value":"<p>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.</p>"},{"base64":false,"type":"text/markdown","value":"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."}],"value":"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."}]}],"metrics":[{"cvssV4_0":{"Automatable":"NOT_DEFINED","Recovery":"NOT_DEFINED","Safety":"NOT_DEFINED","attackComplexity":"LOW","attackRequirements":"PRESENT","attackVector":"LOCAL","baseScore":2.1,"baseSeverity":"LOW","privilegesRequired":"NONE","providerUrgency":"NOT_DEFINED","subAvailabilityImpact":"NONE","subConfidentialityImpact":"NONE","subIntegrityImpact":"NONE","userInteraction":"NONE","valueDensity":"NOT_DEFINED","vectorString":"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","version":"4.0","vulnAvailabilityImpact":"NONE","vulnConfidentialityImpact":"LOW","vulnIntegrityImpact":"NONE","vulnerabilityResponseEffort":"NOT_DEFINED"},"format":"CVSS","scenarios":[{"lang":"en","value":"GENERAL"}]}],"problemTypes":[{"descriptions":[{"cweId":"CWE-863","description":"CWE-863 Incorrect Authorization","lang":"en","type":"CWE"}]}],"providerMetadata":{"orgId":"6b3ad84c-e1a6-4bf7-a703-f496b71e49db","shortName":"EEF","dateUpdated":"2026-12-04T06:17:25.604Z"},"references":[{"name":"Cross-tenant information disclosure in `AshSql.Aggregate.Lateral` in AshSql: the `tenant` option of an aggregate is not applied to everything the aggregate reads","tags":["vendor-advisory","related"],"url":"https://github.com/ash-project/ash_sql/security/advisories/GHSA-3496-vm79-25q9"},{"name":"EEF CNA record for CVE-2026-128360","tags":["related"],"url":"https://cna.erlef.org/cves/CVE-2026-128360.html"},{"name":"OSV record EEF-CVE-2026-128360","tags":["related"],"url":"https://osv.dev/vulnerability/EEF-CVE-2026-128360"},{"name":"Introducing commit dd092ed in ash-project/ash_sql","tags":["related"],"url":"https://github.com/ash-project/ash_sql/commit/dd092ed273dec7bd2194352f24a39229fc8ae68b"},{"name":"Fix commit 3bc558e in ash-project/ash_sql","tags":["patch"],"url":"https://github.com/ash-project/ash_sql/commit/3bc558e984379448ede1db615ce16faea7e313e8"}],"source":{"discovery":"INTERNAL"},"title":"Aggregates given a tenant are read in the enclosing query's tenant, leaking across tenants in AshSql","workarounds":[{"lang":"en","supportingMedia":[{"base64":false,"type":"text/html","value":"<p>Set the tenant on the read (<code>Ash.Query.set_tenant/2</code> or the <code>tenant</code> 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.</p>"},{"base64":false,"type":"text/markdown","value":"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."}],"value":"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."}],"x_proofOfConcept":[{"lang":"en","supportingMedia":[{"base64":false,"type":"text/html","value":"<ol>\n<li>With AshPostgres, define <code>Group</code> (<code>has_many :orgs</code>) and <code>Org</code> (<code>has_many :notes</code>, aggregate <code>count :notes_count, :notes</code>) without multitenancy, and <code>Note</code> with <code>multitenancy</code> using <code>strategy :attribute</code> and <code>attribute :tenant_id</code>.</li>\n<li>Create one group with two orgs. Give the first org one note in tenant <code>\"a\"</code> and two in tenant <code>\"b\"</code>, and the second org two notes in tenant <code>\"a\"</code>.</li>\n<li>Without a tenant on the read, run <code>Group |&gt; Ash.Query.aggregate(:n, :sum, :orgs, field: :notes_count, tenant: \"a\") |&gt; Ash.read!()</code>. The value for tenant <code>\"a\"</code> is 3; an affected version returns 5, the count over both tenants.</li>\n<li>Run the same query with <code>Ash.read!(tenant: \"b\")</code>. An affected version returns 2, the value of tenant <code>\"b\"</code>.</li>\n<li>Again without a tenant on the read, add the aggregate twice, as <code>:a</code> with <code>tenant: \"a\"</code> and as <code>:b</code> with <code>tenant: \"b\"</code>. The values are 3 and 2; an affected version returns 5 for both.</li>\n<li>For comparison, the aggregate without its <code>tenant</code> option in a read without a tenant is refused by Ash with a tenant-required error.</li>\n</ol>"},{"base64":false,"type":"text/markdown","value":"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`.\n2. 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\"`.\n3. 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.\n4. Run the same query with `Ash.read!(tenant: \"b\")`. An affected version returns 2, the value of tenant `\"b\"`.\n5. 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.\n6. For comparison, the aggregate without its `tenant` option in a read without a tenant is refused by Ash with a tenant-required error."}],"value":"* 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.\n* 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\".\n* 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.\n* Run the same query with Ash.read!(tenant: \"b\"). An affected version returns 2, the value of tenant \"b\".\n* 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.\n* For comparison, the aggregate without its tenant option in a read without a tenant is refused by Ash with a tenant-required error."}],"x_technicalAnalysis":[{"lang":"en","supportingMedia":[{"base64":false,"type":"text/html","value":"<p><strong>1. Grouping.</strong> <code>AshSql.Aggregate.Lateral.add_aggregates/6</code> 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.</p>\n<p><strong>2. Nested reads.</strong> 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 <code>context[:private][:tenant]</code> from those bindings, which is the tenant of the enclosing read and not the tenant of the aggregate. <code>AshSql.Join.handle_attribute_multitenancy/3</code> adds no tenant filter when that tenant is <code>nil</code>, 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.</p>\n<p><strong>3. Joined <code>first</code> aggregates.</strong> <code>optimizable_first_aggregate?/3</code> lets a <code>first</code> aggregate over a to-one relationship be added as a join on the enclosing query, which reads the relationship in that query's tenant.</p>\n<p><strong>4. Schema multitenancy.</strong> With <code>strategy(:context)</code> 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.</p>"},{"base64":false,"type":"text/markdown","value":"**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.\n\n**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.\n\n**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.\n\n**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."}],"value":"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.\n\n2. 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.\n\n3. 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.\n\n4. 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."}]}}}