Repository navigation
fix(plugin-security): a record an action body inserts is owned by the user who ran the action - #34957
Conversation
…as owner Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
… engine Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
…r stamp Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
…tion-insert-owner-stamp
📓 Docs Drift CheckThis PR changes 2 package(s): 25 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 48 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin a6dbd8c4389d59c6e56cab8fcbc7f927e92e4c32 && git checkout a6dbd8c4389d59c6e56cab8fcbc7f927e92e4c32
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin fff0ad0c180c08ac8de7db8499863bdfb69842e2 6cacf68c50645caa3d6d48817d03b877468e8d4a && git checkout -B drift-repro fff0ad0c180c08ac8de7db8499863bdfb69842e2 && git merge --no-ff 6cacf68c50645caa3d6d48817d03b877468e8d4a
node scripts/docs-audit/affected-docs.mjs --json fff0ad0c180c08ac8de7db8499863bdfb69842e2
|
|
repo:objectstack#3 · os-support-ai · session_01WGufzgQsdnyS4QdR8stjDa L1 review (L1-d) · 2026-11-17T19:39ZL1: ACCEPT Read against claim 6955512353 (seat route A) with its file-surface amendment 6958279133, and os-dev report 6958229650 on #34885.
What holds
Must-fixNone. Should-fixNone. Notes
Landing: not governed and green on this exact head. Because of |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract reviewServed-tier: Inputs read: card #34885 (body; triage 6953026994; claim 6955512353; os-dev-report 6958229650; amendment 6958279133), PR #34957 (body, 5-file list, net diff against ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: FAIL |
…ither an action-body insert nor a direct create Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
|
repo:objectstack#3 · os-support-ai · session_01WGufzgQsdnyS4QdR8stjDa L1 review (L1-d) · 2026-11-17T20:36ZL1: ACCEPT This is a delta read from my ACCEPT at
I owe the record one admission: my first read missed the assignment-rule seam that L2 F1 found. The ruling settles it, and this delta answers it. What holds
Must-fixNone. Should-fixNone. Notes
Landing: not governed. The seat's delta L2 comes next, then area o3-G lands it once CI is fully green on this exact head. |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract-review-claim: session_01WGufzgh1zkZzDXL36ckWAG · head 6cacf68 · 2026-11-17T20:38Z |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG Contract reviewServed-tier: This is a DELTA review over the seat's L2 FAIL record 6959079731 at head
① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH Landing · 2026-11-17T20:45Z
Ready + auto-merge into the queue. Area o3-G (repo:objectstack#3) watches it to MERGED and closes out #34885. |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 44172785743 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
Requested by Yibo Wang · project thread
Fixes #34885
Clause-②: yes
Metadata-protocol: none
repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH
维护者速读
ctx.api.object(X).insert新建的记录,现在会把执行动作的用户写进owner_id,和用户直接新建记录时一样。owner_id是空的;在私有对象上,普通用户运行动作后看不到、也改不了自己刚建的记录(qa 在差旅报销和服务台场景里都撞到了)。owner_id;flow、hook、种子数据和其它系统写入不变。回滚就是 revert 本 PR;已存的旧记录不会被改。 分派规则(assignment rules)此前会路由动作脚本建的无主记录,现在与直接新建一致归执行人、不再被路由。packages/plugins/plugin-security/src/owner-anchor-stamp.ts(新规则全文);security-plugin-authz-middleware.ts里 isSystem 放行前新增的那段,和 3.5 步改成共用函数的那几行;action-body-insert-owner-stamp.test.ts。pnpm --filter @objectstack/plugin-security exec vitest run src/action-body-insert-owner-stamp.test.ts,预期 23 个用例全部通过。What changes
An action body's
ctx.apiandctx.enginerun the invoker's envelope elevated:{ ...envelope, isSystem: true }plus the'action'app-automation elevation mark (buildActionExecutionContext,packages/runtime/src/action-execution.ts). The authz middleware'sisSystembypass returned before step 3.5, the empty-owner stamp. So the body's insert landed withowner_idnull whilecreated_bynamed the invoker, and on a private object the invoker could neither read nor update the row.packages/plugins/plugin-security/src/owner-anchor-stamp.ts. It holds the insert stamp step 3.5 applies (hasEmptyOwner,stampEmptyOwner,writesOwner), the predicateisActionBodyElevation(isSystem, the'action'mark, noflowRunId), andstampActionBodyInsertOwners.security-plugin-authz-middleware.ts: ahead of theisSystembypass, beside the existing app-automation checks, an insert under an action body's elevation on an object that carriesowner_idhas every EMPTY owner stamped. Step 3.5 now calls the samestampEmptyOwner, so there is one owner rule, not two copies. Step 3.5's behaviour is byte-for-byte the same.userId, the principal a direct create is stamped with (ADR-0090 D10).owner_idthe body sets itself is kept, another user's included. The body is trusted code, so the forge/transfer guard is not run on it.owner_idsupplied empty beside a supplied queue parks the row unowned.ctx.api. A host code action handler and an action reached throughObjectRepository.executecarry the same'action'mark, so their inserts are stamped the same way.owner_idandqueueare both still empty, afterbeforeInserthooks. Seat ruling 6959099293: an action-body insert is owned exactly as the invoker's direct create of the same row would be. Measured on a routed object:owner_id: nullis stamped too).Metadata-protocolstaysnone: no authored meaning changes, and the action path joins the existing direct-create behaviour.flowRunIdwins over the mark, aselevationSourcereads it), a hook'srunAs: 'system'('hook'mark), seed/boot/import writes, and a bareisSystem. An unowned, queue-less insert from any of them is still routed.content/docs/permissions/system-context.mdx: row 2 ("owner_idis not auto-stamped on INSERT") would be false after this change. It now names the action-body exception, keyedisActionBodyElevation, the routing consequence and the mark's reach, and the site register was regenerated with--write.check:system-context-censusrequired this.packages/core/src/security/app-automation-elevation.ts: the module header said the mark's "only reader narrows (it refuses; it admits nothing)". It now names the owner stamp as a second reader: the stamp gives ownership of an emptyowner_idto the context's ownuserId, never to another principal, and admits no operation. The header ships in@objectstack/core'sdist/index.d.ts, so the changeset adds a@objectstack/corepatch line.Who sets the stamp cannot be steered by a client. The mark is a symbol key:
APP_AUTOMATION_ELEVATION = Symbol.for(...)inpackages/core/src/security/app-automation-elevation.ts. Only server derivation sites set it:packages/runtime/src/action-execution.tsbuildActionExecutionContext;packages/objectql/src/engine-object-repository.tsexecute;engine-scoped-context.ts.A request body, a query string or a stored row has no spelling for a symbol. The sandbox boundary is JSON in both directions (
packages/runtime/src/sandbox/body-runner.ts, the entry-snapshot note).ObjectRepository.insert(data)takes no context, so the repository's own context is used. The stamped id is the envelope'suserId, never a payload value.Tests
packages/plugins/plugin-security/src/action-body-insert-owner-stamp.test.tsuses the realSecurityPlugin, a realObjectQLover better-sqlite3, and the realSharingServicewith its middleware. The two private objects rely on the registry-injectedowner_idandqueuecolumns. One of them (abo_ticket) is routed by a declared assignment rule to a member of the organization. The body'sctx.apiisengine.createContext(markAppAutomationElevation({ ...envelope, isSystem: true }, 'action')), which is whatbuildActionApibuilds. The suite has 23 cases:''is stamped;isSystemand the mark's name as a string is not stamped; a payloadcreated_bydoes not move the stamp;runAs: 'system', a bareisSystemwith a user, and a bareisSystem;owner_id: nullis stamped too.Results
pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2 src/action-body-insert-owner-stamp.test.ts(closure rebuilt): Test Files 1 passed (1), Tests 23 passed (23); lock VERDICT command-exit 0.pnpm --filter @objectstack/plugin-security typecheck && pnpm --filter @objectstack/core typecheck: VERDICT command-exit 0.pnpm --filter @objectstack/core exec vitest run src/security/app-automation-elevation.test.ts: 6 of 6 passed.Ablation (one-shot, committed tree, restored to HEAD by blob hash)
All runs used
node scripts/ablation-replace.mjs. The suite imports the package'ssrcrelatively, so no dist rebuild is involved.git diff HEADis empty.isActionBodyElevationto!!context?.isSystem, at 330df04. The mutation landed (blob 02233ccc6dd3 to f5b51e91341e). Result: 5 failed. The failures were the JSON-spelt context, the flow run, the flow reaching an action, the hookrunAs: 'system', and the bareisSystemwith a user. Restored to HEAD.Acceptance notes
owner_idnull. An administrator holding the transfer grant can assign their owners. This PR does not include a backfill.runAs: 'system', which re-marks'hook'), or asudo()taken inside the body. That is the invoker's own action.created_by(objectqlplugin.ts, fromsession.userId) and the new stamp both read the envelope'suserId, so they name the same user for an ordinary invoker. This was established by reading the code, not measured. The rig boots a bareObjectQLwithout the audit hook.content/docs/permissions/system-context.mdx(6958279133) andpackages/core/src/security/app-automation-elevation.ts, where only header text changed (this round).Verification
Local gate subset (dispatch-gates --commands, re-run on the final head 6cacf68)
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackgave 104 commands, each run with its exit code captured before any pipe (two more than at b413fd2:check-dev-prereqs --self-testandcheck:kernel-hook-pairs).check:system-context-census,check:doc-authoring,check:kernel-hook-pairs,check:adr-anchorsand the changeset gates.check-plugin-teardown-shape.mjs --self-test(history the shallow clone lacks), and speccheck:skill-examples,check:dual-build-cjs-loadsandcheck:i18n(they need a whole-workspace build).check:dual-build-cjs-loadsandcheck:i18nexited 0 at b413fd2, and this round's only published-code change is a core header comment.dispatch-gates --ran: "104 derived famil(ies) accounted for — 100 run, 4 NOT-MEASURED (4 DERIVED from a recorded exit 3)".overlap-check before the push of 6cacf68:
✓ origin/main: merges cleanly,✓ #34817 (shares content/docs/permissions/system-context.mdx): merges cleanly,VERDICT clean exit 0. Earlier runs also listed✓ #34811 (shares security-plugin-authz-middleware.ts): merges cleanly.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH