Skip to content

Commit a41e121

Browse files
committed
docs(core): the depth stamp rides the operation's own envelope; changeset
Claude-Session: https://claude.ai/code/session_016WV4d1D3AzXvEhBbz79Pmi Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9104c41 commit a41e121

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/plugin-security': patch
3+
---
4+
5+
fix(plugin-security): each data operation reads at its own object's access depth, even when sibling operations share one request
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The authz middleware resolves an access depth per object (`readScope` / `writeScope`, ADR-0057 D1) and hands it to plugin-sharing's owner-match further down the same operation. It used to write that depth onto the caller's execution context in place. One caller context serves every operation a request runs, concurrent ones included, so a sibling read on another object could overwrite the depth before plugin-sharing read it. The record page payload (`POST /api/v1/data/:object/:id/page`) reads its related lists concurrently: on the showcase, a member staffed `showcase_manager` got the Contacts list filtered at the owner depth of the next list's object, so it showed 1 row beside `total: 26` whenever Contacts was not the last list. The admin was not affected.
11+
12+
The depth, and the external audience's grant stamp beside it, now ride on a copy of the envelope that the middleware hands to the rest of its own operation. The caller's context is never written, so concurrent operations cannot see each other's depth. Request-wide memos (membership sets, queues) are still staged on the caller's context before the copy is made.

‎packages/core/src/security/operation-private-keys.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
*
1919
* - the ADR-0057 D1 access DEPTH the sharing owner-match expands to —
2020
* `__readScope` / `__writeScope`, plus the ADR-0090 D10 delegator halves
21-
* `__delegatorReadScope` / `__delegatorWriteScope`, stamped in place by
22-
* `security-plugin.ts` (`sc.__readScope = …`);
21+
* `__delegatorReadScope` / `__delegatorWriteScope`, stamped by the authz
22+
* middleware (`security-plugin-authz-middleware.ts`, step 2.6) onto the
23+
* envelope it hands the rest of ITS operation's chain — since #33051 a copy
24+
* of the caller's, never the caller's own, because one caller envelope
25+
* serves concurrent operations on different objects;
2326
* - the engine's internal privilege markers on the same channel —
2427
* `__expandRead` marks a read as a lookup EXPANSION sub-read (it no longer
2528
* relaxes any gate — #7626 removed that waiver — but it still travels with
@@ -101,10 +104,10 @@ export const OPERATION_PRIVATE_KEY_PREFIX = '__';
101104
* receives (which is exactly what plugin-security does before it calls the
102105
* sharing service) can never write back into the operation context the caller
103106
* was handed;
104-
* - inbound — the engine's middleware stamps a depth for the object it is about
105-
* to read onto whatever it is handed, so forwarding a caller's envelope BY
106-
* REFERENCE would write that depth back into the request context the route
107-
* goes on using.
107+
* - inbound — a middleware that stamps a depth for the object it is about to
108+
* read onto whatever it is handed (plugin-security's did, in place, until
109+
* #33051) would, through an envelope forwarded BY REFERENCE, write that
110+
* depth back into the request context the route goes on using.
108111
*
109112
* ⛔ Never `return exec;` on the "nothing to strip" path. The copy is the point,
110113
* not an optimisation to skip when the envelope happens to be clean — the two

0 commit comments

Comments
 (0)