Back to skill

Security audit

Openclaw Plugin Upgrade

Security checks for vulnerabilities and agentic risk

Overview

This skill performs real plugin installation, cleanup, and gateway restart work, but its upgrade script gives too much unsafe control over package selection, paths, and package-supplied code.

Install only if you are comfortable with this skill changing OpenClaw plugins and restarting the gateway. Use exact trusted package names and versions, avoid arbitrary --legacy-dirs values, and review or fix the script before using it in an environment with important local files or credentials.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/upgrade-plugin.sh:104
Finding

JavaScript Code Injection Through Unvalidated Plugin Identifier

Content
View full analysis
/dev/null || true)" ``` ```bash HAS_PLUGIN_CHANNEL="$(node -e " try { const cfg = JSON.parse(require('fs').readFileSync('$CONFIG_FILE','utf8')); if (cfg.channels && (cfg.channels['$PLUGIN_ID'] || cfg.channels['$PLUGIN_CHANNEL_KEY'])) process.stdout.write('true'); } catch {} " 2>/dev/null || true)" ``` ```bash HAS_INSTALL_RECORD="$(node -e " try { const cfg=JSON.parse(require('fs').readFileSync('$CONFIG_FILE','utf8')); const inst=cfg.plugins&&cfg.plugins.installs&&cfg.plugins.installs['$PLUGIN_ID']; if(inst) process.stdout.write('yes'); } catch {} " 2>/dev/null || true)" ``` ### Technical Analysis The script reads `PLUGIN_ID` directly from its second positional argument without applying format validation: ```bash PLUGIN_ID="${2:-}" ``` It subsequently interpolates that value into JavaScript source passed to `node -e`. Shell quoting does not make the value safe as JavaScript syntax. An identifier containing a single quote and additional JavaScript tokens can terminate one of the generated string literals and inject attacker-controlled JavaScript. The same unsafe pattern is used for filesystem paths such as `OLD_PKG` and configuration paths. Values that can contain quote characters may therefore alter the program supplied to Node.js instead of being treated solely as data. Because Node.js is launched with the privileges of the agent or user running the Skill, injected JavaScript can use modules such as `child_process`, `fs`, or netw ...[truncated 1405 chars]
Remediation
View remediation
/dev/null || true )" ``` 2. Pass `PLUGIN_ID`, `PLUGIN_CHANNEL_KEY`, and configuration paths through `process.argv` in every `node -e` invocation. 3. Strictly validate plugin identifiers before any use. If plugin directory names are expected to contain only common package identifier characters, enforce an allowlist such as: ```bash if [[ ! "$PLUGIN_ID" =~ ^[A-Za-z0-9._-]+$ ]]; then echo "Invalid plugin identifier" >&2 exit 1 fi ``` 4. Validate npm package names and versions separately according to the supported npm naming grammar. 5. Add regression tests using identifiers containing quotes, backslashes, newlines, traversal segments, and JavaScript syntax to ensure that they remain inert data. ]]>

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/upgrade-plugin.sh:217
Finding

Arbitrary Directory Deletion Through Legacy Directory Path Traversal

Content
View full analysis
Remediation
View remediation
&2 exit 1 fi ``` 2. Apply a strict allowlist suitable for plugin directory identifiers: ```bash [[ "$d" =~ ^[A-Za-z0-9._-]+$ ]] || exit 1 ``` 3. Canonicalize both the base directory and target before deletion, then verify containment: ```bash base="$(realpath -e -- "$EXTENSIONS_DIR")" target="$(realpath -e -- "$EXTENSIONS_DIR/$d")" case "$target" in "$base"/*) ;; *) echo "Refusing path outside extensions directory" >&2; exit 1 ;; esac ``` 4. Ensure the target is an immediate child of the extensions directory rather than merely any descendant. 5. Use `rm -rf -- "$target"` only after all validation succeeds. 6. Apply equivalent validation and containment checks to `PLUGIN_ID` before using it in `mv`, package paths, backup paths, or installation paths. 7. Prefer an internal allowlist of known historical directory names instead of accepting arbitrary cleanup paths from user-controlled arguments. ]]>

T08 · Insecure Dependencies

Error
Location
scripts/upgrade-plugin.sh:229
Finding

Unrestricted Remote Package Installation and Execution of Package-Controlled Code

Content
View full analysis
&1; then UPGRADE_OK=true echo " ✅ install 成功" [ -n "$BACKUP_DIR" ] && [ -d "$BACKUP_DIR" ] && rm -rf "$BACKUP_DIR" && echo " 已清理旧版备份" else echo " ❌ install 失败" [ -n "$BACKUP_DIR" ] && [ -d "$BACKUP_DIR" ] && mv "$BACKUP_DIR" "$EXTENSIONS_DIR/$PLUGIN_ID" && echo " ↩️ 已回滚" restore_temp_config exit 1 fi ``` ```bash # 执行 postinstall 脚本(如有) POSTINSTALL="$TARGET_DIR/scripts/postinstall-link-sdk.js" if [ -f "$POSTINSTALL" ]; then echo " 执行 postinstall-link-sdk..." node "$POSTINSTALL" 2>&1 && echo " ✅ plugin-sdk 链接就绪" || echo " ⚠️ postinstall 失败,插件可能无法加载" fi ``` The default source resolves to a mutable `latest` version: ```bash INSTALL_SRC="${PKG_NAME}@${TARGET_VERSION:-latest}" ``` ### Technical Analysis The Skill is documented as supporting arbitrary npm packages. It accepts a package name from its positional arguments, resolves `latest` when no version is specified, installs the selected package, and then explicitly executes a JavaScript file from the newly installed package when that file exists. No controls in the reviewed code enforce: - An allowlist of approved package names. - An approved registry or namespace. - An immutable version requirement. - Package integrity or signature verification. - Publisher or provenance verification. - User confirmation before executing package-controlled code. - Inspection or sandboxing of `postinstall-link-sdk.js`. Consequently, the effective code executed by the Skill is not limited to the audited repository. It can change whenever a package publisher changes the `latest` release, when a package account or registry is compromised, or when a user is induced to install a typo-squatted or malicious package. The dir ...[truncated 1729 chars]
Remediation
View remediation
Vulnerability Patterns
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (6)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 60)May include surrounding context.

md
> `<skill_dir>` = 本 skill 文件所在目录,即 `SKILL.md` 的 dirname。

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
96% confidence
Finding

The script deletes directories derived from the user-controlled --legacy-dirs parameter using rm -rf "$EXTENSIONS_DIR/$d" without validating that each entry is a safe single directory name. An attacker can supply values such as ../otherdir or absolute-path-like traversal components to delete files outside the intended extensions directory, which is especially dangerous in an upgrade helper that is expected to run with the operator's privileges.

Content

Scanner excerpt · scripts/upgrade-plugin.sh (reported line 209)May include surrounding context.

sh
if [ -n "$LEGACY_DIRS" ]; then
        IFS=',' read -ra LDIRS <<< "$LEGACY_DIRS"
        for d in "${LDIRS[@]}"; do
            [ -d "$EXTENSIONS_DIR/$d" ] && rm -rf "$EXTENSIONS_DIR/$d" && echo "  已清理历史目录: $d"
        done
    fi

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · scripts/upgrade-plugin.sh (reported line 209)May include surrounding context.

sh
if [ -n "$LEGACY_DIRS" ]; then
        IFS=',' read -ra LDIRS <<< "$LEGACY_DIRS"
        for d in "${LDIRS[@]}"; do
            [ -d "$EXTENSIONS_DIR/$d" ] && rm -rf "$EXTENSIONS_DIR/$d" && echo "  已清理历史目录: $d"
        done
    fi

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · scripts/upgrade-plugin.sh (reported line 216)May include surrounding context.

sh
if [ -n "$LEGACY_DIRS" ]; then
        IFS=',' read -ra LDIRS <<< "$LEGACY_DIRS"
        for d in "${LDIRS[@]}"; do
            [ -d "$EXTENSIONS_DIR/$d" ] && rm -rf "$EXTENSIONS_DIR/$d" && echo "  已清理历史目录: $d"
        done
    fi

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The activation examples include broad, everyday phrases such as '帮我升级插件' and '升级 openclaw 插件', which can cause the skill to trigger on ambiguous requests. Because this skill performs direct system-modifying actions like upgrading packages and potentially restarting the gateway, accidental activation could lead to unintended plugin changes or service disruption.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill description and usage guidance do not prominently warn that running the workflow will modify plugin files, execute installation/postinstall behavior, and may restart the gateway. Without an explicit warning and consent model, a user may invoke the skill without understanding the operational impact, increasing the risk of accidental downtime or unsafe package changes.

Content

No source excerpt is available for this finding.