Skip to content

Commit c50654e

Browse files
committed
fix(security): let the admin's contract field locks bind
clm_admin held modifyAllRecords on clm_contract. Since ADR-0066's 2026-11-02 note a super-user set votes editable on every field of its object, so the 17 stamped-field locks (routing flags, stage timestamps, AI fields) bound no administrator; 18.3 lints it as security-superuser-field-mask-inert. Per the ruling on #196 (letter A, the locks win), the contract entry now grants viewAllRecords + writeScope 'org' + allowTransfer instead: every row readable, every row editable and deletable, owner reassign, and no edit vote on the locked fields. The six child entries keep their super-user bits; they lock nothing. The header comment now says a lock binds only without modifyAll and whole-row write comes from writeScope. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017nzWFRUo2U7evMkPdVniAn
1 parent b38df5a commit c50654e

1 file changed

Lines changed: 38 additions & 15 deletions

File tree

‎src/profiles/admin.profile.ts‎

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,37 @@ import { CONTRACT_STAMPED_FIELDS, PARTY_ASSESSED_FIELDS, inList, openAllExcept,
1111
* write access to the four configuration objects that every other set only
1212
* reads, and all seven action gates.
1313
*
14-
* `viewAllRecords` / `modifyAllRecords` on the private contract and its
15-
* children: an administrator reaches every row without a sharing rule, and
16-
* `modifyAllRecords` is what lets them reassign a contract's business owner
17-
* (`allowTransfer` is authored beside it so the capability is readable here
18-
* rather than implied).
14+
* ## The contract: whole-row reach without Modify All
15+
*
16+
* A field lock binds only the holders of a set that does NOT carry
17+
* `modifyAllRecords` on the object. Since ADR-0066's 2026-11-02 note
18+
* (objectstack#29106), a set holding a super-user bit votes on every field of
19+
* that object in the field-permission merge: `viewAllRecords` votes readable,
20+
* `modifyAllRecords` votes readable AND editable. Field votes merge most
21+
* permissively, so with `modifyAllRecords` here every stamped-field lock below
22+
* would bind no administrator (lint `security-superuser-field-mask-inert`).
23+
* The locks win (§04: the routing flags, the stage timestamps and the AI
24+
* fields are read-only for every position; issue #196, ruling A), so the
25+
* contract entry carries no `modifyAllRecords`, and the administrator's reach
26+
* is spelled out bit by bit:
27+
*
28+
* - `viewAllRecords` — every row, past the private OWD and without a sharing
29+
* rule. It never votes an edit.
30+
* - `writeScope: 'org'` — edit and delete on every row of the tenant. Beside
31+
* `viewAllRecords` it is read and honoured: the write-scope resolver
32+
* short-circuits on `modifyAllRecords` alone (`@objectstack/spec`
33+
* `permission.zod.ts`, 18.3.0).
34+
* - `allowTransfer` — reassigning a contract's business owner (`owner_id`);
35+
* the platform's ownership guard refuses that write to anyone without it.
36+
*
37+
* The six child objects keep `viewAllRecords` / `modifyAllRecords`: this file
38+
* locks none of their fields, so the bypass hides nothing there.
1939
*
2040
* ## Why this set carries "allow everything" row policies
2141
*
22-
* The super-user bits skip ownership and sharing. They do NOT skip business
23-
* row-level security on these objects: the platform drops RLS for a Modify
24-
* All Data holder only on an object whose exposure posture is
42+
* Neither the contract's org write scope nor the children's super-user bits
43+
* skip business row-level security on these objects: the platform drops RLS
44+
* for a Modify All Data holder only on an object whose exposure posture is
2545
* `access.default: 'private'` (ADR-0066 D2), and the CLM objects declare an
2646
* OWD (`sharingModel`), not that posture. So the policies of every set an
2747
* administrator holds still apply and OR-combine — and the administrator
@@ -34,16 +54,19 @@ import { CONTRACT_STAMPED_FIELDS, PARTY_ASSESSED_FIELDS, inList, openAllExcept,
3454
* Same pattern, same reason as the companions in `legal.profile.ts`. Each
3555
* policy is the whole vocabulary of the field it names, read from the object.
3656
*
37-
* The super-user bits do NOT bypass field-level security, and field masks
38-
* merge most permissively only among the sets that declare a field
39-
* (`_grants.ts`, `open`): an administrator also holds `clm_requester`, whose
40-
* masks would otherwise apply to them. Every field another set locks or hides
41-
* is opened here explicitly.
57+
* ## Field locks
58+
*
59+
* Field masks merge most permissively among the sets that vote on a field: a
60+
* set votes when it declares the field (`_grants.ts`, `open`) or holds a
61+
* super-user bit on its object. An administrator also holds `clm_requester`,
62+
* whose masks would otherwise apply to them, so every field another set locks
63+
* or hides is opened here explicitly.
4264
*
4365
* What even the administrator may not do by hand is write the fields §04 locks
4466
* for every position: the routing flags, the stage timestamps and the AI
4567
* fields have exactly one writer each (hooks, flows and the adopt action,
46-
* under a system context), and a hand edit would forge an audit trail.
68+
* under a system context), and a hand edit would forge an audit trail. A
69+
* write that names one is refused with 403 "Field write denied".
4770
*/
4871
const full = { allowCreate: true, allowRead: true, allowEdit: true, allowDelete: true, viewAllRecords: true, modifyAllRecords: true } as const;
4972
const config = { allowCreate: true, allowRead: true, allowEdit: true, allowDelete: true } as const;
@@ -63,7 +86,7 @@ export const AdminSet = definePermissionSet({
6386
'manage_approval_rules',
6487
],
6588
objects: {
66-
clm_contract: { ...full, allowTransfer: true },
89+
clm_contract: { allowCreate: true, allowRead: true, allowEdit: true, allowDelete: true, viewAllRecords: true, writeScope: 'org', allowTransfer: true },
6790
clm_contract_version: full,
6891
clm_review: full,
6992
clm_deviation: full,

0 commit comments

Comments
 (0)