Back to skill

Security audit

Cleanup Sessions

Security checks for vulnerabilities and agentic risk

Overview

This skill has a legitimate cleanup purpose, but its documentation includes unsafe broad deletion commands and a missing script reference that could cause unintended file loss.

Review this carefully before installing. Only use it if you are comfortable deleting OpenClaw session history and backups, avoid the raw README rm/find commands, and require a dry-run or explicit file list in the verified sessions directory before any deletion.

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
README.md:40
Finding

Unchecked Directory Change Can Cause Deletion in an Unintended Directory

Content
View full analysis

Vulnerability Details

File Location: README.md, lines 40–42
Vulnerability Type: Unsafe destructive shell commands following an unchecked directory change
Risk Level: Medium

Vulnerable Code:

bash
cd ~/.openclaw/agents/main/sessions
rm -f *.jsonl.deleted.*
find . -name "*.jsonl.reset.*" -mtime +7 -delete

Technical Analysis

The documented cleanup sequence changes directories without verifying that the cd command succeeded. Standard interactive shells do not terminate automatically when cd fails. If the sessions directory is absent, inaccessible, or resolves incorrectly, the subsequent rm and find commands execute from the caller's existing working directory.

The find . operation recursively traverses that directory and deletes every file matching *.jsonl.reset.* that is older than seven days. It is not constrained with -maxdepth 1, so deletion can extend into every accessible descendant directory. The rm -f command may also delete matching files in the unintended current directory while suppressing diagnostics for missing operands.

Attack Path

  1. A user follows the command sequence documented in README.md.
  2. The expected ~/.openclaw/agents/main/sessions directory does not exist, is inaccessible, or cannot be entered.
  3. The cd command fails, but shell execution continues.
  4. rm -f *.jsonl.deleted.* operates in the user's previous working directory.
  5. find . -name "*.jsonl.reset.*" -mtime +7 -delete recursively searches the previous working directory.
  6. Matching files in that directory and its descendants are permanently deleted without confirmation.

A malicious party capable of influencing where the user invokes these instructions, or of causing the expected sessions directory to be unavailable, could increase the likelihood that deletion occurs in a sensitive directory tree.

Impact Assessment

The commands execute with the invoking user's pri ...[truncated 582 chars]

Remediation
View remediation

Remediation Suggestions

  1. Make directory validation mandatory and stop immediately if it fails:

    bash
    sessions_dir="$HOME/.openclaw/agents/main/sessions"
    
    if [ ! -d "$sessions_dir" ]; then
      printf 'Error: sessions directory does not exist: %s\n' "$sessions_dir" >&2
      exit 1
    fi
    
    cd -- "$sessions_dir" || exit 1
    
  2. Constrain searches to the intended directory level and require regular files:

    bash
    find . -maxdepth 1 -type f -name '*.jsonl.deleted.*' -print
    find . -maxdepth 1 -type f -name '*.jsonl.reset.*' -mtime +7 -print
    
  3. Present the exact candidate list and obtain explicit user confirmation before deletion.

  4. After confirmation, delete only the reviewed candidates:

    bash
    find . -maxdepth 1 -type f -name '*.jsonl.deleted.*' -delete
    find . -maxdepth 1 -type f -name '*.jsonl.reset.*' -mtime +7 -delete
    
  5. Prefer a verified cleanup script with fail-fast behavior, such as set -eu, rather than documenting independent destructive commands. The package currently references cleanup.sh, but that script is not present in the audited project and therefore cannot provide the advertised safeguards.

Vulnerability Patterns
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (3)

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The README promises safeguards such as filtering only aborted sub-agent sessions and applying a 48-hour protection window, but the documented shell commands delete backup files broadly based on filename and age without enforcing those checks. This mismatch can mislead users into running destructive cleanup commands under a false assumption of safety, causing unintended deletion of session artifacts that may still be needed for recovery or investigation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The file's natural-language instructions, warnings, and examples are all presented in Chinese, which effectively forces a specific language for users reading or invoking the skill. The policy allows locale constraints only when the skill offers user opt-in or clearly documents a justified region-specific limitation, neither of which appears here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The description and summary are written only in Chinese, with no indication that the skill is region-specific or that users may choose another language. This can violate a language/locale policy when skills are expected to be accessible without forcing a specific language absent opt-in or justification.

Content

No source excerpt is available for this finding.