openclaw-backup
- Type
- Skill
- Scanned
- Nov 17, 2026
- Version
- a05a80d554a3
- Files read
- 18
This skill backs up and restores an entire OpenClaw instance—including agent memory, skills, session history, bot tokens, and API keys—and provides an optional web server for uploading, downloading, and restoring archives. Its biggest risk is that crafted backup filenames or archives can run arbitrary commands on your computer even during a dry-run preview or when you open the local backup web page, bypassing the server's built-in safety checks.
What it can reach
- Files
- Reads and overwrites ~/.openclaw/ (workspace, skills, session history, configuration, and startup scripts) and writes backup archives, temporary files, and logs under /tmp/ or a chosen output folder.
- Secrets
- Reads, packages into .tar.gz archives, and restores bot tokens, channel pairing credentials, and model API keys stored in ~/.openclaw/openclaw.json, ~/.openclaw/credentials/, and ~/.openclaw/agents/.
- Network
- Can start an HTTP server (default port 7373 on all network interfaces) to list, upload, and download backup archives and trigger local backup or restore actions.
- Shell commands
- Executes bash scripts and system tools (tar, rsync, python3, openclaw, kill, pgrep) and restarts ~/.openclaw/start-gateway.sh during restore.
- System
- Reads and modifies the user's system crontab via schedule.sh to run recurring automatic backups.
Findings
-
HighArbitrary code execution during --dry-run restore via archive directory name
Users and agents are instructed to run restore.sh with --dry-run first to safely inspect an archive before making changes. Before asking for confirmation and even in --dry-run mode, restore.sh extracts the archive, finds the openclaw-backup_* directory, and interpolates its path directly inside single quotes in a python3 -c snippet; an archive whose directory name contains single quotes and Python expressions executes arbitrary OS commands immediately.
Fix: Pass file paths and metadata values to Python via command-line arguments (sys.argv) or environment variables (os.environ) instead of interpolating shell variables into python3 -c code strings.
-
MediumShell command injection via backup filename in HTTP restore endpoint
Remote clients with the server token are allowed to upload .tar.gz files via POST /upload, and server.js only checks that the filename ends with .tar.gz without blocking shell characters like $(), backticks, or double quotes. When the local user runs even a 'safe' Dry Run from the web UI, POST /restore/:filename interpolates the file path inside double quotes in a shell command passed to execSync, causing /bin/sh to immediately execute commands embedded in the filename.
Fix: Use execFileSync('bash', [RESTORE_SH, filePath, '--dry-run']) (or spawnSync with input: 'yes\n' for confirmed restores) instead of building a shell command string, and restrict backup filenames to a strict allowlist such as /^[a-zA-Z0-9._-]+\.tar\.gz$/.
-
MediumStored XSS in backup web UI bypasses localhost-only execution protection
The server's security model relies on blocking remote callers from POST /backup and POST /restore while allowing remote callers with the token to upload .tar.gz files. However, serveUI inserts backup filenames directly into the HTML table without escaping, so an uploaded file named openclaw-backup_<img src=x onerror=...>.tar.gz runs attacker JavaScript as soon as the user opens http://localhost:7373, allowing the script to read the token and trigger a full restore from localhost.
Fix: HTML-escape all dynamic values (filename and downloadUrl) before inserting them into ui.html, validate uploaded filenames against a strict alphanumeric pattern, and add a restrictive Content-Security-Policy header.
-
MediumPlaintext credentials staged in predictable, world-readable /tmp directories
Although backup.sh applies chmod 600 to the finished .tar.gz file, it first copies openclaw.json (bot tokens and API keys), channel credentials, and session history into /tmp/openclaw-backup_<agent>_<timestamp> created with mkdir -p under the default umask, leaving secrets readable to other local users during backup and allowing local attackers to pre-create /tmp/openclaw-backups or staging directories. The same predictable /tmp pattern is used during extraction in restore.sh.
Fix: Create staging directories with mktemp -d (which sets 0700 permissions atomically), set umask 077 at the start of backup.sh and restore.sh, and store backups under ~/.openclaw/backups (mode 0700) by default instead of /tmp.
-
LowBackup HTTP server binds to 0.0.0.0 over unencrypted HTTP with no host option
Even though the documentation describes serve.sh as starting a local HTTP server and prints a localhost URL, server.js hardcodes 0.0.0.0 and offers no --host flag to bind to 127.0.0.1. Starting the server on a cloud VPS or shared Wi-Fi exposes the backup API on all network interfaces over plain HTTP, and the migration guide instructs transferring the token and credential-filled archive over unencrypted HTTP.
Fix: Bind to 127.0.0.1 by default, add an explicit --host flag with a clear warning when binding to non-loopback addresses, and recommend SSH port forwarding or scp/sftp for remote transfers.
-
LowServer auth token leaked via process arguments and world-readable /tmp log
When starting the HTTP server, serve.sh passes --token on the node command line (making it visible to all local users via ps) even though server.js already reads BACKUP_TOKEN from the environment, and redirects server output—including the full access URL containing ?token=SECRET—into /tmp/openclaw-backup-server.log without restricting file permissions.
Fix: Pass the token exclusively via the BACKUP_TOKEN environment variable (removing --token from the node CLI invocation), move the log and PID files into a 0700 directory under ~/.openclaw/, and avoid printing the raw token to log files.
