Repository navigation
fix(databases): enforce transaction-staging permissions; accept documents.read on legacy transaction reads - #14754
Conversation
…egacy transaction read scope Transaction staging (Transactions/Operations/Create) role-checked the raw $permissions without aggregating first, so a write() aggregate for a role the caller does not hold slipped past the check and was persisted at commit. Validate and aggregate (as the direct document endpoints do) before the role check, and stage the canonical expanded permissions. The legacy /v1/databases/transactions Get and XList routes were labeled rows.read (a TablesDB scope); a documents.read key could not read its own transactions. Accept ['documents.read','rows.read'] to match the TablesDB variants. Refs appwrite-labs/cloud#6748, appwrite-labs/cloud#6751, appwrite-labs/cloud#6754 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Review complete. No issues found — approved ✅. This PR aligns the legacy Databases transaction surface with the TablesDB one: the transaction read routes now authorize callers holding either legacy
All scanned candidates were adjudicated as pre-existing or false positives, so no findings are reported. Reviewed commit: fc94564 |
🟢 Tier S · Ready to merge
Transaction operation staging now validates and expands aggregate permissions before persisting staged data, including bulk-operation payloads. The legacy transaction Get and List endpoints accept both
📂 Walkthrough · 5
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…ller Aggregation ran only in the non-privileged branch, so API keys and privileged users staged a raw write(...) that the commit handler persisted unexpanded, unlike the direct document endpoints. Validate and aggregate permissions for all callers; keep the "roles you hold" check scoped to non-privileged callers. Adds a regression that a key staging write(user:x) commits as update+delete(user:x). Addresses review on #14754. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Addressed the review: validation + |
|
@hansi-codes review |
…s too The normalization only ran in the non-bulk branch, so staged bulkCreate/bulkUpsert documents (and bulkUpdate data) kept raw write(...) aggregates that the commit handler persisted verbatim, unlike the direct bulk endpoints. Extract a normalizePermissions() helper and apply it to per-document bulk permissions. Adds a bulkCreate regression that a staged write(user:x) commits as update+delete. Addresses review on #14754. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Fixed in the latest push: extracted a @hansi-codes review |
…psert Extends the staging regressions beyond bulkCreate: bulkUpsert (per-document permissions) and bulkUpdate (the data block's permissions) now also assert a staged write(user:x) commits as update+delete, catching any shape mismatch that would leave the raw aggregate unexpanded. Addresses review on #14754. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Added @hansi-codes review |
normalizePermissions() declared an array parameter, so a scalar $permissions value in a staged operation raised a TypeError (500) before the Permissions validator could return a clean 400. Accept mixed and reject a non-array value with GENERAL_BAD_REQUEST. Adds a regression staging data.$permissions as a string. Addresses review on #14754. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Fixed: @hansi-codes review |
) Staging role-checked the raw permissions before aggregating, so write("<role not held>") was staged and committed unvalidated. Permissions are now validated, aggregated, role-checked and staged in canonical form. Legacy transaction Get and List also accept documents.read. (cherry picked from commit d2d54bf)
…on-authz fix(databases): enforce transaction-staging permissions; accept documents.read on legacy transaction reads (cherry picked from commit d2d54bf)
What
Two authorization fixes on the Databases transaction surface, each with a regression that fails before the change and passes after.
Transaction staging permission bypass
Transactions/Operations/Createrole-checked the raw$permissionsbefore aggregating. The direct create/update/upsert endpoints callPermission::aggregate()first, so awrite(...)aggregate expands to update+delete and every role is checked. Staging did not:write("<role you don't hold>")matched none of read/create/update/delete and was staged and persisted at commit unvalidated — a bypass of the "users may only grant roles they hold" control (and a latent escalation if any path later expands stored aggregates). This path is shared by the Databases, TablesDB, DocumentsDB and VectorsDB surfaces.Fix: validate with
Permissions([Read, Update, Delete, Write]), aggregate to[Read, Update, Delete], role-check the expanded set, and stage the canonical permissions.Legacy transaction read scope
/v1/databases/transactionsGetandXListwere labeledrows.read(a TablesDB scope). Adocuments.readkey — which can create/stage/commit transactions viadocuments.write— could not read its own transactions, while arows.read-only key could. Fix: accept['documents.read', 'rows.read'], matching the TablesDB variants.Tests
TransactionPermissionsBase::testCannotStageUnauthorizedAggregatePermissions(Legacy + DocumentsDB): stagingwrite(team:adminTeam)is 401 (was 201);write(user:self)stays 201.LegacyTransactionsCustomServerTest::testLegacyTransactionReadsAcceptDocumentsReadScope: adocuments.readkey reads its own legacy transaction, 401 → 200.🤖 Generated with Claude Code