Commit bb16143
committed
fix(security): exempt engine referential FK clears from the owner_id transfer guard (#3023)
owner_id is a lookup to sys_user with default deleteBehavior 'set_null', so
deleting a sys_user makes cascadeDeleteRelations null owner_id on every dependent.
That cascade write re-entered the write middleware under the deleter's context,
where the #3004 ownership-anchor guard read owner_id=null as a user disown and
denied it — aborting the cascade mid-way (no transaction → partial state) for any
deleter lacking the transfer grant on the child (e.g. a member clearing a
public_read_write child that RLS would otherwise allow).
The cascade FK clear is engine-mandated referential integrity consequent to an
already-authorized parent delete, not a user ownership change. cascadeDeleteRelations
now tags the set_null write with a server-derived __referentialFieldClear context
marker (set by the engine, never built from a request — same trust model as
__expandRead), and the ownership-anchor guard skips when it is present. Ordinary
user writes are unaffected; the marker can't be forged from client input, so it can
never slip a real ownership transfer past the guard.
Tests: engine-cascade-delete proves the set_null write carries the marker (and a
user update does not); plugin-security proves the guard honors it (a member's
owner_id=null with the marker is allowed, denied without). objectql 899 /
plugin-security 462 / related dogfood green.1 parent aaec5db commit bb16143
5 files changed
Lines changed: 91 additions & 2 deletions
File tree
- .changeset
- packages
- objectql/src
- plugins/plugin-security/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
141 | 175 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2631 | 2631 | | |
2632 | 2632 | | |
2633 | 2633 | | |
2634 | | - | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
2635 | 2644 | | |
2636 | 2645 | | |
2637 | 2646 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
372 | 385 | | |
373 | 386 | | |
374 | 387 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1099 | 1099 | | |
1100 | 1100 | | |
1101 | 1101 | | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
1102 | 1111 | | |
1103 | 1112 | | |
1104 | 1113 | | |
1105 | | - | |
| 1114 | + | |
| 1115 | + | |
1106 | 1116 | | |
1107 | 1117 | | |
1108 | 1118 | | |
| |||
0 commit comments