Skip to content

fix(plugins): enforce activation before shipped imports - #59136

Merged
vincentkoc merged 9 commits into
mainfrom
fix/plugin-activation-boundary
Apr 2, 2026
Merged

vincentkoc merged 9 commits into
mainfrom
fix/plugin-activation-boundary

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

  • only setup-load disabled channel plugins when the caller scopes to that selected plugin/channel
  • keep broad plugin loads metadata-first so disabled shipped plugins are not imported during unscoped setup scans
  • route src/tts/tts.ts through the existing lazy speech-runtime facade instead of directly importing extensions/speech-core/runtime-api.js
  • add regression coverage for scoped setup-only loads and lazy TTS facade loading

Testing

  • pnpm test -- src/plugins/loader.test.ts src/tts/tts.test.ts
  • pnpm test -- src/commands/channel-setup/plugin-install.test.ts src/commands/channel-setup/discovery.test.ts
  • pnpm check
  • pnpm build

@vincentkoc vincentkoc self-assigned this Apr 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Apr 1, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review April 1, 2026 17:20
@aisle-research-bot

aisle-research-bot Bot commented Apr 1, 2026 •

Copy link
Copy Markdown

🔒 Aisle Security Analysis

We found 1 potential security issue(s) in this PR:

# Severity Title
1 🟠 High Scoped plugin loading can be bypassed via manifest channel ID matching
1. 🟠 Scoped plugin loading can be bypassed via manifest channel ID matching
Property Value
Severity High
CWE CWE-863
Location src/plugins/loader.ts:283-296

Description

loadOpenClawPlugins/loadOpenClawPluginCliRegistry implement scoping via onlyPluginIds to prevent importing/registering plugins outside a requested subset.

The new helper matchesScopedPluginRequest treats an entry in onlyPluginIds as matching either:

  • the plugin manifest id, or
  • any entry in manifestRecord.channels

This weakens the scoping boundary:

  • Call sites already pass a channel name into onlyPluginIds (e.g. plugin-install.ts uses [params.pluginId ?? params.channel]).
  • Any installed/bundled plugin can declare an arbitrary channel ID in its manifest.
  • As a result, scoping intended to load a single plugin (by ID) can load additional plugins that merely claim the same channels value, executing their import-time code and registration side-effects.

Vulnerable code:

return params.manifestChannels.some((channelId) => scopedIds.has(channelId));

Impact depends on the trust model for plugins and who controls the scoped channel/plugin selection, but in common setups where:

  • plugins are third-party/extendable and can execute arbitrary Node.js code on import, and
  • the scoped channel/plugin selection can be influenced by an external request or untrusted user input,

this becomes an authorization/scoping bypass leading to unintended code execution (loading extra plugins not explicitly selected by plugin ID).

Recommendation

Treat onlyPluginIds as plugin IDs only and do not match against manifestRecord.channels during the import-time guard.

If channel-based setup loading is desired, introduce an explicit, separate option (e.g. onlyChannels) and keep the semantics disjoint.

Example fix (plugin-id-only scoping):

function matchesScopedPluginRequest(params: {
  onlyPluginIdSet: ReadonlySet<string> | null;
  pluginId: string;
}): boolean {
  const scopedIds = params.onlyPluginIdSet;
  return !scopedIds || scopedIds.has(params.pluginId);
}

If you must support channel scoping, ensure it is safe by:

  • validating/namespace-protecting channel IDs (e.g. restrict to core-reserved namespaces),
  • enforcing uniqueness (a channel can only be owned by a single allowed plugin), and/or
  • requiring explicit mapping from channel -> plugin ID in trusted configuration rather than trusting plugin manifests.

Analyzed PR: #59136 at commit 35b0921

Last updated on: 2026-04-01T17:34:31Z

@greptile-apps

greptile-apps Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR tightens two plugin-loading behaviors: it gates setup-only registration mode behind an explicit onlyPluginIds scope (so broad unscoped setup scans no longer eagerly import disabled shipped channel plugins), and it re-routes src/tts/tts.ts through the existing lazy speech-runtime facade instead of directly importing extensions/speech-core/runtime-api.js at module load time.

Key changes:

  • Added matchesScopedPluginRequest helper in loader.ts that accepts either a plugin ID or a channel ID in onlyPluginIds, and uses it in both loadOpenClawPlugins and loadOpenClawPluginCliRegistry as the scope filter.
  • registrationMode = \"setup-only\" is now only entered when onlyPluginIdSet is non-null, preventing disabled channel plugins from being imported during broad (unscoped) setup scans.
  • tts.ts is now a thin re-export of the generated speech-runtime facade, so importing the TTS module no longer pulls in speech-core/runtime-api.js eagerly.
  • Regression tests cover both the "broad unscoped call does not activate disabled plugin" path and the "scoped call by channel ID activates the correct disabled plugin" path.

Confidence Score: 5/5

Safe to merge — logic is correct, all callers that need scoped setup-only loading already pass onlyPluginIds, and the TTS facade change is a clean drop-in replacement.

No P0 or P1 issues found. The matchesScopedPluginRequest helper correctly handles both plugin IDs and channel IDs in the scope set, the registrationMode guard is tightened in the right direction, and the test coverage directly validates both the new unscoped (no-op) and scoped (active) paths. The TTS change is a straightforward re-export swap with its own lazy-load regression test.

No files require special attention.

Reviews (1): Last reviewed commit: "Merge branch 'main' into fix/plugin-acti..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35b0921479

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugins/loader.ts Resolved
Comment thread src/tts/tts.test.ts Resolved
@vincentkoc
vincentkoc requested a review from a team as a code owner April 2, 2026 01:11
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations agents Agent runtime and tooling size: M and removed size: S labels Apr 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10e46997da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugin-activation-boundary.test.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75e9a3ea47

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44f999afcd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@vincentkoc
vincentkoc merged commit 7771c69 into main Apr 2, 2026
9 checks passed
@vincentkoc
vincentkoc deleted the fix/plugin-activation-boundary branch April 2, 2026 02:18
steipete pushed a commit to duncanita/openclaw that referenced this pull request Apr 4, 2026
* fix(plugins): enforce activation before shipped imports

* fix(plugins): remove more ambient bundled loads

* fix(plugins): tighten scoped loader matching

* fix(plugins): remove channel-id scoped loader matches

* refactor(plugin-sdk): relocate ambient provider helpers

* fix(plugin-sdk): preserve unicode ADC credential paths

* fix(plugins): restore safe setup fallback
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* fix(plugins): enforce activation before shipped imports

* fix(plugins): remove more ambient bundled loads

* fix(plugins): tighten scoped loader matching

* fix(plugins): remove channel-id scoped loader matches

* refactor(plugin-sdk): relocate ambient provider helpers

* fix(plugin-sdk): preserve unicode ADC credential paths

* fix(plugins): restore safe setup fallback
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* fix(plugins): enforce activation before shipped imports

* fix(plugins): remove more ambient bundled loads

* fix(plugins): tighten scoped loader matching

* fix(plugins): remove channel-id scoped loader matches

* refactor(plugin-sdk): relocate ambient provider helpers

* fix(plugin-sdk): preserve unicode ADC credential paths

* fix(plugins): restore safe setup fallback
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix(plugins): enforce activation before shipped imports

* fix(plugins): remove more ambient bundled loads

* fix(plugins): tighten scoped loader matching

* fix(plugins): remove channel-id scoped loader matches

* refactor(plugin-sdk): relocate ambient provider helpers

* fix(plugin-sdk): preserve unicode ADC credential paths

* fix(plugins): restore safe setup fallback
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
* fix(plugins): enforce activation before shipped imports

* fix(plugins): remove more ambient bundled loads

* fix(plugins): tighten scoped loader matching

* fix(plugins): remove channel-id scoped loader matches

* refactor(plugin-sdk): relocate ambient provider helpers

* fix(plugin-sdk): preserve unicode ADC credential paths

* fix(plugins): restore safe setup fallback
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
* fix(plugins): enforce activation before shipped imports

* fix(plugins): remove more ambient bundled loads

* fix(plugins): tighten scoped loader matching

* fix(plugins): remove channel-id scoped loader matches

* refactor(plugin-sdk): relocate ambient provider helpers

* fix(plugin-sdk): preserve unicode ADC credential paths

* fix(plugins): restore safe setup fallback
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
* fix(plugins): enforce activation before shipped imports

* fix(plugins): remove more ambient bundled loads

* fix(plugins): tighten scoped loader matching

* fix(plugins): remove channel-id scoped loader matches

* refactor(plugin-sdk): relocate ambient provider helpers

* fix(plugin-sdk): preserve unicode ADC credential paths

* fix(plugins): restore safe setup fallback
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
* fix(plugins): enforce activation before shipped imports

* fix(plugins): remove more ambient bundled loads

* fix(plugins): tighten scoped loader matching

* fix(plugins): remove channel-id scoped loader matches

* refactor(plugin-sdk): relocate ambient provider helpers

* fix(plugin-sdk): preserve unicode ADC credential paths

* fix(plugins): restore safe setup fallback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant