Back to skill

Security audit

backup claw

Security checks for vulnerabilities and agentic risk

Overview

This is a legitimate OpenClaw backup/restore helper, but its restore script can be pointed outside the chosen backup folder and copy arbitrary local files into OpenClaw configuration after confirmation.

Review carefully before installing. Use only a private, trusted backup directory, avoid shared or network-mounted backup paths unless intended, and do not run restore with any value other than a real YYYY-MM-DD backup date. The restore script should be fixed to validate the date and ensure the canonical restore source is an immediate child of the backup root before it is used.

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/restore.sh:29
Finding

Path Traversal Through Unvalidated Restore Date

Content
View full analysis

Vulnerability Details

File Location: scripts/restore.sh, lines 29–41
Vulnerability Type: Path traversal caused by insufficient input validation
Risk Level: Medium

Vulnerable Code

bash
# Validate date format
if [ -z "$RESTORE_DATE" ]; then
    echo -e "${RED}错误: 请指定恢复日期 (YYYY-MM-DD)${NC}"
    echo "Usage: $0 <backup_dir> <date>"
    echo ""
    echo -e "${BLUE}可用的备份日期:${NC}"
    find "$BACKUP_ROOT" -maxdepth 1 -type d -name "20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]" | sort -r | xargs -I {} basename "{}"
    exit 1
fi

# Check if backup directory exists
RESTORE_DIR="$BACKUP_ROOT/$RESTORE_DATE"
if [ ! -d "$RESTORE_DIR" ]; then

The value is subsequently used as the source of the restoration operation:

bash
rsync -av --exclude='workspace' --exclude='workspace/**' "$RESTORE_DIR/" "$OPENCLAW_DIR/"

Technical Analysis

The script labels the initial check as date-format validation, but it only verifies that RESTORE_DATE is nonempty. It does not enforce the documented YYYY-MM-DD format or reject path separators and traversal components such as ...

RESTORE_DIR is constructed by directly concatenating the user-controlled value with BACKUP_ROOT. Shell quoting prevents command injection, but it does not prevent filesystem path resolution. Consequently, a value such as ../../attacker-controlled-directory can resolve outside the designated backup root.

The directory-existence check does not mitigate the issue: it accepts any resolved directory that exists. After interactive confirmation, that directory is passed to rsync as the restoration source.

Attack Path

  1. An attacker or untrusted caller prepares a readable directory containing files intended to overwrite or augment the victim's OpenClaw configuration.
  2. The restore script is invoked with a legitimate backup root and a traversal value in place of the date, for example:
    bash
    ./scripts/restore.s
    

...[truncated 1261 chars]

Remediation
View remediation

Remediation Suggestions

  1. Enforce the date format before constructing a path:

    bash
    if [[ ! "$RESTORE_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
        echo "Error: restore date must use YYYY-MM-DD format" >&2
        exit 1
    fi
    
  2. Optionally verify that the value represents a valid calendar date rather than only matching its shape:

    bash
    if [ "$(date -d "$RESTORE_DATE" +%Y-%m-%d 2>/dev/null)" != "$RESTORE_DATE" ]; then
        echo "Error: invalid restore date" >&2
        exit 1
    fi
    
  3. Canonicalize the backup root and restore directory, then ensure the restore directory is an immediate child of the backup root:

    bash
    BACKUP_ROOT_REAL=$(realpath -- "$BACKUP_ROOT")
    RESTORE_DIR=$(realpath -- "$BACKUP_ROOT_REAL/$RESTORE_DATE") || exit 1
    
    if [ "$(dirname -- "$RESTORE_DIR")" != "$BACKUP_ROOT_REAL" ]; then
        echo "Error: restore source is outside the backup root" >&2
        exit 1
    fi
    
  4. Reject symbolic-link backup directories or establish an explicit symlink policy so canonicalization cannot redirect restoration to an unintended source.

  5. Display the canonical restore source in the confirmation prompt and consider validating backup integrity or provenance before copying files into ~/.openclaw.

Vulnerability Patterns
  • Rogue AgentSelf-Modification, Session Persistence
  • 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 (8)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The code substantially matches the backup portion of the description: it backs up ~/.openclaw, excludes workspace, uses a date-stamped directory, checks for changes against the latest backup, and logs changes to changelog.md. It also requires a backup directory argument, consistent with obtaining the backup path from the user. However, the declared description explicitly includes restore functionality ('restore from a previous backup' / 'restore by date'), and this code chunk contains no restore logic at all. That is a material description-to-behavior mismatch.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
83% confidence
Finding

Persisting the user-provided backup directory in ~/.openclaw/backup.json creates session-persistent state that can influence future executions without fresh confirmation. In a filesystem-writing skill, persisted paths can become dangerous if later runs automatically trust stale or attacker-influenced locations, leading to writes into unintended directories or exposure through shared/network paths.

Content

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

md
2. If exists, read "backup_location" field
3. If missing or file doesn't exist:
   - Ask user for backup directory path
   - Create `~/.openclaw/backup.json` with the provided path
   - Confirm path to user

**Change backup directory (changedir command):**

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

The skill performs local file writes, directory creation, copy operations, and diff-based inspection, but the user-facing description does not clearly warn that it will modify files and persist backup state. That gap can mislead users about the sensitivity and side effects of invoking the skill, especially because it operates on configuration directories and backup locations.

Content

No source excerpt is available for this finding.

Skill Enumeration

Medium
Category
Agent Snooping
Confidence
80% confidence
Finding

The changelog example explicitly records internal path names such as extensions/feishu/skills/feishu-doc/SKILL.md, which can reveal installed extensions, skill names, and filesystem structure. If shown to the user or stored in a shared backup location, this enumeration can aid reconnaissance about the local agent environment and available capabilities.

Content

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

markdown
  ## 2026-03-12 14:30:00
  - openclaw.json (modified)
  - extensions/feishu/skills/feishu-doc/SKILL.md (added)

Exclusion rules:

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger phrases are broad enough that ordinary requests like 'check if config changed' or '修改备份目录' could invoke a skill that reads configuration, writes backup metadata, and performs filesystem operations. Over-broad invocation increases the chance of unintended state changes or disclosure of local configuration structure without sufficiently explicit user intent.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The error-handling guidance says to provide clear error messages in Chinese when appropriate, and other parts of the document include fixed Chinese user-facing strings. This imposes a language preference without explicitly asking the user or offering a language choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script's interactive prompts, warnings, and status messages are presented in Chinese throughout the file. Because the file does not indicate that the skill is region-specific or provide any user opt-in or fallback language, this is a natural-language locale policy issue under the stated rules.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

This shell script emits user-facing status and error text in Chinese, e.g. the error message at L020, and similar messages continue throughout the file. Because the file provides no opt-in, fallback, or justification for a Chinese-only locale, it conflicts with the language/locale policy criteria for natural-language content.

Content

No source excerpt is available for this finding.