Back to skill

Security audit

ccc3po-session-cleaner

Security checks for vulnerabilities and agentic risk

Overview

This skill does what it says at a high level, but it can permanently delete OpenClaw session files without preview, confirmation, backup, or reliably protecting the main session.

Review before installing. Only use this skill if you are comfortable with permanent deletion of OpenClaw session history. A safer version should use a specific trigger, validate the session directory, preview files, require confirmation, exclude the active or main session, and back up files before 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
SKILL.md:17
Finding

Unprotected Session Cleanup Can Delete the Main Session or Files in an Unintended Directory

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 17–19
Vulnerability Type: Unsafe destructive file operation
Risk Level: Medium

sh
2. Safe clean old session files (retain main session)
cd /home/ubuntu/.openclaw/agents/main/sessions/
find . -name "*.jsonl" -mtime +3 -delete 2>/dev/null

Technical Analysis

The cleanup instruction claims to retain the main session, but the find expression does not identify or exclude it. Every matching .jsonl entry older than three days is deleted, including the main session if it satisfies those conditions.

The operation is irreversible and lacks a dry run, backup, confirmation prompt, or validation of the files selected for deletion. It also suppresses error output, making failures and partial cleanup harder to detect.

In addition, the deletion command depends on the preceding cd succeeding. If an automation runner executes subsequent commands after a failed directory change, find . operates on the runner's existing working directory. The practical scope remains limited to matching files that the executing account is permitted to delete, but it may exceed the intended OpenClaw session directory.

Attack Path

  1. The user or automation invokes the clean sessions trigger.
  2. The cleanup enters, or attempts to enter, the configured session directory.
  3. find selects every accessible entry named *.jsonl whose modification time is more than three days old.
  4. No condition excludes the active or main session.
  5. Selected files are permanently deleted without confirmation or backup.
  6. openclaw session rebuild reconstructs the index from the remaining files, making the deleted sessions unavailable.
  7. If the directory change failed and the runner did not abort, matching files under an unintended current directory could instead be deleted.

Impact Assessment

The operation executes with the privileges of the account running the Skill. ...[truncated 488 chars]

Remediation
View remediation

Remediation Suggestions

  1. Use a validated absolute target directory and terminate immediately if it cannot be entered:

    sh
    SESSION_DIR="/home/ubuntu/.openclaw/agents/main/sessions"
    [ -d "$SESSION_DIR" ] || {
      echo "Session directory does not exist" >&2
      exit 1
    }
    cd -- "$SESSION_DIR" || exit 1
    
  2. Determine the authoritative active or main session identifier through OpenClaw and explicitly exclude its file from cleanup. Do not rely only on file age to distinguish sessions.

  3. Restrict selection to regular files and preview the exact deletion set before making changes:

    sh
    find "$SESSION_DIR" -maxdepth 1 -type f -name '*.jsonl' -mtime +3 -print
    
  4. Require explicit confirmation before deletion, especially when invoked interactively.

  5. Create a timestamped, recoverable backup before cleanup and verify that the backup succeeded.

  6. Perform deletion only after validating that every selected file is inside the canonical session directory and is not the active session.

  7. Remove 2>/dev/null; record and report deletion errors so partial failures are visible.

  8. Rebuild sessions.json only after cleanup succeeds, then verify the rebuilt index and confirm that the main session remains present.

Vulnerability Patterns
  • 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
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (1)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The trigger phrase 'clean sessions' is short and generic enough to plausibly appear in normal user conversation or administrative discussion, which can cause unintended activation. In this skill's context, accidental execution is more dangerous because the actions perform file deletion under a fixed session directory and rebuild session state, potentially causing data loss or disruption even without malicious intent.

Content

No source excerpt is available for this finding.