T09 · Insecure Skill Coding Practices
- Location
scripts/ctm.sh:361- Finding
Remote Command Injection Through the --remote-dir Argument
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This is a real OpenClaw backup and migration tool, but it handles credentials and remote restore commands in ways that need careful review before use.
Install only if you trust the publisher and need full OpenClaw state backup or migration. Treat every backup as a sensitive secrets bundle, store it privately, do not restore archives from untrusted sources, avoid --force unless automation is intentional, do not use untrusted --remote-dir values, and prefer fixing the remote-script quoting, archive validation, and file-permission controls before production use.
scripts/ctm.sh:361Remote Command Injection Through the --remote-dir Argument
scripts/ctm.sh:183Sensitive Backup Archives Are Created Without Enforced Private Permissions
scripts/ctm.sh:264Restore Extracts Untrusted Archives Without Content or Authenticity Validation
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).
local item
for item in "${SOUL_FILES[@]}"; do
if [[ -e "$OPENCLAW_DIR/$item" ]]; then
rm -rf -- "$OPENCLAW_DIR/$item"
fi
done
}
The remote restore script performs rm -rf on paths derived from the user-controlled --remote-dir value after simple string substitution into a shell script. If REMOTE_DIR is set to a dangerous location such as /, $HOME, or a path containing shell metacharacters, the generated remote script can delete unintended files or execute injected commands on the remote host during migration.
for item in $SOUL_ITEMS; do
if [ -e "$REMOTE_DIR/$item" ]; then
rm -rf -- "$REMOTE_DIR/$item"
fi
done
The activation description is broad enough to trigger on very common terms like backup, restore, migration, and generic Chinese equivalents. That can cause the skill to activate in contexts where the user did not intend to invoke a highly privileged state-management tool, increasing the chance of destructive restore or data-exfiltrating migration actions being suggested or run.
The skill is explicitly designed to persist and archive sensitive session and installation state, including credentials, identity, workspace memories, and custom skills, into backups under a user directory and to migrate them to remote hosts. This materially increases exposure of secrets at rest and in transit, especially if backup permissions, encryption, retention, or destination trust are not tightly controlled.
Commands:
- `backup [filename]` — create a backup under `~/.ctm/`
- `list` — show backups, newest first
- `restore <index|filename|latest> [--force]` — restore a backup
- `migrate <user@host> [--remote-dir <dir>] [--clean-remote-archive] [--force]` — copy a backup to another machine and restore it there
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.
High-level sequence:
1. Create a fresh backup on the source machine
2. Copy the archive to the target machine
3. Ensure `~/.openclaw` exists on the target machine
4. Create a safety backup of target state paths if they exist
The script is explicitly designed to back up and migrate highly sensitive state, including credentials, identity, workspace memory, skills, and scheduled tasks. In this skill context, preserving and exporting that material increases risk because the resulting tar.gz archives are not encrypted, are copied to a predictable backup directory, and are transferred to remote hosts, creating a concentrated secrets bundle that could be stolen or misused if local or remote storage is compromised.
$SCRIPT_NAME migrate <user@host> [--remote-dir <dir>] [--clean-remote-archive] [--force]
Commands:
backup Create a backup in $BACKUP_DIR
list List backups, newest first
restore Restore by index, filename, or 'latest'
migrate Create a fresh backup, copy it to a remote host, and restore there
This shell script includes user-facing operational messages in Chinese, such as dependency and error output, without any indication that language is configurable or selected by user preference. That can violate a language/locale policy when a skill is expected to respect user locale or offer opt-in.