T09 · Insecure Skill Coding Practices
- Location
scripts/smart-backup.sh:26- Finding
Authentication credentials are duplicated without explicit backup permission hardening
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill’s recovery purpose is coherent, but it installs persistent automatic jobs that can change OpenClaw configuration and backs up authentication files with unsafe handling.
Review before installing. This skill is not clearly malicious, but it should be treated as high-impact: it installs recurring cron jobs, can automatically overwrite OpenClaw config and restart the gateway, and backs up authentication files. Install only if you accept unattended recovery, verify backup directory permissions, and check that the uninstaller will not remove unrelated backup or recovery jobs.
scripts/smart-backup.sh:26Authentication credentials are duplicated without explicit backup permission hardening
scripts/rollback.sh:14Crafted backup filenames can inject code into Python validation commands
scripts/uninstall.sh:24Uninstaller removes unrelated cron jobs and terminates unrelated processes
The cleanup pipeline uses ls ... | tail ... | xargs rm -f, which is unsafe because filenames are parsed through whitespace-delimited text processing. If a crafted backup filename contains spaces, newlines, or begins with option-like content, xargs rm may delete unintended files or behave unpredictably; using shell pipelines for deletion also creates avoidable fragility around edge cases.
cp "$CONFIG_FILE" "$BACKUP_FILE"
# 保留最近20个备份,删除旧的
ls -t "$BACKUP_DIR"/openclaw.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
echo "备份完成: $BACKUP_FILE"
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.
echo "[\$(date)] 备份完成 - 原因: \$reason" >> "\$LOG_FILE"
# 清理:保留最近20个 + 7天历史
ls -t "\$BACKUP_DIR"/openclaw.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
ls -t "\$BACKUP_DIR"/auth-profiles.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
find "\$BACKUP_DIR" -name "*.bak.*" -mtime +7 -type f -delete 2>/dev/null
}
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.
echo "[\$(date)] 备份完成 - 原因: \$reason" >> "\$LOG_FILE"
# 清理:保留最近20个 + 7天历史
ls -t "\$BACKUP_DIR"/openclaw.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
ls -t "\$BACKUP_DIR"/auth-profiles.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
find "\$BACKUP_DIR" -name "*.bak.*" -mtime +7 -type f -delete 2>/dev/null
}
The YARA hit is triggered by cron-based persistence, and in this file that persistence is real even though there is no obvious secondary malware payload. Because the installer creates recurring background execution of recovery scripts that can alter configuration and restart services, this is security-significant behavior in a skill distribution context.
==================
echo "[4/5] 创建首次备份..."
bash "$INSTALL_DIR/scripts/generated/backup.sh"
# ==================== 定时任务 ====================
echo "[5/5] 设置定时任务..."
case "$OS" in
macos|linux)
CRON_RECOVER="*/5 * * * * bash $INSTALL_DIR/scripts/generated/recover.sh"
CRON_DAILY="0 2 * * * bash $INSTALL_DIR/scripts/generated/backup.sh daily"
(crontab -l 2>/dev/null | grep -v "openclaw-recovery"; echo "$CRON_RECOVER"; echo "$CRON_DAILY") | crontab -
echo " cron 定时任务已设置"
;;
windows)
echo ""
echo " ⚠️ Windows 请手动设置定时任务:"
echo " 1. 打开「任务计划程序」"
echo " 2. 创建任务 → 触发器 → 每 5 分钟"
echo " 3. 操作 → 启动程序: bash $INSTALL_DIR/scripts/generated/recover.sh"
echo ""
echo " 或使用 PowerShell(管理员):"
echo " \$action = New-ScheduledTaskAction -Execute 'bash
The script automatically replaces the active configuration with backup or safe-mode files and restarts the gateway, without user approval and without checking whether the restored config weakens security settings or restores stale secrets. In this skill context, a recovery script runs with the user's privileges against security-relevant auth and gateway configuration, so rollback to an older state could re-enable unsafe settings, revert protective changes, or restore compromised configuration after an incident.
Using ls output piped into xargs rm is an unsafe deletion pattern because filenames are parsed by whitespace and special characters, which can cause unintended files in the backup directory to be deleted if crafted names are present. In this script the damage is somewhat limited by the fixed backup directory and filename prefix, but shell-pipeline deletion remains brittle and should not be used for destructive operations.
# 清理备份函数
cleanup_backups() {
# 保留最近20个
ls -t "$BACKUP_DIR"/openclaw.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
ls -t "$BACKUP_DIR"/auth-profiles.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
ls -t "$BACKUP_DIR"/auth-state.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
This deletion pipeline has the same unsafe parsing issue: filenames from ls are split by xargs, so spaces, newlines, or option-like names can lead to incorrect deletions. Because the script handles credential backups, accidental deletion can interfere with recovery and may be triggered if an attacker can place crafted files in the backup directory.
cleanup_backups() {
# 保留最近20个
ls -t "$BACKUP_DIR"/openclaw.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
ls -t "$BACKUP_DIR"/auth-profiles.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
ls -t "$BACKUP_DIR"/auth-state.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
# 删除7天前的备份(保留每天最新的一个)
This is another instance of unsafe command chaining for file deletion. Although the glob prefix narrows the target set, relying on ls and xargs for destructive actions can still mishandle unusual filenames and produce unintended deletions within the backup store.
# 保留最近20个
ls -t "$BACKUP_DIR"/openclaw.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
ls -t "$BACKUP_DIR"/auth-profiles.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
ls -t "$BACKUP_DIR"/auth-state.json.bak.* 2>/dev/null | tail -n +21 | xargs rm -f 2>/dev/null
# 删除7天前的备份(保留每天最新的一个)
find "$BACKUP_DIR" -name "*.bak.*" -mtime +7 -type f -delete 2>/dev/null
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).
�平台)
set -e
echo "=== OpenClaw 自救系统卸载 ==="
echo ""
INSTALL_DIR="$HOME/.openclaw/workspace/skills/openclaw-recovery"
# 检测 OS
case "$(uname -s)" in
Darwin*) OS="macos" ;;
Linux*) OS="linux" ;;
MINGW*|MSYS*|CYGWIN*) OS="windows" ;;
*) OS="unknown" ;;
esac
echo "[系统] $OS"
# 移除 cron(macOS/Linux)
case "$OS" in
macos|linux)
if crontab -l 2>/dev/null | grep -q "openclaw-recovery\\|recover.sh\\|backup.sh"; then
crontab -l 2>/dev/null | grep -v "openclaw-recovery" | grep -v "recover.sh" | grep -v "backup.sh" | crontab - 2>/dev/null || true
echo "✅ 已移除 cron 定时任务"
fi
;;
windows)
echo " 如有定时任务,请在「任务计划程序」中手动删除 OpenClaw-Recovery"
;;
esac
# 停止可能运行的进程
pkill -f "smart-backup.sh watch" 2>/dev/null || true
pkill -f "recover.sh" 2>/dev/null || true
rm -f "$HOME/.openclaw/backup-watch.pid" 2>/
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).
# 停止可能运行的进程
pkill -f "smart-backup.sh watch" 2>/dev/null || true
pkill -f "recover.sh" 2>/dev/null || true
rm -f "$HOME/.openclaw/backup-watch.pid" 2>/dev/null || true
echo "✅ 已停止后台进程"
# 询问删除备份和日志
rm -rf is inherently destructive, and this script recursively deletes a backup directory after only a single-character confirmation. Although the path is fixed and under $HOME, the context makes this more sensitive because it removes recovery data that could be needed after mistakes or compromise, creating data-loss risk if run unintentionally or in an unexpected environment.
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf "$HOME/.openclaw/backups"
rm -f "$HOME/.openclaw/logs/recovery.log"
rm -f "$HOME/.openclaw/logs/recovery-history.log"
rm -f "$HOME/.openclaw/logs/backup.log"
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).
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf "$HOME/.openclaw/backups"
rm -f "$HOME/.openclaw/logs/recovery.log"
rm -f "$HOME/.openclaw/logs/recovery-history.log"
rm -f "$HOME/.openclaw/logs/backup.log"
rm -f "$HOME/.openclaw/logs/backup-watch.log"
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).
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf "$HOME/.openclaw/backups"
rm -f "$HOME/.openclaw/logs/recovery.log"
rm -f "$HOME/.openclaw/logs/recovery-history.log"
rm -f "$HOME/.openclaw/logs/backup.log"
rm -f "$HOME/.openclaw/logs/backup-watch.log"
echo "✅ 已删除备份和日志"
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).
rm -rf "$HOME/.openclaw/backups"
rm -f "$HOME/.openclaw/logs/recovery.log"
rm -f "$HOME/.openclaw/logs/recovery-history.log"
rm -f "$HOME/.openclaw/logs/backup.log"
rm -f "$HOME/.openclaw/logs/backup-watch.log"
echo "✅ 已删除备份和日志"
else
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).
rm -f "$HOME/.openclaw/logs/recovery.log"
rm -f "$HOME/.openclaw/logs/recovery-history.log"
rm -f "$HOME/.openclaw/logs/backup.log"
rm -f "$HOME/.openclaw/logs/backup-watch.log"
echo "✅ 已删除备份和日志"
else
echo "📁 备份和日志已保留"
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).
read -p "是否删除保底配置 (safe-mode.json)?(y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -f "$HOME/.openclaw/safe-mode.json"
echo "✅ 已删除"
else
echo "📁 已保留"
This markdown file advertises safety-relevant behaviors including automatic configuration changes, rollback to backups, log deletion, and uninstall operations. Although the features are described, the README does not include a clear user warning that these actions can modify or remove configuration, backups, logs, or scheduled tasks, which is the kind of disclosure required for markdown skill descriptions affecting user data or system integrity.
The installation instructions state that the script will configure cron jobs for recurring health checks and backups, enabling persistent unattended execution. In a skill ecosystem, persistence materially changes the trust boundary because the skill continues operating after installation and can repeatedly modify configuration or system state without further user confirmation.
The README instructs users to edit crontab to schedule recurring execution of the recovery script, which establishes persistence. While this is openly documented and likely intended for reliability, persistent scheduled execution increases risk because any flaw or unsafe behavior in the recovery script will be re-triggered automatically over time.
编辑 crontab 修改检查频率:
crontab -e
# 默认:每 5 分钟检查一次
*/5 * * * * /path/to/recover-v2.sh
Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.
ls -la ~/.openclaw/backups/
The skill name, description, and author metadata are entirely presented in Chinese, which indicates a language-specific user experience. The file provides no indication that users can choose another language or that the locale restriction is intentional and justified for a region-specific use case.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
"mode": "merge",
"providers": {
"moonshot": {
"baseUrl": "https://api.moonshot.cn/v1",
"api": "openai-completions",
"models": [
{
The top-level documentation says the installer 'automatically detects the OS' and 'generates an adapted version', which implies a packaging/setup role. However, the generated recover.sh performs active remediation actions including editing ~/.openclaw/openclaw.json, restoring backups, and invoking 'openclaw gateway restart' (L139-L161, L181-L216), which is materially broader than merely generating scripts.
The installer immediately creates directories, writes executable scripts, copies files, performs an initial backup, and later enables persistence, all without an explicit confirmation prompt. In a skill/install context, silent persistent changes reduce user awareness and can normalize unsafe installation patterns that are easily repurposed for abuse.
The generated script header describes 'health monitoring and automatic recovery', which suggests liveness checks and restart behavior. In addition to monitoring/restart, the script edits configuration contents in place by changing compaction and blockStreamingDefault values before restarting (L149-L160, L188-L195), which is a stronger side effect than the header conveys.