Skip to content

Commit 74d2e76

Browse files
committed
Merge origin/main into claude/project-thread-3giljf
Claude-Session: https://claude.ai/code/session_01Utp6CZu9RRx2o8sFUUpEPU Co-authored-by: Claude <noreply@anthropic.com>
2 parents 2990c4c + 14754c7 commit 74d2e76

33 files changed

Lines changed: 2428 additions & 181 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@objectstack/plugin-security': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
fix(security): app-authored automation's system elevation does not change or delete the rows of an append-only object
7+
8+
Clause-②: no (narrowing: a system flow's, a system hook body's and an action body's update or delete of a managedBy 'append-only' object, and their delete of a record such a ledger row references, are refused at run time)
9+
Metadata-protocol: none
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No key of any metadata schema is removed, renamed or re-shaped, so there is nothing for `objectstack migrate meta` to rewrite and no tombstone. What changes is the run-time answer to an elevated automation's update or delete of an append-only object, and to its delete of a record such an object references. -->
12+
13+
**BREAKING** (a served-set narrowing) for app-authored automation that, while it runs as system, updates or deletes the rows of an object declared `managedBy: 'append-only'` — the audit log (`sys_audit_log`), the activity feed (`sys_activity`), the mail logs, the job-run log, the approval actions and the rest of that bucket — or deletes a record that one of those rows references. A census of the flows, hooks and action bodies in this repository and in HotCRM found none that does.
14+
15+
An append-only object is a ledger: its rows record what happened, and the platform service that owns the object writes them. A flow with `runAs: 'system'`, a sandboxed hook body that runs as system, and an action body — sandboxed, or through the action's engine facade — run elevated. Their elevation is the one the identity-assignment refusal already judges, and the same check now covers ledgers:
16+
17+
- An update, transfer, delete, purge or restore of an append-only object's rows from such a context answers `403 PERMISSION_DENIED`, and nothing is written. This check covers those five verbs; an insert is not judged by it. A flow's write node fails and the run hands the refusal to its caller; a hook's refusal aborts the triggering write under the default `onError: 'abort'`.
18+
- A delete of a record that a ledger row references — a user that an audit row or an activity row names, for example — is refused the same way, whole: deleting the record would clear that reference on the ledger row, which is a change to an append-only object made under the automation's elevation. Nothing is deleted and the ledger row does not move. The message says so: deleting this record would change a record in an append-only ledger that references it.
19+
- The message names the object, the source and the rule. The set is read from each object's `managedBy` on the live registry, so an append-only object a plugin registers is covered the day it registers.
20+
21+
Unchanged: reads of every append-only object from the same automation. Its writes to every other object — except a delete of a record a ledger row references, above — and the audit and activity rows the platform records for those writes. The platform's own writers — the retention sweeper, migrations and backfills, the audit seal, every service writing under a system context of its own — which carry neither a flow run nor the app-automation mark; a platform delete of a record a ledger row references still lands and clears the reference.
22+
23+
**What changes for you.** A flow, hook body or action body that rewrote or removed a ledger row while elevated now fails. Keep any value your automation must change on an object of your own app, and leave the ledger to the platform service that writes it; retention of ledger rows is the platform's lifecycle policy, declared on the object. An elevated automation that deleted a record a ledger row references — most often a user — now fails too: keep the record and retire it instead (for a user, deactivate it), or let the platform's own door delete it.
24+
25+
`@objectstack/spec`: the flow `runAs`, hook `runAs` and action `body` descriptions state the rule.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@objectstack/plugin-security': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
fix(plugin-security)!: a caller whose read of an object is refused is explained the same for every record id, decided by that refusal
7+
8+
Clause-②: yes (narrowing) — a record-grained `security.explain` asked by a principal about its own access, where that principal's read of the object is refused, answers every record id with one explanation: `visible: false`, `decidedBy` the layer that refused the read, singular and batch alike, on every operation; the comment and attachment gates that admit a parent edit on that explanation's `update` verdict follow it.
9+
Metadata-protocol: none
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export is removed or retyped: what moves is the answer `security.explain` computes for one kind of asker, and the contract text that states it. Nothing at rest records that answer, so there is nothing for a migration to rewrite and no tombstone. -->
12+
13+
**BREAKING.** A principal explaining its own access, whose read of the object is refused (a declared 4xx, such as no read grant on the object, or a read capability the object asks that the principal does not hold), gets the same explanation for every record id (ruling of record 6787890900):
14+
15+
- the record verdict is `visible: false`, with `decidedBy` naming the layer that refused the read (`object_crud`, `required_permissions`), taken from a read-operation pass; where no layer names the refusal, `decidedBy` is omitted, for every id alike;
16+
- every layer's per-record attribution is the one an id no row carries gets, prefaced with the sentence that the principal's own read of this object is refused;
17+
- the explanation never tells a stored record from a missing one, on any operation, and the batch form (`recordIds`) answers each id the same way;
18+
- the comment gate (`@objectstack/plugin-audit`) and the attachment gate (`@objectstack/service-storage`), where they judge a parent edit by the caller's own `update` explanation of the parent record, admit it only when that explanation is allowed and visible; so they refuse a caller who holds edit on the parent object while its read of that object is refused, whatever kind of principal it is.
19+
20+
This is the security service's explain (`security.explain`, the REST explain route and every in-process caller of the service). The plugin-security engine export `explainAccess(deps, input)`, which is handed no asker, keeps answering a refused read by its own read question, as before.
21+
22+
A principal asking for itself is recognised by the request (no other user named), whatever kind of principal it is. A principal who can read the object is answered as before, and an asker explaining another user keeps the answer it had: an id it cannot read is the missing record, with no decider for the read.
23+
24+
What to do: a client that showed a per-record explanation to a principal without read access should expect one answer for every record id, naming the read refusal. To explain a record's own story, or to let a principal comment on or attach to a record it edits, grant the principal read on the object (and any capability the object's read requires).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
fix(metadata-protocol): a refused package publish leaves nothing live on a runtime that cannot roll back
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A package publish (`publishPackageDrafts`, behind `POST /packages/:id/publish-drafts` and Studio's publish-all) is all-or-nothing (ADR-0067 D2), and relied on `engine.transaction()` to undo the drafts it had promoted before a refused one. On a runtime whose default driver declares no transactions, such as the remote Turso transport, the engine runs that callback with no rollback. A draft refused at item 9 of 11 therefore left items 1–8 live while the response said nothing had taken effect.
11+
12+
Where the runtime cannot roll back (the `engineCanRollBack` check that `/discovery`'s `transactionalBatch` already answers), the publish now judges every draft before it promotes any, so a refusal leaves every draft pending and nothing served. A failure that only the writes themselves can meet, such as a draft saved under the publish or a store fault, undoes every promotion already made before the refusal is reported: rows the publish created are removed, rows it edited go back to their prior version, and each consumed draft is put back unchanged. Each undo step leaves its own history event. An undo that itself fails is named in `failed[]`, without `BATCH_ABORTED`, and in an error log, instead of being reported as "nothing landed". Runtimes with a real transaction behave exactly as before.

0 commit comments

Comments
 (0)