See how ash compares to other vendors in security performance
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.
Summary Certain bulk action calls with a beforetransaction hook and no aftertransaction hook, will call the beforetransaction hook before authorization is checked and a Forbidden error is returned, when called as a bulk action.
The impact is that a malicious user could cause a beforetransaction to run even though they are not authorized to perform the whole action. The beforeaction could run a sensitive/expensive operation.
Impact A malicious user could cause a beforeaction to run even though they are not authorized to perform the whole action.
You are affected if you have an create, update or destroy action that:
- has a beforetransaction hook on it, and no aftertransaction hook on it. - is being used via an Ash.bulk callback (which AshJsonApi and AshGraphql do for update/destroy actions)
Whether or not or how much it matters depends on the nature of those beforetransaction callbacks. If those beforetransaction callbacks are side-effectful, or just doing something like looking up some external data. If your API endpoints are behind authentication and what kind.
Severity
The severity for this was hard to gauge. beforetransaction hooks are not that commonly used. Additionally, any attacker must know which of these things are available to them, be authenticated to make such a request (i.e you very rarely have policies preventing the running of anonymous queries), so privileges and inside knowledge are required. Additionally, the action will always return a forbidden error, so no information is revealed. We will evaluate and adjust the severity in the next few days as needed.
It is currently marked as High, given that we really don't know what logic folks are putting in their beforetransaction hooks and it could theoretically be very bad.
Workarounds
You should update ASAP, but if for whatever reason you cannot update, you can add logic to those beforetransaction hooks to prevent them from doing their logic before they should.