You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 77e4f31
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-security)!: refuse every write that sets a controlled_by_parent master reference declared readonly or system (ADR-0055 §1)
Ruling 6345869077 on #25095 (route B, refuse at the write gate). The
relation still resolves for such a declaration, so reads, the cache and
the unresolved report are unchanged and stored rows keep their master.
CbpRelation.masterNotWritable is now read from the same field def the
relation came from, judged by the parse's own predicate on that one def.
The gate refuses, before any master is asked and before anything is
written, every insert (single or batch, with or without a master in the
body) and every update whose body carries the reference key (any value,
null included), 422 INVALID_METADATA with the parse's message. A delete
and an update that leaves the key alone take the path they took before.
The same answer for every caller the gate judges; the system bypass is
unchanged.
Tests: the suite is renamed to controlled-by-parent-unwritable-master-write
and now covers a member and a platform admin, ordinary and sys_-named
objects, inserts with and without a master, batch inserts, updates
naming a master or null, and the controls (stored rows read, an update
without the key, a delete, a system create, the in-repo declaration
shape). The [#8688] flagged-insert pin in controlled-by-parent-sharing
and the unjudged-reference pins in controlled-by-parent-every-row-master
move to the new answer; the stored-master-first ordering pin moves to
the validated detail. The stale AUTHORABLE wording and the two stale
freeze-note paragraphs are corrected.
Claude-Session: https://claude.ai/code/session_01LQG7z3CxDLtiMaHLbTFSeB
Co-authored-by: Claude <noreply@anthropic.com>
fix(plugin-security)!: under a `controlled_by_parent` declaration whose one master reference is `readonly` or `system`, every write that sets that reference is refused (ADR-0055 §1)
6
+
7
+
Clause-②: no (narrowing)
8
+
9
+
Metadata-protocol: none
10
+
11
+
<!-- adr-0087: not-required (already-registered cbp-master-relation-tiers-retired) registered before this change, and it covers it: that entry's stored-row listing (`os migrate meta --stored`) already reports this declaration as `master-not-writable`, with the prescription below. Nothing new moves: no spec key, authorable spelling, object definition, stored row or stored shape is added, removed, renamed or re-shaped, and no exported declaration is removed or narrowed. What changes is the answer the security plugin's write gate gives on an object that reached the registry with a declaration the parse already refuses. -->
12
+
13
+
**BREAKING** for a caller that relied on such a write landing. A non-protocol change, shipped as `patch`.
14
+
15
+
ADR-0055 §1 derives a `controlled_by_parent` detail's access from exactly one required `master_detail` field that every write of a detail supplies. The parse refuses that master when it is declared `readonly: true` or `system: true`, so an object with it reaches the runtime only through a door that does not parse: a raw `registerObject` or `registerApp`, a `defineStack` call with `strict: false`, or a stored object the boot registers under its `[metadata_spec_invalid]` diagnostic. On such an object the security plugin's write gate let writes that set the master reference through, and a detail could end up outside the master its access derives from, readable by nobody, while the write reported success.
16
+
17
+
-**Before.** An insert under that declaration was written when it named a master. An update could set the reference.
18
+
-**Now.** Every write that sets the reference answers `INVALID_METADATA` (422) and writes nothing, before any master is asked: every insert, single or batch, whether or not it names a master, and every update whose body carries the reference key, whatever the value, `null` included. The message is the parse's own refusal of the declaration, prefixed with the write it refused, so it names the object, the field, each flag and the fix. It is the same for every caller the gate judges.
19
+
-**Unchanged.**
20
+
- The rows already stored: the gate still derives their read access from that field, so they keep their master and are read as before.
21
+
- A delete, and an update whose body leaves the reference key out.
22
+
- System contexts, every object declared with an ordinary required master, and every object that does not declare `controlled_by_parent`.
23
+
24
+
**What to do.** Fix the declaration as the parse says: remove `readonly: true` and `system: true` from the master reference and declare it as an ordinary required field. If the rows must outlive their parent, the object is not a detail: give it its own `sharingModel` (`private`, `public_read` or `public_read_write`).
Copy file name to clipboardExpand all lines: packages/plugins/plugin-security/src/controlled-by-parent-every-row-master.test.ts
+24-29Lines changed: 24 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -27,16 +27,16 @@
27
27
* - each master a batch names is asked once, in row order;
28
28
* - a row naming no master, under a reference required-field validation
29
29
* judges, is answered by validation as before;
30
-
* - under a reference required-field validation does not judge, a batch
31
-
* create naming a master the caller may not edit is refused on that master
32
-
* (for an agent, whose own pass runs first, on the empty-master answer),
33
-
* and every other batch create is still refused whole, as before;
34
-
* - an update that empties the master reference, under a reference
35
-
* required-field validation does not judge, is refused — addressed by
36
-
* `where`, in its body and by predicate — with the empty-master refusal, and
37
-
* nothing is written; under a reference validation judges, validation's
38
-
* answer is unchanged; and an update that leaves the reference out lands as
39
-
* it did.
30
+
* - under a reference required-field validation does not judge — one the
31
+
* declaration keeps from the author, which the parse refuses — every batch
32
+
* create is refused whole as the declaration defect it is (#25095), before
33
+
* any master is asked, and nothing is written;
34
+
* - an update that empties the master reference is refused — addressed by
35
+
* `where`, in its body and by predicate — and nothing is written: under a
36
+
* reference validation judges, by validation as before, after the master
37
+
* the row is stored under is asked; under one it does not judge, as the
38
+
* declaration defect (#25095); and an update that leaves the reference out
39
+
* lands as it did.
40
40
*
41
41
* Real stack: `ObjectQL` over better-sqlite3, the real `SecurityPlugin`, the
42
42
* real sharing service and middleware, the real protocol, and contexts
@@ -83,7 +83,9 @@ const D = { rls: 'qa_cbp_erm_detail_rls', chain: 'qa_cbp_erm_detail_chain' } as
83
83
/**
84
84
* A detail under `M.rls` whose master reference required-field validation does
85
85
* not judge (`validateRecord` skips a provenance-flagged field), so the gate is
86
-
* the one thing that holds the reference populated.
86
+
* the one thing that holds the reference populated. The parse refuses the
87
+
* declaration (`master-not-writable`), and since #25095 the gate refuses every
88
+
* write that sets the reference as that defect.
87
89
*/
88
90
constUNJUDGED='qa_cbp_erm_detail_unjudged';
89
91
@@ -457,27 +459,20 @@ describe('ADR-0055 §1 · §3 — every row a write stores in a controlled_by_pa
457
459
});
458
460
});
459
461
460
-
it('under a reference validation does not judge: a batch create naming a master the caller may not edit is refused on that master, and every other batch create is still refused whole',async()=>{
462
+
it('under a reference validation does not judge: every batch create is refused whole as the declaration defect, before any master is asked, and nothing is written',async()=>{
461
463
for(constcallerofObject.keys(CALLERS)asCaller[]){
462
464
const{ user, onBehalf }=CALLERS[caller];
463
465
constcontext=awaitrig.contextOf(user,onBehalf);
466
+
// [#25095] The single create's answer, even naming a master the caller may not edit.
@@ -486,13 +481,13 @@ describe('ADR-0055 §1 · §3 — every row a write stores in a controlled_by_pa
486
481
487
482
describe('an update never empties the master reference a detail derives its access from',()=>{
488
483
for(constcallerofObject.keys(CALLERS)asCaller[]){
489
-
it(`${caller}: under a reference validation does not judge, it is refused on every update shape, and nothing is written`,async()=>{
484
+
it(`${caller}: under a reference validation does not judge, it is refused on every update shape as the declaration defect, and nothing is written`,async()=>{
0 commit comments