|
| 1 | +--- |
| 2 | +'@objectstack/plugin-security': patch |
| 3 | +--- |
| 4 | + |
| 5 | +fix(plugin-security)!: a predicate update or delete now writes the rows a Modify All holder, a non-creator owner or an edit-share target can write by id, instead of stopping at the platform's creator-only floor |
| 6 | + |
| 7 | +Clause-②: no (narrowing) |
| 8 | +Metadata-protocol: none |
| 9 | + |
| 10 | +<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export changes shape. What moves is which rows one predicate update or delete by an organization member writes, and whether such a write is refused whole: no stored row, registry key or authored value changes, so there is nothing for a migration to rewrite and no tombstone. --> |
| 11 | + |
| 12 | +**BREAKING** for a predicate update or delete (`update(object, data, { where, multi: true })`, `delete(object, { where, multi: true })`) by an organization member, whose predicate now matches a row the member did not create because the record-sharing service answers `allow` for a write of that row by id (ownership at the member's write depth or Modify All, and, for an update, an `edit` share or the row sitting in a queue the member belongs to), when that row is refused: on an update, by a row-level `check`, a validation rule or a hook; on a delete, by a `beforeDelete` hook or a `restrict` relation. It ships `patch` because it is a non-protocol breaking change (AGENTS.md Post-Task Checklist step 3): no schema, key or stored value moves, so `Metadata-protocol` is `none`. |
| 13 | + |
| 14 | +- FROM: the write matched only the rows the member created. It answered success and changed those, and the other row was never judged. |
| 15 | +- TO: that row is matched and judged too, and the write applies to all of its matched rows or to none. An update whose new image of that row fails a row-level `check` is refused whole with `PERMISSION_DENIED` / 403 and writes nothing. A validation rule or hook that refuses that row refuses the whole update too, with its own code, and a `readonlyWhen` lock on that row strips the field from the whole write. A delete is refused whole, and deletes nothing, when a `beforeDelete` hook or a `restrict` relation refuses that row, with that hook's or relation's own refusal. A write of that row by id is refused too, alone. |
| 16 | + |
| 17 | +The fix for a caller: write those rows by id to get an outcome per row, or narrow the predicate to the rows that are not refused. |
| 18 | + |
| 19 | +A predicate write (`update(object, data, { where, multi: true })`, `delete(object, { where, multi: true })`) by an organization member held the platform's own ownership floor (`owner_only_writes` / `owner_only_deletes` in `member_default`, `created_by == current_user.id`) as an unconditional condition, where record sharing enforces writes. Unless an app-authored write policy admitted a row, the write matched only the rows that member had created, even when the same user could update or delete the other matching rows one at a time by id. This affected a manager holding `modifyAllRecords` on the object, a row's owner who did not create it, and, for an update, the target of an `edit`-level record share or a member of the queue a row sits in. The write answered success and changed fewer rows than its predicate matched. A write by id lets the record-sharing service's `allow` verdict replace the floor. |
| 20 | + |
| 21 | +The predicate write now makes the by-id decision for each matched row the floor would refuse. Such a row is written when a write of that row by id would be, because the sharing service answers `allow` for it: ownership at the caller's write depth, Modify All, or, for an update only, an `edit` share or the row's queue. A row the service abstains on keeps the floor: on an object with no `owner_id`, on a delete under `public_read_write` (an update there has no floor to keep, because that OWD opens row updates), and on a `controlled_by_parent` detail unless an update's row sits in a queue the caller belongs to. A row it denies keeps the floor too. The row-level `check` on each updated row follows the same decision. |
| 22 | + |
| 23 | +The by-id decision costs one sharing verdict, a few store reads, for each matched row the floor does not already admit. Measured on SQLite in memory: |
| 24 | + |
| 25 | +- A member's predicate update matching 1,000 readable rows owned by other people, every verdict `deny`: 1,000 verdicts and 2,004 store reads, about 1.1 s, against 44 ms and 3 reads before. |
| 26 | +- The same at 10,000 rows: 10,000 verdicts and 20,004 store reads, about 5.3 s, against 47 ms before. |
| 27 | +- A Modify All holder at 10,000 rows: 10,000 verdicts and 10,003 store reads, about 1.8 s, and it now writes the 10,000 rows. Before, it took 47 ms and wrote none of them. |
| 28 | +- Where an app-authored `using` policy for the write applies to the caller: 0 verdicts, because a row the floor refuses fails that policy too (10,000 matched rows the floor refuses, 45 ms). |
| 29 | + |
| 30 | +What does not change: |
| 31 | + |
| 32 | +- The rows a predicate write can reach are still only the rows its predicate matches that the caller can read. A predicate matching more than 10,000 of them is still refused before anything is written. |
| 33 | +- The sharing service's own bulk write scope still bounds a predicate write: the owner set at the caller's depth, plus the edit shares (at most 5,000 of them) and the queue on an update. A row that only a read share and an app `update` policy together make writable is still written by id alone. |
| 34 | +- An app-authored row-level policy still binds every row, and Modify All still does not bypass row-level security on an ordinary business object. |
| 35 | +- An `edit` share still widens update and never delete. |
| 36 | +- The tenant wall is unchanged. |
| 37 | +- A write made on another user's behalf keeps the floor for both principals, as its by-id write does. |
| 38 | +- A `controlled_by_parent` detail keeps the floor on a predicate write, except on an update of a row that sits in a queue the caller belongs to, which the sharing service answers `allow` for under any OWD. The master gate still judges the predicate write. Its by-id write is decided by the master gate instead of the floor, and that half is not changed here. |
| 39 | + |
| 40 | +A flow, script or server-side bulk update or delete that relied on a predicate write skipping the rows its caller did not create now changes those rows too, when the caller may write them by id, and is refused whole when one of them is refused. The fix is the one above. |
0 commit comments