Skip to content

Commit 3673799

Browse files
committed
test(core, plugin-security): classify the grant-holder refusal's holder read; pin that it is the caller's own, projected to id
The second-object read census names the grant-holder membership refusal as a caller of the reference-target arbiter that serves nothing of the target: its one read of a holder is the caller's own read door, projected to `id`, and its answer only decides whether the write-path reference check answers the holder. plugin-security pins that read's shape. Claude-Session: https://claude.ai/code/session_012dn2AdqWnb3ndnEacKvJvF Co-authored-by: Claude <noreply@anthropic.com>
1 parent e51de9d commit 3673799

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎packages/core/src/security/second-object-read-exposure.pin.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,18 @@ const CALLERS: Record<string, Classification> = {
264264
"resolves on the target (the engine's `referenceExists` probe) and answers `reference_not_found` or nothing, " +
265265
'never a field of the target',
266266
},
267+
// The grant-holder membership refusal's hand-off to that check.
268+
'packages/plugins/plugin-security/src/grant-holder-membership-refusal.ts': {
269+
kind: 'not-a-served-read',
270+
reason:
271+
"the grant-holder membership refusal (`referenceCheckAsksCaller`, `callerReadsHolder`) asks whether a grant's `user_id` is a reference " +
272+
"the write-path reference check judges. Its one read of the target is the CALLER's own read door, projected to " +
273+
'`id`, and its answer only decides whether that check (`engine-referential-integrity.ts`, its row) answers the ' +
274+
'holder; it reads no field of the target and serves nothing of it. Pinned by ' +
275+
'`packages/plugins/plugin-security/src/grant-holder-membership-refusal.test.ts` (a holder the caller cannot read ' +
276+
"is read only through the caller's own door, projected to `id`, and the answer served is the same whatever the " +
277+
'target holds)',
278+
},
267279
// [#25522 cut 14] The validation-predicate reads, moved out of engine.ts.
268280
'packages/objectql/src/engine-master-detail-related.ts': {
269281
kind: 'not-a-served-read',

‎packages/plugins/plugin-security/src/grant-holder-membership-refusal.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,30 @@ describe('a refused grant holder the caller cannot read is answered as a holder
568568
});
569569
}
570570

571+
it("a holder the caller cannot read is read only through the caller's own door, projected to its id, and no membership is read for it", async () => {
572+
for (const store of STORES) {
573+
const h = await bootWith(store);
574+
const reads: Array<{ object: string; query: any }> = [];
575+
const find = h.engine.find.bind(h.engine);
576+
vi.spyOn(h.engine, 'find').mockImplementation(async (object: string, query?: any) => {
577+
reads.push({ object, query });
578+
return find(object, query);
579+
});
580+
expectMembershipRefusal(await refusalOf(() => h.engine.insert(
581+
'sys_user_position', { user_id: HOLDER, position: 'qa_rep' }, { context: OWN_ROW_ADMIN_A } as any,
582+
)), store);
583+
const namesHolder = (q: any) => JSON.stringify(q?.where ?? null).includes(`"${HOLDER}"`);
584+
const holderReads = reads.filter((r) => r.object === 'sys_user' && namesHolder(r.query));
585+
expect(holderReads.length, store).toBeGreaterThan(0);
586+
for (const r of holderReads) {
587+
expect(r.query?.context?.isSystem, store).toBeFalsy();
588+
expect(r.query?.context?.userId, store).toBe(OWN_ROW_ADMIN_A.userId);
589+
expect(r.query?.fields, store).toEqual(['id']);
590+
}
591+
expect(reads.filter((r) => r.object === 'sys_member' && namesHolder(r.query)), store).toEqual([]);
592+
}
593+
});
594+
571595
it('a holder the caller CAN read keeps the membership refusal; a readable member is admitted', async () => {
572596
const h = await bootWith('member elsewhere');
573597
// The caller's own row is readable, and the caller is no member of org_a.

0 commit comments

Comments
 (0)