Back to skill

Security audit

系统清理技能

Security checks for vulnerabilities and agentic risk

Overview

This OpenClaw cleanup skill is mostly purpose-aligned, but needs review because its script can delete editor swap files automatically and handles filenames unsafely.

Review before installing or running. Use it only for OpenClaw-specific maintenance, avoid scheduled unattended runs unless you accept automatic cleanup behavior, and inspect the listed files before deletion. The cleanup script should be fixed to require confirmation for swap files and use null-delimited filename handling before routine use.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/cleanup.sh:84
Finding

Unconfirmed File Deletion with Unsafe Filename Handling

Content
View full analysis
/dev/null) if [ -n "$swp_files" ]; then log "找到vim交换文件:" echo "$swp_files" | while read -r file; do log_warning " $file" done echo "$swp_files" | xargs -r rm -v ``` ### Technical Analysis The script recursively locates `.swp` and `.swx` entries under `~/.openclaw` and deletes them automatically. It does not request confirmation, even though `SKILL.md` states that files should be listed and confirmed before deletion. The script transports pathnames through command substitution, newline-delimited text, `echo`, and `xargs`. Unix filenames may contain spaces, tabs, quotes, backslashes, and newline characters. Consequently, the pathnames produced by `find` can be split or reinterpreted by `xargs` as multiple independent arguments to `rm`. The `find` expression also lacks `-type f` and explicit grouping: ```bash find "$OPENCLAW_DIR" -name "*.swp" -o -name "*.swx" ``` Although operator precedence makes the two name patterns function as alternatives in this particular expression, omitting `-type f` allows matching non-regular filesystem entries. The deletion command also lacks an explicit `--` end-of-options marker. ### Attack Path 1. An attacker or compromised process obtains permission to create directories and files beneath the victim's `~/.openclaw` directory. 2. The attacker creates a directory hierarchy containing whitespace so that the actual matching pathname is parsed by `xargs` into multiple path operands. For example, a path component ending in a space can cause the remainder of the emitted pathname to appear as a separate absolute-looking operand after whitespace tokenization. 3. The attacker places a matching `.swp` or `.swx` entry at ...[truncated 1141 chars]
Remediation
View remediation
0)); then log "Found Vim swap files:" printf ' %q\n' "${swp_files[@]}" read -r -p "Delete these swap files? (y/N): " confirm if [[ "$confirm" =~ ^[Yy]$ ]]; then rm -v -- "${swp_files[@]}" else log "Skipped swap-file cleanup" fi fi ``` 4. For unattended execution, make deletion opt-in through an explicit option such as `--force` or `--non-interactive`; default to report-only behavior. 5. Consider detecting whether a swap file is associated with a running editor before deletion. At minimum, apply an age threshold and clearly warn that swap files may contain recoverable unsaved work. 6. Run the cleanup script only with the minimum required user privileges. Do not invoke it as root unless privileged cleanup is explicitly necessary. ]]>
Vulnerability Patterns
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (7)

Chaining Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

The pipeline echo "$swp_files" | xargs -r rm -v is unsafe because xargs splits on whitespace and can mis-handle filenames containing spaces, tabs, newlines, or shell-metacharacter-like text. In practice, an attacker who can create crafted filenames under the scanned directory could cause unintended files to be passed to rm, leading to accidental deletion within the user's scope.

Content

Scanner excerpt · scripts/cleanup.sh (reported line 89)May include surrounding context.

sh
echo "$swp_files" | while read -r file; do
        log_warning "  $file"
    done
    echo "$swp_files" | xargs -r rm -v
    log_success "临时文件清理完成"
else
    log "未找到vim交换文件"

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill content and operational guidance are presented in Chinese, which can impose a specific language on users or maintainers without opt-in. Under the stated policy, language constraints should either offer a choice or be clearly documented as justified for a region-specific use case.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The activation condition is very broad: it triggers on generic requests for cleanup, maintenance, optimization, or freeing disk space, which can cause the skill to run in contexts the user did not specifically intend. In a destructive file-deletion skill, over-broad matching increases the chance of unsafe invocation and unintended deletion or system changes, especially when combined with shell commands and scheduled automation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The manifest description is written entirely in Chinese and provides no indication that other languages are supported or that this skill is intentionally region-specific. Under the policy, forcing a specific language without user opt-in or justification is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This shell script performs a file-deletion operation with xargs -r rm -v on discovered *.swp and *.swx files, but unlike the backup-file cleanup path it provides no confirmation prompt before removing them. Although the script logs the files found, there is no user disclosure that deletion will happen automatically at this step, which makes the destructive action easy to miss.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The script's comments, prompts, and log messages are written in Chinese, including the deletion confirmation prompt, with no option to select another language or locale. This can violate language/locale policy when a skill forces a specific language without user opt-in.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The header comments at L003-L004 describe the script as cleaning temporary and backup files. In addition to cleanup-related actions, the code at L141-L143 invokes openclaw gateway status and parses service/runtime output, which is a status inspection capability rather than cleanup behavior.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.