-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
before_install hook not triggered by CLI openclaw plugins install #91593
Copy link
Copy link
Closed
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.Security boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.Security boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Summary
The
before_installplugin hook is never triggered when installing plugins via the CLI commandopenclaw plugins install <spec>, even when a plugin that registers abefore_installhandler is already installed and loaded in the running Gateway. The hook fires correctly when installing via the Gateway chat command/plugins install.This means enterprise policy and security scanner plugins cannot enforce install-time checks through the most common installation path.
Steps to Reproduce
before_installhook handleropenclaw gateway run)openclaw plugins install @openclaw/browser-pluginbefore_installhandler is never invokedFor comparison, repeating the install via Gateway chat
/plugins install @openclaw/browser-plugincorrectly triggers the hook.Expected Behavior
before_installshould fire for all plugin installation paths, as documented in PR #56050:CLI
openclaw plugins installis a plugin package install path and should be covered.Root Cause
The CLI and Gateway run in separate processes with independent memory spaces. The
before_installhook depends on a process-local singleton (getGlobalHookRunner()) that is only initialized when the plugin system is loaded.CLI process flow:
src/cli/command-catalog.ts— there is no catalog entry for["plugins", "install"]src/cli/command-path-policy.ts:12-20— falls through to default policyloadPlugins: "never"src/cli/command-bootstrap.ts:33-35—ensureCliCommandBootstrapreturns immediately whenloadPluginsis false, never callingloadOpenClawPlugins()src/plugins/hook-runner-global.ts:60-62—getGlobalHookRunner()returnsnullin the CLI processsrc/plugins/install-security-scan.runtime.ts:726-728— the null check silently returnsundefined, skipping the hook entirelyGateway process flow (works correctly):
loadGatewayStartupPlugins()→loadOpenClawPlugins()→activatePluginRegistry()→initializeGlobalHookRunner()runBeforeInstallHookfinds the runner and executes the hookThe key issue is that
Symbol.forsingleton state is process-isolated — the CLI process cannot see the Gateway process's initialized hook runner.Impact
before_installhook's fail-closed design (failurePolicyByHook: { before_install: "fail-closed" }) is completely bypassed in the CLI path.Suggested Fix Directions
Option A — Load plugins for
plugins installin CLI:Add a catalog entry in
src/cli/command-catalog.ts:This would cause the CLI process to load the plugin registry and initialize the hook runner before executing the install. Trade-off: increased CLI startup latency for the install command.
Option B — Delegate CLI installs to Gateway via RPC:
When a Gateway is running, route
openclaw plugins installthrough a Gateway RPC call (e.g.,skills.installor a dedicated endpoint) so the install executes in the Gateway process where plugins are already loaded. This avoids the startup cost but requires Gateway connectivity.References
before_installhookinstall-security-scan.runtime.ts:42-44: "Initialize hooks before running install security scans"block: trueis logged but installation is never actually prevented"src/plugins/hook-runner-global.ts— singleton hook runnersrc/plugins/install-security-scan.runtime.ts:700-771—runBeforeInstallHooksrc/cli/command-catalog.ts— declarative command routing (no["plugins", "install"]entry)