Back to skill

Security audit

safe-backup

Security checks for vulnerabilities and agentic risk

Overview

This backup skill is review-worthy because it packages broad OpenClaw state and workspace data and documents remote storage workflows that can persist or expose sensitive content.

Install only if you need this exact OpenClaw backup workflow. Prefer local encrypted storage, inspect the archive contents before keeping or transferring it, avoid committing raw backups to git, and do not use the remote rsync example without expanding exclusions and encrypting first. Run it only on machines where local temp-directory exposure is acceptable or after hardening the script's temporary-file handling.

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/backup.sh:21
Finding
Predictable and Insufficiently Protected Temporary Backup Files<![CDATA[ ## Vulnerability Details **File Location**: `scripts/backup.sh`, lines 21-23 and 81-113 **Vulnerability Type**: Unsafe temporary-file handling and plaintext exposure of sensitive backup data **Risk Level**: Medium ### Vulnerable Code ```bash BACKUP_DIR="$TEMP_DIR/safe-backup-$TS" STATE_DIR="${OPENCLAW_STATE_DIR:-$HOME/.openclaw}" WORKSPACE_DIR="${OPENCLAW_WORKSPACE_DIR:-$HOME/.openclaw/workspace}" ``` ```bash # 1. Create temporary backup directory echo "[1/4] Creating backup directory..." mkdir -p "$BACKUP_DIR" # 2. Copy state directory (exclude sensitive files) echo "[2/4] Copying state directory..." # Build rsync args array RSYNC_ARGS=("-a" "--delete") for pattern in "${EXCLUDE_PATTERNS[@]}"; do RSYNC_ARGS+=("--exclude=$pattern") done rsync "${RSYNC_ARGS[@]}" "$STATE_DIR/" "$BACKUP_DIR/state/" # 3. Copy workspace (if exists) - use rsync with same exclusions echo "[3/4] Copying workspace..." if [ -d "$WORKSPACE_DIR" ]; then # Use rsync with same exclusion patterns as state directory rsync "${RSYNC_ARGS[@]}" "$WORKSPACE_DIR/" "$BACKUP_DIR/workspace/" else echo "Warning: Workspace directory not found: $WORKSPACE_DIR" fi # 4. Package echo "[4/4] Packaging backup..." cd "$TEMP_DIR" tar -czf "safe-backup-$TS.tar.gz" "safe-backup-$TS" # Cleanup temp directory rm -rf "$BACKUP_DIR" ``` ### Technical Analysis The script creates its staging directory and output archive directly under a temporary directory using a timestamp with one-second precision. On Linux, this is normally the shared `/tmp` directory. It uses `mkdir -p` rather than a securely and atomically created directory such as one produced by `mktemp -d`. Because the path is predictable, another local user can pre-create the expected staging path or insert symbolic links into it before the script reaches `mkdir` or `rsync`. The script does not verify that the staging directory and its components are real directories owned by the invoking user. The script also does not set ...[truncated 2704 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Set restrictive permissions before creating any backup content: ```bash umask 077 ``` 2. Create the staging directory atomically with `mktemp`: ```bash BACKUP_DIR="$(mktemp -d "${TEMP_DIR%/}/safe-backup.XXXXXXXX")" ``` 3. Register cleanup immediately so partial staging data is removed on both success and failure: ```bash cleanup() { rm -rf -- "$BACKUP_DIR" } trap cleanup EXIT HUP INT TERM ``` 4. Validate the temporary-directory environment before use: - Require it to exist and be a directory. - Reject symbolic links where appropriate. - Verify it is owned by the invoking user or has secure sticky-directory semantics. - Canonicalize paths before destructive operations. 5. Securely create the output archive and explicitly restrict its permissions: ```bash BACKUP_FILE="$(mktemp "${TEMP_DIR%/}/safe-backup.XXXXXXXX.tar.gz")" chmod 600 "$BACKUP_FILE" tar -czf "$BACKUP_FILE" -C "$(dirname "$BACKUP_DIR")" "$(basename "$BACKUP_DIR")" ``` 6. Prefer authenticated encryption as part of the backup operation rather than leaving an unencrypted archive in shared temporary storage. If encryption is optional, clearly warn the user that the archive remains plaintext until encrypted. 7. Validate that `BACKUP_DIR` is non-empty, canonical, owned by the current user, and located beneath the intended temporary root before passing it to `rm -rf`. 8. Treat exclusion patterns as defense in depth rather than a complete secret-management control. Consider an allowlist of necessary backup paths and add checks for sensitive file permissions or recognized key formats before packaging. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (10)

Tool Parameter Abuse

High
Category
Tool Misuse
Content
git push origin main

# Delete local copy
rm -rf ~/safe-backup
rm "$BACKUP_FILE"
```
Confidence
90% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
git push origin main

# Delete local copy
rm -rf ~/safe-backup
rm "$BACKUP_FILE"
```
Confidence
90% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Credential Access

High
Category
Privilege Escalation
Content
# Credentials & Keys
    "*.key"
    "*.pem"
    ".env"
    ".env.*"
    "id_rsa*"
    "id_ed25519*"
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
"*.secret"
    "*.token"
    "auth-profiles.json"
    "credentials.json"
    "api-keys.json"
    
    # Runtime generated (not needed for migration)
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
"*.secret"
    "*.token"
    "auth-profiles.json"
    "credentials.json"
    "api-keys.json"
    
    # Runtime generated (not needed for migration)
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Vague Triggers

Medium
Confidence
96% confidence
Finding
The trigger description includes broad everyday actions such as backup, export, or save state, which can cause the skill to activate in unintended contexts. For a skill that packages user state and workspace data, accidental invocation raises the risk of unnecessary data collection, staging sensitive files, or guiding a user into unsafe backup/export behavior.

Intent-Code Divergence

Medium
Confidence
98% confidence
Finding
The document states that the script does not automatically push to any remote, but later provides explicit instructions to clone a GitHub repository, extract backup contents into it, commit, and push, as well as rsync to a remote server. This contradiction can mislead users into underestimating the network exposure and sensitivity of the workflow.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The skill is presented as a safe local backup workflow, but its documented storage options extend into publishing extracted backup contents to a GitHub repository and synchronizing data to a remote server. Even if framed as optional, these instructions materially increase the chance of exfiltrating configuration, memory, workspace content, or other sensitive state to third-party infrastructure.

Session Persistence

Medium
Category
Rogue Agent
Content
git clone https://github.com/YOUR_USERNAME/safe-backup.git ~/safe-backup

# Extract backup
mkdir -p ~/safe-backup/$(date +%Y-%m-%d)
tar -xzf "$BACKUP_FILE" -C ~/safe-backup/$(date +%Y-%m-%d)/

# Commit and push
Confidence
84% confidence
Finding
The workflow directs users to extract backup contents into a Git repository and commit/push them, creating long-lived copies of application state that may persist in git history even after deletion. Because backups can still contain sensitive configuration, memory, and workspace data, this increases persistence and recovery difficulty if exposed.

File System Enumeration

Medium
Category
Data Exfiltration
Content
```bash
# Check if OpenClaw is installed
ls -la ~/.openclaw
```

### "Permission denied"
Confidence
60% confidence
Finding
Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

Static analysis

No suspicious patterns detected.