Repository navigation
Commit 695b9db
fix(plugin-security)!: an app-authored elevation's reads and writes are judged by its caller's organization wall (#36386)
Clause-②: no (narrowing)
Metadata-protocol: none
## 维护者速读
- **改了什么:** 动作代码、以系统身份运行的钩子和以系统身份运行的流程,在替某个登录用户读写数据时,按该用户自己的组织边界判定。
- 用户的组织边界不放行时,读不到任何租户数据;写入一律拒绝,删除按「找不到」处理。所谓不放行:isolated 下是没有选当前组织,group
下是没有任何成员关系,single 下是不属于任何组织。group 下的成员可以读写自己所有组织的并集。
- 已选组织的用户照常使用。
- 写入数据里点名别的组织,会被拒绝。
- **为什么:** 这是安全席位的高危派单,维护者裁定 ⑤ A。
- **若出错:** 只会多拒,不会多放。平台自身的系统任务、定时任务不受影响。可以撤回。
- **要你做什么:** 本 PR 申报为收窄,契约审核 PASS 在案后,需要授权账号批准当前 head。
## What changes
Rule: **elevation lifts a caller's business rules, never the
organization wall.** This applies to an action body, a hook that runs as
system, and a flow that runs as system. Their reads and writes are
judged by the organization wall of the caller they run for (ADR-0095 D1,
ADR-0123 D1/D2). The full FROM/TO is in `.changeset/sec2-wf9p.md`.
- **A caller the wall denies:**
- reads resolve to nothing;
- delete and purge follow the read rule (a predicate delete matches
nothing; a by-id delete answers `404`);
- other writes are refused `403 PERMISSION_DENIED`, naming the missing
organization or membership.
- **A write whose own data names an organization outside the caller's
wall, or empties a row's organization:** refused `403`.
- **On a federated object:** reads are those of the caller's
organization scope, and a by-id write of a row outside it answers `404`.
The check is read inside the write's own transaction.
- **A run that began for no caller:** unchanged, including after an
approval decision. The decider is its attribution user, not its caller.
Its trigger user stays the writer, so approval submitter exclusion and
run history answer as before.
Packages:
- `@objectstack/plugin-security`: the wall.
- `@objectstack/core`: exports `RUN_CALLER`, `markRunCaller` and
`runCallerOf`, a server-constructed mark.
- `@objectstack/service-automation`: a system run's data context carries
its user's membership set and posture rung, seeded at run setup. A run
whose own user is not its caller carries neither.
- `@objectstack/objectql` and `@objectstack/trigger-record-change`:
record that a run began for no caller.
- `@objectstack/spec`: the `runAs` descriptions of flows and hooks and
the `body` description of actions state the limit. The change is
description-only, and the reference pages are regenerated.
## Why
A no-card hardening order from the security seat. The details stay with
the seat.
## Tests
- **Real stack**
(`packages/plugins/organizations/src/elevated-organization-wall*.wall.test.ts`):
- each elevation kind under each tenancy posture, with controls for a
caller with an active organization;
- the write rules, and the by-id check inside a body's own transaction;
- the run-that-began-for-no-caller cases, including a child run.
- **Module pins** in plugin-security, service-automation, objectql and
trigger-record-change.
- **plugin-approvals:** the decider stays excluded as submitter on a
downstream approval.
Every pin is red on its base and green on the head, and each guard was
ablated and restored.
## Verification
- CI on the head: every required check is green.
- The dogfood battery runs on the final head.
- Contract review: by the security seat, recorded on this PR.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request. (A no-card order.)
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`. (The reference
pages changed are regenerated.)
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_017xRBcW9L8Noz9BxEwjwiov
<!-- signed: security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6e643cc commit 695b9db
45 files changed
Lines changed: 3261 additions & 68 deletions
File tree
- .changeset
- content/docs
- automation
- permissions
- references
- api
- automation
- data
- kernel
- ui
- packages
- core/src/security
- objectql/src
- plugins
- organizations/src
- plugin-approvals/src
- plugin-security/src
- runtime/src
- services/service-automation/src
- builtin
- spec/src
- automation
- data
- ui
- triggers/trigger-record-change/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
604 | 605 | | |
605 | 606 | | |
606 | 607 | | |
607 | | - | |
| 608 | + | |
608 | 609 | | |
609 | 610 | | |
610 | 611 | | |
| |||
0 commit comments