Repository navigation
fix(plugins): close four trust-boundary holes in the plugin system - #11232
Conversation
Greptile SummaryThis 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
Confidence Score: 5/5All 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 Files Needing Attention: No files require special attention. Reviewers should confirm the deliberate scope assumption called out in the PR: the
|
| 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
📝 WalkthroughWalkthroughThe 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)
✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this comment.
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.tssrc/main/plugins/plugin-content-pack-registry.tssrc/main/plugins/plugin-kill-list-content-revocation.test.tssrc/main/plugins/plugin-kill-list-service.test.tssrc/main/plugins/plugin-kill-list-service.tssrc/main/plugins/plugin-service.tssrc/renderer/src/components/right-sidebar/plugin-panel-activity-items.test.tssrc/renderer/src/components/right-sidebar/plugin-panel-activity-items.tssrc/renderer/src/components/right-sidebar/plugin-panel-bridge-host.test.tssrc/renderer/src/components/right-sidebar/plugin-panel-bridge-host.tssrc/shared/plugins/plugin-kill-list.test.tssrc/shared/plugins/plugin-kill-list.tssrc/shared/plugins/plugin-language-pack-artifact.test.tssrc/shared/plugins/plugin-language-pack-artifact.tssrc/shared/plugins/plugin-panel-bridge.tssrc/shared/plugins/plugin-panel-message-budget.ts
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]>
81b9674 to
c8dbf7d
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/right-sidebar/plugin-panel-bridge-host.ts (1)
91-106: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCondense 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.tssrc/main/plugins/plugin-content-pack-registry.tssrc/main/plugins/plugin-kill-list-content-revocation.test.tssrc/main/plugins/plugin-kill-list-service.test.tssrc/main/plugins/plugin-kill-list-service.tssrc/main/plugins/plugin-service.tssrc/renderer/src/components/right-sidebar/plugin-panel-activity-items.test.tssrc/renderer/src/components/right-sidebar/plugin-panel-activity-items.tssrc/renderer/src/components/right-sidebar/plugin-panel-bridge-host.test.tssrc/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]>
|
Pre-merge gate: one real defect found and fixed in The PR claims zod v4's None of the 18 parity cases sat above Impact is small but it is on the security boundary this PR exists to tighten: Fix: Full re-verification on the final commit, all run locally:
|
…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]>
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 ongeneratedAt, so one far-future snapshot froze out every later revocation permanently; the protected-translation list inplugin-language-pack-artifact.tswas 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 namedconstructorresolved toObjectand crashed the right sidebar; andplugin-panel-bridge-host.tscharged 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
isKilledpredicate 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, publishercommunity, loaded from a dev path) that mapsPluginConsentProvenance.communityto"Official". Both shots are the same consent dialog for the same unrelated third-party plugin (orca-samples.hostile-panel, publisherorca-samples), in the same running app, same profile, same route — differing only by whethersrc/shared/plugins/plugin-language-pack-artifact.tsis atmainor at this branch.Before — a community plugin presents itself as Official · orca-samples:
After — the host's own copy wins, Community · orca-samples, and the language pack is refused at load:
window.api.plugins.list()in the same two sessions, pasted verbatim: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.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
PluginServiceover a real on-disk plugin tree. Source hunk reverted tomain, tests kept:That
createstring is what reachesspawn(..., { shell: true }). With the fix, both thereconcileActivationState()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: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: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:
plugin-kill-list-content-revocation.test.tsplugin-content-pack-registry.test.tsgeneratedAtplugin-kill-list.test.ts+plugin-kill-list-service.test.tsplugin-language-pack-artifact.test.tsplugin-panel-activity-items.test.tsplugin-panel-bridge-host.test.tsplugin-panel-pong-frame.test.tsAll passing on HEAD:
Command:
npx vitest run --config config/vitest.config.ts <the 8 files>. Notepnpm test -- <file>/ barenpx vitestdo not resolve the@/alias;--config config/vitest.config.tsis required.A regression this branch introduced and then fixed — please read
The first commit (43b14b51ec) put the future-skew bound inside
pluginKillListSchema.superRefine, which evaluatesDate.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, andinitialize()catches a store read failure by settingcurrentList = 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):
Fixed in 81b9674cf9:
isPluginKillListTooFarInFuture()is applied at the two fetch chokepoints only (performRefreshbeforestore.write, andfetchPluginKillList), leaving the cache read unbounded — a cached list was already accepted once, and re-judging it later can only lose revocations. The covering testkeeps cached revocations live when the device clock runs far behindfails on bothmainand 43b14b51ec.Review round 2 — the reserved lane had the same bug it was fixing
Greptile (P2) caught that
PANEL_CONTROL_RATE_LIMIT = 4 / 10sused the same window asPANEL_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 cheaptype-only check, so near-miss pongs (pingId: -1,pingId: 'x', absentpingId) 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:
PANEL_CONTROL_RATE_LIMITis 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.looksLikePanelControlFrameis replaced byreadPanelPongId(), which returns thepingIdornull; anything failing falls through to the data budget like any other malformed frame.readPanelPongIdis hand-rolled rather thanpanelPongSchema.safeParsebecause 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.tspins the reader topanelPongSchemaacross 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 usedNumber.isInteger, sopingId: 1e100took the reserved lane the schema would have refused (and could never correlate against a watchdog id starting at 0). Fixed in7b473c327ewithNumber.isSafeInteger, plus four above-MAX_SAFE_INTEGERparity cases. Reverting only the source change fails exactly those four.CodeRabbit (Major, security) separately caught a TOCTOU on finding 1.1's own boundary:
approvedKeysis snapshotted before the awaited verification phase, so a plugin killed during that wait still published.approveAtomically— the last gate before publication — now re-readsisKilled. Reverting only that hunk fails the new test with the attacker payload published:CodeRabbit (Minor) also caught that
resolvePluginPanelIcon('file-text') === resolvePluginPanelIcon('FileText')passes when both fall back toPlug. The test now asserts the exact icon (toBe(FileText)), which is stronger than the suggestednot.toBe(Plug); stubbing the resolver toreturn Plugnow 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
380034edf9and25da91d653touches any of the five source files here (git diff --stat 380034edf9 origin/main -- src/main/plugins src/shared/pluginsshows onlyAiVaultSessionRow.tsxand that one test file), so no hunk was dropped as already-fixed-upstream.Existing tests over the touched area
plugin-launch-content.test.ts, which guards the bundled Portuguese launch pack against the widened 1.3 rule, passes.Typecheck and lint
Deliberate scope choices and open judgement calls
auto.components.settings.<module>where the module segment matches/^plugin/i. This is what stops the next extracted dialog from silently regressing the wayPluginConsentProvenancedid. Blast radius measured: it protects 16 of 196auto.components.settings.*modules across all five shipped locales (en/es/ja/ko/zh), and the only bundled language pack (stablyai.orca-portuguese) contains zeroauto.components.settings.*keys. It also closesPluginDevelopmentSectionand thepluginsnamespace, which the original list missed. A reviewer should confirm no future non-security settings module is intended to be namedPlugin*— that is the one assumption this rule rests on.readPanelPongIdplus one byte-walk capped at 1 KiB per pong-shaped frame — all of which the data budget already meters.PluginContentPackRegistry's constructor signature (adds a requiredisKilledpredicate). One production construction site exists (plugin-service.ts:67); two test constructions were updated to() => false.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
Made with Orca 🐋