Back to skill

Security audit

openclaw-cleaner

Security checks for vulnerabilities and agentic risk

Overview

This workspace cleanup skill matches its stated purpose, but its file-deletion safeguards are weak enough that users should review it carefully before installing.

Review cleaner.yaml before use, keep dry_run enabled, run previews manually before any --force or cron use, do not rely on the documented whitelist until fixed, and avoid deleting the cleaner-archive directory unless you have checked that it contains nothing you need.

Vulnerability Patterns
  • 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
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/cleaner.sh:55
Finding

Whitelist Parsing Failure Allows Protected Files to Be Deleted or Archived

Content
View full analysis

Vulnerability Details

File Location: scripts/cleaner.sh, lines 55-73
Vulnerability Type: Ineffective security control caused by unsafe YAML parsing
Risk Level: High

Vulnerable Code

bash
# ---------- 解析白名单 ----------
WHITELIST=()
while IFS= read -r line; do
  line=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
  [[ -z "$line" || "$line" =~ ^# ]] && continue
  [[ "$line" == "whitelist:" ]] && continue
  WHITELIST+=("${line//\~/${HOME}}")
done < <(grep -A 20 "^whitelist:" "$CONFIG" 2>/dev/null || true)

# ---------- 白名单检查 ----------
is_whitelisted() {
  local f="$1"
  for w in "${WHITELIST[@]:-}"; do
    [[ "$f" == "$w" || "$f" == "$w"/* ]] && return 0
  done
  return 1
}

The corresponding entries in config.yaml, lines 56-59, use standard YAML list syntax:

yaml
whitelist:
  - "~/.openclaw/workspace/SOUL.md"
  - "~/.openclaw/workspace/MEMORY.md"

Technical Analysis

The custom parser trims whitespace but does not remove the YAML list marker (- ) or surrounding quotes. An entry such as:

yaml
- "~/.openclaw/workspace/SOUL.md"

is therefore stored in the array as a value resembling:

text
- "/home/user/.openclaw/workspace/SOUL.md"

This does not equal the actual path passed to is_whitelisted, so the intended protection is ineffective. The parser also uses grep -A 20, which is not structurally aware of YAML and can consume unrelated lines following the whitelist section.

Attack Path

  1. An attacker or configuration author places a broad rule in ~/.openclaw/workspace/cleaner.yaml that matches an intended protected file.
  2. The whitelist contains that file using the documented YAML list syntax.
  3. Mutation is enabled through --force or dry_run: false.
  4. The parser retains the list marker and quotes in the whitelist value.
  5. is_whitelisted fails to recognize the ...[truncated 471 chars]
Remediation
View remediation

Remediation Suggestions

  • Replace the ad hoc parser with a maintained YAML parser such as yq, or parse the configuration in a language with safe YAML support.
  • If a restricted parser must be retained, explicitly validate YAML structure and remove list markers and matching outer quotes before accepting values.
  • Canonicalize both candidate and whitelist paths using realpath before comparison.
  • Reject relative whitelist entries, malformed values, control characters, and entries outside the expected workspace.
  • Parse only the actual whitelist sequence rather than an arbitrary 20-line range.
  • Add automated tests proving that documented whitelist entries block both deletion and archival.
  • Abort all mutation if configuration or whitelist parsing fails.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/cleaner.sh:47
Finding

Configuration Can Silently Enable Destructive Operation and Invalid Actions Default to Deletion

Content
View full analysis

Vulnerability Details

File Location: scripts/cleaner.sh, lines 47-50 and 189-198
Vulnerability Type: Fail-open destructive configuration handling
Risk Level: High

Vulnerable Code

bash
DRY_RUN_STR="$(read_val "dry_run")"
[[ "$DRY_RUN_STR" == "false" ]] && DRY_RUN=false
bash
main() {
  local archive_rules=() delete_rules=()
  while IFS= read -r rule; do
    [[ -z "$rule" ]] && continue
    local act="${rule%%|*}"
    if [[ "$act" == "archive" ]]; then
      archive_rules+=("$rule")
    else
      delete_rules+=("$rule")
    fi
  done < <(parse_all_rules)

Permanent deletion is subsequently performed at lines 173-180:

bash
if [[ "$action" == "archive" ]]; then
  mkdir -p "$ARCHIVE_DIR"
  mv "$f" "${ARCHIVE_DIR}/" 2>/dev/null && echo "    ✅ 归档 $basename" || echo "    ❌ 归档失败 $basename"
else
  rm -f "$f" && echo "    🗑  删除 $basename" || echo "    ❌ 删除失败 $basename"
fi

Technical Analysis

The script initially sets DRY_RUN=true, but a workspace-level configuration can set dry_run: false and enable filesystem mutation without the documented --force argument. This makes the safety boundary dependent on a configuration file that takes precedence over the packaged default.

Action validation also fails open. Only the exact value archive is treated as archival; every other value—including delete, misspellings, malformed text, unsupported actions, and parser artifacts—is placed into the deletion group and ultimately reaches rm -f.

These behaviors combine dangerously: a malformed or attacker-modified configuration can both disable preview mode and convert an invalid rule into permanent deletion.

Attack Path

  1. An attacker, compromised process, or mistaken user modifies ~/.openclaw/workspace/cleaner.yaml.
  2. The file sets dry_run: false.
  3. A rule contains a broad pattern and an invalid or ...[truncated 729 chars]
Remediation
View remediation

Remediation Suggestions

  • Require an explicit command-line confirmation such as --force for every mutation; configuration must never be sufficient to bypass preview mode.
  • Validate actions against an exact allowlist containing only archive and delete.
  • Reject the entire configuration on unknown actions, malformed rules, duplicate fields, or invalid Boolean values.
  • Make invalid or missing actions fail closed rather than defaulting to deletion.
  • Consider requiring a separate flag such as --allow-delete for permanent deletion.
  • Display the resolved configuration and require interactive confirmation before destructive execution where practical.
  • Check configuration ownership and permissions before trusting a workspace-level override.
  • Add regression tests for misspelled actions, malformed YAML, dry_run: false without --force, and broad patterns.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/cleaner.sh:173
Finding

Archive Name Collisions Can Overwrite Previously Archived Files

Content
View full analysis

Vulnerability Details

File Location: scripts/cleaner.sh, lines 173-177
Vulnerability Type: Unsafe archive destination and file overwrite
Risk Level: Medium

Vulnerable Code

bash
if [[ "$action" == "archive" ]]; then
  mkdir -p "$ARCHIVE_DIR"
  mv "$f" "${ARCHIVE_DIR}/" 2>/dev/null && echo "    ✅ 归档 $basename" || echo "    ❌ 归档失败 $basename"

Technical Analysis

All archived files are moved into one shared destination directory using only their basename. The script does not preserve the source-relative path, test whether the destination exists, generate a unique name, or use explicit no-clobber behavior.

On systems where mv replaces an existing destination file, archiving another file with the same basename can silently overwrite the prior archive. This contradicts the documented expectation that archived files remain recoverable.

Attack Path

  1. A matching file named report.pdf is archived into the configured archive directory.
  2. Another matching file named report.pdf is later created in a scanned source directory.
  3. Cleanup is run again with mutation enabled.
  4. The script moves the second file into the same archive directory and destination name.
  5. The previously archived report.pdf is replaced and can no longer be recovered through this tool.

Impact Assessment

The impact is loss of previously archived user data within the configured archive directory. The operation is limited to files writable by the invoking account and does not escalate privileges. If an attacker can influence matching source filenames, they can intentionally trigger collisions and destroy prior archive contents.

Remediation
View remediation

Remediation Suggestions

  • Preserve source-relative directory structure inside the archive.
  • Use no-clobber behavior and treat an existing destination as an error.
  • Alternatively, create collision-resistant names using a timestamp, cryptographic digest, or securely generated unique suffix.
  • Perform an atomic destination-existence check and move operation where supported.
  • Log the complete source and destination paths rather than only the basename.
  • Add tests covering identical basenames from different source locations and repeated archival runs.

T08 · Insecure Dependencies

Warning
Location
SKILL.md:19
Finding

Installation Documentation Executes an Unpinned Third-Party npm Package

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 19-23
Vulnerability Type: Unpinned dependency execution through npx
Risk Level: Medium

Vulnerable Code

bash
## 安装

```bash
npx skills add ~/.openclaw/workspace/skills/openclaw-cleaner
text

### Technical Analysis

The documented installation command invokes `npx skills` without a package version, integrity constraint, verified source, or package identity explanation. If the package is absent locally, `npx` can retrieve and execute the currently resolved registry package. The effective installer code can therefore change independently of the reviewed Skill.

The alternative clone command also refers to a placeholder repository (`https://github.com/your-repo/openclaw-cleaner.git`), so it does not provide a concrete, verifiable source as written.

### Attack Path

1. A user follows the documented installation command.
2. `npx` resolves the unversioned `skills` package through the configured npm registry.
3. The resolved package or its dependency chain has changed, is compromised, or is not the package the author intended.
4. npm downloads the package and may execute its command and lifecycle behavior.
5. Malicious package code runs with the privileges of the user performing installation.

### Impact Assessment

A compromised or incorrectly resolved package can execute arbitrary code with the installing user's privileges. Potential consequences include reading or modifying user-accessible files, stealing environment credentials, altering the OpenClaw workspace, or installing additional user-level persistence. No malicious dependency payload is present in the audited project itself; the risk arises from the unpinned external installation command.
Remediation
View remediation

Remediation Suggestions

  • Pin the installer package to a reviewed exact version rather than using an unversioned package name.
  • Document the official package scope, registry, maintainers, and source repository.
  • Use lockfiles and integrity hashes where the installation workflow supports them.
  • Prefer a verified local installation process that does not execute dynamically retrieved package code.
  • Replace the placeholder repository URL with the canonical repository and recommend verification of a signed tag or release checksum.
  • Periodically audit the pinned installer and its transitive dependencies before updating the documented version.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (9)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Even though the command is scoped to the skill directory, publishing raw rm -rf uninstall instructions is operationally risky because users may execute them without verifying path expansion or may adapt them incorrectly. In a tool aimed at novice users, destructive shell commands increase the chance of accidental data loss if environment variables, symlinks, or copy-paste mistakes alter the target path.

Content

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

卸载

bash
rm -rf ~/.openclaw/workspace/skills/openclaw-cleaner
rm -rf ~/.openclaw/workspace/cleaner-archive
# 如有 cron,手动删除对应的 cron job

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Even though the command is scoped to the skill directory, publishing raw rm -rf uninstall instructions is operationally risky because users may execute them without verifying path expansion or may adapt them incorrectly. In a tool aimed at novice users, destructive shell commands increase the chance of accidental data loss if environment variables, symlinks, or copy-paste mistakes alter the target path.

Content

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

卸载

bash
rm -rf ~/.openclaw/workspace/skills/openclaw-cleaner
rm -rf ~/.openclaw/workspace/cleaner-archive
# 如有 cron,手动删除对应的 cron job

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

The archive directory may contain user data that was previously preserved for recovery, so instructing users to delete it with rm -rf can permanently destroy files they may not realize are still valuable. This is more dangerous in this skill's context because the archive is explicitly presented as a safety and recovery mechanism, yet the uninstall step removes that safeguard wholesale.

Content

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

bash
rm -rf ~/.openclaw/workspace/skills/openclaw-cleaner
rm -rf ~/.openclaw/workspace/cleaner-archive
# 如有 cron,手动删除对应的 cron job

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

The archive directory may contain user data that was previously preserved for recovery, so instructing users to delete it with rm -rf can permanently destroy files they may not realize are still valuable. This is more dangerous in this skill's context because the archive is explicitly presented as a safety and recovery mechanism, yet the uninstall step removes that safeguard wholesale.

Content

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

bash
rm -rf ~/.openclaw/workspace/skills/openclaw-cleaner
rm -rf ~/.openclaw/workspace/cleaner-archive
# 如有 cron,手动删除对应的 cron job

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest description and all user-facing instructions are written only in Chinese, with no indication that other languages are supported or that the user can choose their preferred locale. This is a natural-language policy concern because the skill implicitly enforces a specific language without opt-in or justification of a region-specific scope.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
82% confidence
Finding

The installation instruction uses npx skills without pinning a specific version, which can cause users to execute whatever package version is current at install time. This creates a supply-chain risk: a compromised, typosquatted, or unexpectedly changed package could run arbitrary code during installation or skill management.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The configuration defines broad delete rules for common file types such as audio, images, HTML, temp files, and logs, with some set to delete immediately. Although the metadata says scanning is under ~/.openclaw/workspace/ and dry_run is enabled by default, the patterns themselves are coarse and could cause accidental data loss if the effective scan scope expands, user overrides are unsafe, or dry_run is disabled without careful review.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The natural-language comments and documentation in this file are written exclusively in Chinese, with no indication that users may choose another language or that the locale is intentionally region-specific. This can violate language or locale policy when a skill imposes a language without opt-in or justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

This shell script includes natural-language usage text and status messages in Chinese, which imposes a specific language on users. Under the policy, forced language/locale without user opt-in is a natural-language policy violation unless clearly justified as region-specific.

Content

No source excerpt is available for this finding.