T09 · Insecure Skill Coding Practices
- Location
scripts/backup-restore.js:260- Finding
Shell Command Injection Through User-Controlled Archive and Backup Paths
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is a real backup and restore tool, but it handles credential-bearing backups through unsafe shell commands and an exposed HTTP server, so it should be reviewed carefully before use.
Only use this with backups you created and trust. Do not expose the HTTP server beyond localhost, do not transfer archives over plain HTTP, rotate any tokens exposed through a backup or server URL, and treat restore as equivalent to installing persistent code and credentials into ~/.openclaw.
scripts/backup-restore.js:260Shell Command Injection Through User-Controlled Archive and Backup Paths
scripts/server.js:129Stored Cross-Site Scripting Through Uploaded Archive Filenames
scripts/server.js:67Cleartext Public HTTP Service Exposes Credential-Bearing Backups and Bearer Tokens
scripts/backup-restore.js:793Untrusted Backup Archives Can Install and Automatically Execute Restored Code
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.
# 🦞 MyOpenClaw Backup Restore �?跨平台备份还原工�?
> �?[MyClaw.ai](https://myclaw.ai) 开源技能生态提�?
**一个命令备份,一个命令还原。支�?Windows、macOS、Linux 互相备份还原�?*
The skill description claims a built-in HTTP server and 'only requires Node.js,' while the analysis says the code relies on external commands such as tar, unzip, PowerShell, bash, and openclaw CLI and may not implement the advertised server behavior. This mismatch is security-relevant because operators may deploy the skill under false assumptions about its attack surface, dependencies, portability, and review requirements.
Referenced artifact was not completely inspected
node scripts/backup-restore.js backup
Referenced artifact was not completely inspected
node scripts/backup-restore.js backup
Referenced artifact was not completely inspected
node scripts/backup-restore.js backup
Referenced artifact was not completely inspected
node scripts/backup-restore.js backup
Referenced artifact was not completely inspected
node scripts/backup-restore.js backup
Referenced artifact was not completely inspected
node scripts/backup-restore.js backup
Referenced artifact was not completely inspected
node scripts/backup-restore.js backup
Referenced artifact was not completely inspected
node scripts/server.js --token <secret> [--port 7373] [--backup-dir <dir>]
The quick-start section presents restore commands immediately after backup/list commands, and although a dry-run is shown, it does not prominently warn that restore modifies local state and may overwrite credentials, configuration, and conversation data. In a tool explicitly handling highly sensitive OpenClaw state, understated warning language increases the chance of unsafe operator use and accidental destructive restoration.
The HTTP management server section advertises browser-based upload and download of backup archives without placing an immediate privacy warning beside those features. Because the same README elsewhere states backups contain bot tokens, API keys, credentials, and full conversation history, omitting that warning in the network-transfer section materially increases the risk of accidental exposure or insecure sharing.
The skill metadata grants filesystem read/write and network-listen access, but the static finding indicates the documented tool scope does not accurately disclose shell/env capabilities used by the implementation. Undeclared execution capability is dangerous because it expands what the skill can do beyond what reviewers and users can reasonably infer, especially for a backup/restore tool that handles secrets and system state.
This skill is explicitly designed to preserve and migrate session state, credentials, tokens, and other persistent agent data across machines. That behavior is expected for backup/restore, but it is still sensitive because compromise of archives or misuse of restore operations can transfer active secrets and long-lived access between environments.
---
name: myopenclaw-backup-restore
description: "Cross-platform backup and restore for OpenClaw. Works on Windows, macOS, and Linux — backups created on any OS can be restored on any other OS. Use when user wants to create a snapshot, restore from backup, migrate to a new machine, or protect against data loss. Supports dry-run preview, automatic pre-restore snapshots, gateway token preservation, credential permission hardening, and a built-in HTTP server for browser-based management. Only requires Node.js (no bash/rsync/python needed)."
metadata:
openclaw:
requires:
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
node scripts/backup-restore.js backup [--output-dir
]
Creates `openclaw-backup_{agent}_{timestamp}.tar.gz` in `~/openclaw-backups/`. Auto-prunes (keeps last 7). On non-Windows: `chmod 600` applied.
### restore
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
node scripts/backup-restore.js backup [--output-dir
]
Creates `openclaw-backup_{agent}_{timestamp}.tar.gz` in `~/openclaw-backups/`. Auto-prunes (keeps last 7). On non-Windows: `chmod 600` applied.
### restore
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
- **Pre-restore snapshot**: Auto-saves current state before overwriting
- **Gateway token preservation**: Keeps new server's token (prevents Control UI mismatch)
- **Interactive confirmation**: Must type `yes`
- **Credential hardening**: `chmod 700/600` on non-Windows
- **Auto-restart**: Starts gateway after restore
- **Legacy compatibility**: Handles v1 (bash) and v2 archive structures
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
- **Pre-restore snapshot**: Auto-saves current state before overwriting
- **Gateway token preservation**: Keeps new server's token (prevents Control UI mismatch)
- **Interactive confirmation**: Must type `yes`
- **Credential hardening**: `chmod 700/600` on non-Windows
- **Auto-restart**: Starts gateway after restore
- **Legacy compatibility**: Handles v1 (bash) and v2 archive structures
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
- **Pre-restore snapshot**: Auto-saves current state before overwriting
- **Gateway token preservation**: Keeps new server's token (prevents Control UI mismatch)
- **Interactive confirmation**: Must type `yes`
- **Credential hardening**: `chmod 700/600` on non-Windows
- **Auto-restart**: Starts gateway after restore
- **Legacy compatibility**: Handles v1 (bash) and v2 archive structures
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
*
* SECURITY:
* - Archives contain bot tokens, API keys, and session credentials
* - Permissions hardened on non-Windows (chmod 600 for archive, 700/600 for credentials)
* - Pre-restore snapshot always created before overwriting
* - Gateway token preserved by default (prevents Control UI mismatch)
* - Interactive confirmation required before destructive restore
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
*
* SECURITY:
* - Archives contain bot tokens, API keys, and session credentials
* - Permissions hardened on non-Windows (chmod 600 for archive, 700/600 for credentials)
* - Pre-restore snapshot always created before overwriting
* - Gateway token preserved by default (prevents Control UI mismatch)
* - Interactive confirmation required before destructive restore
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
*
* SECURITY:
* - Archives contain bot tokens, API keys, and session credentials
* - Permissions hardened on non-Windows (chmod 600 for archive, 700/600 for credentials)
* - Pre-restore snapshot always created before overwriting
* - Gateway token preserved by default (prevents Control UI mismatch)
* - Interactive confirmation required before destructive restore
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
*
* SECURITY:
* - Archives contain bot tokens, API keys, and session credentials
* - Permissions hardened on non-Windows (chmod 600 for archive, 700/600 for credentials)
* - Pre-restore snapshot always created before overwriting
* - Gateway token preserved by default (prevents Control UI mismatch)
* - Interactive confirmation required before destructive restore
The script invokes external programs via execSync for version detection, archive creation/extraction, and service control, which expands trust beyond local file operations. Because some command arguments incorporate file paths and restored content later influences execution flow, a crafted archive or attacker-controlled environment can turn restore into code execution or unsafe command behavior.
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
// ── Interactive confirmation ─────────────────────────────────────────
console.log('');
console.log(c.red('⚠️ WARNING: This will OVERWRITE ~/.openclaw/ with backup data.'));
console.log(` Backup: ${path.basename(archive)}`);
console.log(` Target: ${OPENCLAW_DIR}`);
if (currentToken && !overwriteToken) {