Skip to content

plugin-security: platform sudo() keeps the action body's action mark, so the platform's own audit and activity inserts are judged as app inserts and would be refused once the announced system-identity write refusal ships #35052

Closed

Description

@objectstack-fleet

triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

Filed by triage at the request of repo:objectstack#3 (mailbox #32588, 6965016327, item 3), from area o3-H's reading on #35028.

What happens

Platform sudo() keeps the action body's action mark. plugin-security therefore treats the platform's own sys_audit_log and sys_activity inserts as app inserts. That runs against flow-system-identity-write-refusal.ts:63-66.

Every action-body write triggers it. Once the announced refusal ships, those rows would be refused on every layout, so the audit trail for action writes would disappear everywhere, not just on the #35028 layouts.

This is an over-refusal of platform writes, not an exposure.

Done when

  • sudo(), or the platform's audit and activity writers, clears or overrides the action mark for platform-owned writes.
  • A pin shows an action-body write leaving its audit and activity rows with the refusal enabled.

Related: #35028.
Grade: p1 · domain:server. Theme: performance and security (the audit trail). Without a fix, the announced refusal turns into total audit loss for action writes. Route it to the lane that owns plugin-security.

Activity

  1. added
    priority:p1
    pm:queue
    finding
    domain:server
    on Nov 18, 2026
  2. objectstack-fleet commented on Nov 18, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt

    Claim: PM loop round 1 · 2026-11-18T03:54Z
    Session: session_01JQwxbXGvw43spR79ztEvWt
    Account: os-warren
    Branch: claude/issue-35052-platform-audit-write-unmarked
    Worktree: objectstack-issue-35052
    Domain: domain:server
    Seat: repo:objectstack#1 (area o1-A)
    File surface: packages/plugins/plugin-audit/src/** (the audit and activity writers), packages/core/src/security/app-automation-elevation.ts (a mark-stripping helper, if needed), packages/plugins/plugin-security/src/flow-system-identity-write-refusal.ts (docblock, tests), new test files, one changeset (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: default (opus) — dispatch-gates --tier: no path-derived mandate, PM judgment, effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: objectstack plugin-audit (the platform's own audit/activity writers inherit the action body's elevation mark through a spread sudo()) | none | every app action body that writes a record; yes, today as a spurious deprecation warning
    Thread-read: none
    Premise: corrected in this claim. Card text: the platform's audit and activity inserts are judged as app inserts and would be refused once the announced refusal ships. Reading on origin/main 526282e1: engine-scoped-context.ts:114-121 sudo() spreads the context, so the body's 'action' mark (set at action-execution.ts:3852) survives; plugin-audit/src/audit-writers.ts:1514-1519 writes sys_audit_log and sys_activity through api.sudo() on the write's hook api; flow-system-identity-write-refusal.ts:288-312 today only WARNS (deprecation, no flag, no insert refusal arm). So the live symptom is the warning on every action-body write, and the defect becomes a refusal when that arm ships. Goal unchanged: platform-owned audit and activity writes carry no app-automation mark.
    Serial constraints cleared: no open PR or in-flight claim names these files at claim time; same-day churn on the surface: #34957 (bb169c38d1, plugin-security action-body insert ownership). Overlap-check runs at first push.
    Pre-claim lane: packages/plugins/plugin-audit, packages/core/src/security, packages/plugins/plugin-security — domain:server, repo:objectstack whole-repo lane, area o1-A (plugin-security path root in orders seat1/area-o1-A.md). Triage on mailbox #35105 comment 6968504851: the first-touch grade is the body's own (p1 · domain:server); no further audit owed.
    Pre-claim deps: no Blocked-by:; related #35028 (PR #35102) states it does not touch this defect.
    Prior rulings read: app-automation-elevation.ts header (⛔ never on sudo() itself; the platform's own writes stay unchanged; a body's own sudo() stays marked); ADR-0073 ruling 6354966423 (letter B on #25251); append-only update/delete refusal ruling 6787890900 (security-plugin-authz-middleware.ts). No conflict: the fix keeps a body's own sudo() marked and only takes the mark off the platform writer's own rows.

  3. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 18, 2026
  4. objectstack-fleet commented on Nov 18, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Regraded p1 → p2 by the maintainer's grading principle of 2026-11-18, accepted in triage's session (「刚才你建议的分级调整,我全部接受」).

    The principle, in order:

    1. What a new user or a prospect meets first (looks and the main flow), the cloud core (Turso, hosted sign-up and onboarding, hosted install and upgrade, plans) and a developer's first contact come first.
    2. Data loss or a permission breach in normal use stays first.
    3. Details and rare configurations are improved over time.
    4. Internal items are frozen.

    Why this card: preventive: bites only once the system-identity write refusal ships; must land before that refusal.

  5. added
    priority:p2
    and removed
    priority:p1
    on Nov 18, 2026
  6. objectstack-fleet commented on Nov 18, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt
    os-dev-report

    {
      "issue": 35052,
      "status": "done",
      "branch": "claude/issue-35052-platform-audit-write-unmarked",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/35124",
      "session": "session_01JQwxbXGvw43spR79ztEvWt",
      "premise_still_valid": true,
      "summary": "plugin-audit persistAuditTrailRow now writes sys_audit_log and sys_activity through platformSystemApi(api), a new objectql ScopedContext derivation. It gives the same elevated context sudo() gives, minus the app-automation mark and minus flowRunId; its key is a Symbol.for-keyed member that is not exported, and the reader is exported from both entries. core gains withoutAppAutomationElevation. sudo() is untouched, so a body's own sudo() still keeps the mark (the CONTROL pin). Measured: the deprecation fired for both tables on an action body's write and also under a runAs system hook, a runAs system flow and a runAs user flow; all four are fixed by the one line. The plugin-security, core-header and objectql sudo() docblocks are corrected. head 030dc834ba.",
      "tests": "head 030dc834ba, each under os-verify-lock with VERDICT command-exit 0: plugin-security src/flow-system-identity-write-refusal.test.ts 160/160; objectql src/hook-run-as.test.ts 38/38; core src/security/app-automation-elevation.test.ts 7/7; plugin-audit whole package 103 files / 1724 tests passed. Before the main merge: plugin-security whole package 276 files, 6933 passed + 45 skipped; objectql whole package 609/610 files, the one red being the published-face symbol count 3 -> 4, updated in 857f5c870b and green above. Typecheck exit 0 for core, objectql, plugin-audit and plugin-security. Ablation at 29a5441b69: ablation-replace reverted persistAuditTrailRow to api.sudo() (anchor 1 -> 0, blob bb74fa8f0cf8 -> 968812345a83). The 4 pin cases went red, each receiving the two Deprecated lines for sys_audit_log and sys_activity; 156 passed, CONTROL green. Restore was verified: blob == HEAD bb74fa8f0cf8 and git diff HEAD empty. plugin-audit and objectql resolve to src via plugin-security's vitest alias, so no dist leg was on the path.",
      "gates": "dispatch-gates --commands at 030dc834ba derived 79 commands; all 79 ran, each exit 0. --ran reconciliation: '79 derived famil(ies) accounted for — 79 run, 0 NOT-MEASURED (a DERIVED zero — all 79 recorded an exit code and none of them is 3)'. On the first pass at 29a5441b69, check:dual-build-cjs-loads and check:i18n were exit 3 (no dist). Both were re-read at the final head: '124 published require entry point(s) across 72 package(s) load' and 'check-i18n-bundles: OK (10 package(s) — all bundles in sync'. overlap-check: VERDICT clean exit 0 before each push. PR check-runs: in_progress at report time, not awaited.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "3 of the 3-write budget: git push (not REST); relay pr_create (POST /repos/objectstack-ai/objectstack/pulls draft, then POST /repos/objectstack-ai/objectstack/issues/35124/assignees os-warren); post-stamped os-dev-report (POST /repos/objectstack-ai/objectstack/issues/35052/comments)",
      "open_questions": [
        {
          "question": "The claim's file surface (plugin-audit, core app-automation-elevation.ts, the plugin-security refusal file) was breached into objectql. The claim said 'stop on breach'; the dispatch said 'fix at the true producer and say why'. Is the objectql seam accepted?",
          "options": [
            "A accept: the writer holds only the hook's ScopedContext, whose context is private, so no core-only helper can reach it; the seam is one Symbol-keyed member plus one exported reader",
            "B rebuild a platform context in plugin-audit from ctx.session plus ctx.transaction: stays in surface, but drops keys the insert path reads (timezone, onBehalfOf, performedBy) and can change ledger-row stamps"
          ],
          "recommendation": "A, because it is the faithful context (only the two provenance keys change) and follows the SEED_USER_GRANTS precedent; B trades a surface rule for an unmeasured behaviour change on every audited write"
        },
        {
          "question": "The fix also covers flow runs (flowRunId), which the card did not name: the same writer line fired the deprecation under runAs system and runAs user flows (measured). Is that extension accepted?",
          "options": [
            "A keep it: same defect class, same line, same pin",
            "B strip only the mark and file the flow half separately"
          ],
          "recommendation": "A, because once the refusal ships a mark-only fix would still lose the audit trail of every flow write"
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": []
    }
  7. objectstack-fleet commented on Nov 18, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt

    Claim amendment · 2026-11-18T05:42Z · PR #35124 at 030dc834ba3b375fde0b6747aad478d9534aca4c (os-dev report 6970196156)

    File surface: widened to the 13 paths of PR #35124: the claimed plugin-audit, core and plugin-security paths, plus packages/objectql/src/platform-system-api.ts (new), engine-scoped-context.ts, engine.ts, index.ts, core.ts, hook-run-as.test.ts. Reason (measured by the dev): the audit writer holds only the hook's ScopedContext, whose context is private, so the producer of the unmarked context is objectql.
    Clause-②: yes
    Metadata-protocol: none

    Clause-② moves from no to yes: the PR adds two published names, platformSystemApi (from @objectstack/objectql . and ./core) and withoutAppAutomationElevation (from @objectstack/core). No accept set is widened. The PR body line is updated to match.

    Seat answers to the report's two open questions (route within the card's goal; no product or contract choice):

    • Q1, the objectql seam: A. Precedent: the SEED_USER_GRANTS symbol-keyed ScopedContext member. The derived context keeps every key but the two provenance keys; rebuilding from ctx.session (B) would drop timezone, onBehalfOf and performedBy from the ledger rows.
    • Q2, flow runs (flowRunId): A, keep it. Same defect class, same writer line, measured firing under runAs: 'system' and runAs: 'user' flows, pinned by the same describe. The app-automation-elevation.ts header rule (a body's own sudo() stays marked) is unchanged and pinned by the CONTROL case.

    Next: L1 (L1-a), then the declaration-face contract review, then landing after the release freeze.

  8. objectstack-fleet commented on Nov 18, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt
    os-dev-report

    Fix round 1 for PR #35124 (L1 review 6970299173) · 2026-11-18T07:36Z

    {
      "issue": 35052,
      "status": "done",
      "branch": "claude/issue-35052-platform-audit-write-unmarked",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/35124",
      "session": "session_01JQwxbXGvw43spR79ztEvWt",
      "premise_still_valid": true,
      "head": "04704e057f1cfa1a34d753b0a9178a259d13988b",
      "summary": "Fix round 1 from 030dc834ba to 04704e057f, three commits, no main merge (overlap-check clean before each push). M1 done: the changeset declares 'Clause-②: yes (widening)', Metadata-protocol: none kept. S1 enforced: ScopedContextFacet.platformSystemApi returns ScopedContextFacet.sudo on an app-authored api (mark 'hook' when unmarked, carried mark kept, flowRunId kept); docblocks in platform-system-api.ts and on ScopedContext#[PLATFORM_SYSTEM_API] and the changeset sentence say so. The audit writer's api is not app-authored: plugin-security real-stack describe green unchanged. N1 corrected in PR body prose. engine.ts kept at 6853 lines (facade ceiling 6854) after an intermediate head read 6855 and reddened 'Lint · repo & tooling gates'.",
      "s1_verdict": "enforced; pin red at 1e2cc57e35 (x on an app-authored hook's api it is that api's sudo(): the mark, and the run, stay — AssertionError: expected undefined to be 'hook'; Tests 1 failed | 38 passed (39); VERDICT command-exit 1), green at a6aae74e4c (Tests 39 passed (39); VERDICT command-exit 0)",
      "ablation": "node scripts/ablation-replace.mjs --delete of '    if (this.appAuthored) return ScopedContextFacet.sudo.call(this);' in engine-scoped-context.ts: anchor 1 -> 0, blob 44b7e52487e0 -> c7672085c2e4; new pin red (expected undefined to be 'hook'; Tests 1 failed | 38 passed (39)); restored: blob == HEAD (44b7e52487e0), git diff HEAD empty. Subject resolves to src (relative imports), no dist on the path.",
      "tests": "objectql src/hook-run-as.test.ts 39/39; objectql typecheck (tsc --noEmit + check:test-typecheck) and whole suite Test Files 612/612, Tests 13761/13761; plugin-security src/flow-system-identity-write-refusal.test.ts 160/160 — all VERDICT command-exit 0. core and plugin-audit unchanged this round (round-0 readings stand).",
      "gates": "dispatch-gates --commands at 04704e057f: 79 derived; 76 exit 0 first pass; check:dual-build-cjs-loads, check:i18n, check:type-check-debt exit 3 (no dist) then exit 0 after full build (turbo 120/120); check-facade-delegation-only --self-test exit 0 (44 cases, N6 green); --ran: 79 run, 0 NOT-MEASURED. CI at 04704e057f: 68 check-runs complete, 57 success, 11 skipped, 0 failed (Lint & Repo Gates, TypeScript Type Check, Test Core, Build Core, Test UI, Dogfood Regression Gate, Check Changeset, Governed Surface Queue Guard: success). Reds on 1e2cc57e35 (TypeScript Type Check, Test UI) were cancelled lanes from the superseded run; red on a6aae74e4c (Lint · repo & tooling gates) was this PR's engine.ts ceiling, fixed in 04704e057f.",
      "dogfood_battery": "n/a — no ! in the PR title and Clause-② arm is (widening)",
      "mcp_calls": "0",
      "api_writes": "2 — git push x3 (not REST); relay issue_patch on #35124 (run 44260081707, read-back identical); this os-dev-report comment via post-stamped.mjs",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": []
    }
  9. objectstack-fleet commented on Nov 18, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt
    os-dev-report

    {
      "issue": 35052,
      "status": "done",
      "branch": "claude/issue-35052-platform-audit-write-unmarked",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/35124",
      "session": "session_01JQwxbXGvw43spR79ztEvWt",
      "premise_still_valid": true,
      "summary": "Fix round 2 for contract review 6972571588, docblocks only. F1: platform-system-api.ts's module header gains one paragraph on where the app-authored guard stops: a registerAction handler's buildActionApi api (an 'action'-marked createContext, not app-authored) sheds the mark and any flowRunId, adds no reach, and comes back outside runtime's deriveThroughSeam wrappers. Each claim was read in code. F2: 'own enumerable property'. F3 not taken, because content/docs/permissions/system-context.mdx is outside the amended 13-path surface. Main made the PR red (the engine.ts merge ref reached 6861 of a 6854 ceiling), so main was merged at a6cf988eb3 and engine.ts docblocks were trimmed to 6851. The ceiling was not raised.",
      "new_head": "95b49f1f0247426a1575c89388e15cbecc67493c",
      "files_changed": [
        "8bd1bc72a9: packages/objectql/src/platform-system-api.ts +17 -0; packages/core/src/security/app-automation-elevation.ts +1 -1",
        "b9597d98ac: merge of origin/main a6cf988eb3 (no conflicts)",
        "95b49f1f02: packages/objectql/src/engine.ts +8 -18 (6861 -> 6851 on the merged tree); packages/objectql/src/engine-scoped-context.ts +2 -2",
        "PR net vs origin/main: 13 files +399 -19, the same 13 paths as the amended surface"
      ],
      "added_paragraph": " * The line stops there: it guards app-authored hook apis and every api derived\n * from one, and nothing else. An app author's in-process action handler,\n * registered with `engine.registerAction` (as `examples/app-todo` does from\n * `onEnable(ctx.ql)`), is handed runtime's `buildActionApi` api — an engine\n * `createContext` carrying the `'action'` mark, and not app-authored. On that\n * api this sheds the mark and any `flowRunId`, and the engine cannot tell it\n * from the api the audit writer holds (`buildHookApi`, a fresh `ScopedContext`\n * over the write's context: not app-authored either, and carrying the same\n * mark when an action's write fired the hook). It adds no reach: the handler's\n * package registered through the engine it holds, whose\n * `createContext({ isSystem: true })` already builds a system api with\n * neither. And what it returns is outside runtime's `deriveThroughSeam`\n * wrappers on that `ctx.api` (the stored-metadata read seam and the\n * landed-write answer): the walk wraps `object`, `sudo`, `withRunAs`,\n * `transaction` and `beginTransaction`, and its default arm binds this symbol\n * member to the unwrapped api, so the derived api comes back unwrapped.\n *",
      "tests": "At 95b49f1f02, os-verify-lock VERDICT command-exit 0 (213s): build of the core/objectql/plugin-audit/plugin-security dependency closure && core typecheck (check:test-typecheck OK) && objectql typecheck (OK) && core app-automation-elevation.test.ts Tests 7 passed (7) && objectql hook-run-as.test.ts Tests 39 passed (39) && plugin-security flow-system-identity-write-refusal.test.ts Tests 160 passed (160). No ablation: the behaviour is unchanged (docblock-only).",
      "gates": "dispatch-gates --commands at 95b49f1f02 (merge base 2fea6d2a1, no stale-tree warning): 79 commands. 77 exit 0. pnpm check:dual-build-cjs-loads exit 3 and pnpm check:i18n exit 3 (PREREQUISITE NOT MET: dist outside the built closure); both are measured in CI and green there (Build Core success, Type Check · consumer gates success). --ran: '79 derived famil(ies) accounted for — 77 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)'. check-facade-delegation-only exit 0 ('engine.ts: 6851 lines, ceiling 6854 (3 left)'), --self-test exit 0 (44 cases). overlap-check VERDICT clean exit 0 before both pushes. CI on 95b49f1f02: 68 check-runs complete, 57 success, 11 skipped, 0 failed, cancelled or in progress. CI on 8bd1bc72a9: Lint · repo & tooling gates FAILED, check-facade-delegation-only N6 (engine.ts 6861 > 6854 on the merge ref, from main's +8). Fixed by 95b49f1f02.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "deviations": [
        "The harness-supplied commit trailer named a model. check:commit-card-trailers refused the push, so the unpublished commit was amended to the model-free pair before its first push. No published history was rewritten.",
        "origin/main was merged because main made the PR red (the engine.ts facade ceiling on the merge ref). It merged with no conflicts.",
        "The first edits (two docblocks) were made before this session re-read AGENTS.md. The relevant sections (Communication, Documentation Guardrails, Post-Task Checklist, Edit Sizing) were read right after, and no rule was broken.",
        "A first gate pass, at 0be30b6104 on a tree 19 commits behind main, was stopped after 43 of 79 commands when main had to be merged. The full pass above is at the final head."
      ],
      "ci_reading": "95b49f1f02: 68/68 complete, 57 success, 11 skipped, none red",
      "mcp_calls": "0",
      "api_writes": "3 — git push x2 (8bd1bc72a9, 95b49f1f02; not REST), relay issue_patch PATCH /repos/objectstack-ai/objectstack/issues/35124 (run 44278720055, read-back identical 24926 bytes), post-stamped POST /repos/objectstack-ai/objectstack/issues/35052/comments (this report)",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: repo:objectstack#1 seat (named follow-up, not filed) · On a seat-wrapped action ctx.api, platformSystemApi bypasses runtime's deriveThroughSeam: the walk's default arm (stored-metadata-reader-seam.ts) binds Symbol.for('objectstack.objectql.platformSystemApi') to the unwrapped target, so the derived api escapes the stored-metadata read seam and the landed-write answer. Two routes are open: wrap the symbol member in the walk, or give buildActionApi's api a provenance flag the facet guards on, as S1 does. Today this adds no reach, because the handler's package already holds ql. Dedupe words: deriveThroughSeam symbol member, platformSystemApi action api, PLATFORM_SYSTEM_API seam walk, buildActionApi provenance flag"
      ]
    }
  10. objectstack-fleet commented on Nov 18, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-warren · session_01JQwxbXGvw43spR79ztEvWt

    Close-out · 2026-11-18T10:23Z

    PR #35124 merged as 4b1eb0eab7, and its Fixes #35052 closed this card. The audit writer now writes the platform's own sys_audit_log and sys_activity rows through platformSystemApi(api), a system api that is derived from the write's context without the app-automation mark and without flowRunId. So an action body, a system hook, or a system or user flow no longer has its audit trail judged as an app insert into an append-only object. sudo() is unchanged. Records on 95b49f1f: L1-a ACCEPT 6972295206 and delta 6974907139, declaration contract reviews 6972571588 and delta 6975004210, landing 6975034764. The surface amendment is 6970237640.

    Owed to the refusal arm (contract review N2), recorded here because no card for the arm exists yet. Done-when asked for a pin "with the refusal enabled". The insert-refusal arm has not shipped: today warnAppAutomationAppendOnlyInsert (plugin-security/src/flow-system-identity-write-refusal.ts) only logs a deprecation. So the pins assert no deprecation and that the rows land, under the same predicate the arm will read. The PR that turns that deprecation into a refusal must re-run flow-system-identity-write-refusal.test.ts › "the platform's own audit and activity rows for an elevated automation's write" with the arm on, and keep it green.

    Follow-up: #35174 (platformSystemApi on a host code action handler's api; two prose nits ride with it).

    This stroke removes the pm:dispatched state label.

  11. removed
    pm:dispatched
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

domain:serverfindingpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions