T09 · Insecure Skill Coding Practices
- Location
scripts/memory-backup.sh:29- Finding
Shell Command Injection Through GIT_SSH_COMMAND
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is a coherent memory backup tool, but it can automatically push sensitive memory files to a Git remote without reliable user confirmation.
Install only if you are comfortable with conversation memory, profile files, and workflow notes being committed to a user-configured Git remote. Use a private repository, a dedicated least-privilege SSH key, review diffs before every push, avoid cron until the script fails closed without approval, and do not rely on the built-in secret scanner as complete protection.
scripts/memory-backup.sh:29Shell Command Injection Through GIT_SSH_COMMAND
scripts/memory-backup.sh:70Non-Interactive Execution Bypasses Push Confirmation
scripts/memory-sync.sh:41Incomplete Secret Detection Allows Credentials to Be Backed Up
scripts/memory-sync.sh:22Symbolic-Link Bypass Permits Reading Files Outside the Workspace
scripts/memory-backup.sh:29General-Purpose SSH Private Key Is Used as the Default Backup Identity
声明描述的是一个较完整的“记忆管理与同步”技能,包含写入、同步、备份、恢复和对话触发等能力。但提供的代码只是单一的 Git 备份脚本:追踪固定路径,提交并推送到 Git 远程仓库。虽然其中“通过 Git 推送到远程仓库备份”这一点与声明部分一致,但其余核心能力并未在代码中体现。代码也没有解析对话内容、自动写入记忆、恢复文件、或任何跨渠道接口/同步实现。因此描述明显宽于实际行为,存在实质性不匹配。
The description does not prominently warn that conversation content may be synchronized across channels and pushed to a remote Git repository, which is a significant data handling and exfiltration concern. Users may invoke the skill for local memory persistence without realizing the content could be replicated and transmitted off-host, including potentially sensitive cross-channel context.
The workflow includes a raw rm command using a templated path, which is dangerous because the substituted name may be wrong, ambiguous, or attacker-influenced, leading to unintended deletion. In a memory backup skill, file operations are part of the core behavior, so unsafe deletion guidance is more dangerous than in passive documentation because an agent or user may execute it during routine maintenance.
ls docs/<名称>-workflow.md 2>/dev/null && echo "旧版存在,需删除"
# 3. 确认新版内容已包含旧版所有有价值信息后,删除旧版
rm memory/<名称>-workflow.md
rm docs/<名称>-workflow.md
# 4. 推送备份
This second rm command targets the docs path and has the same tool-parameter abuse risk: a templated filename can cause deletion of the wrong document or removal of legitimate files during migration. Because the skill promotes automatic backup/sync workflows, destructive commands embedded in the process can propagate operational mistakes and cause irreversible loss of documentation.
# 3. 确认新版内容已包含旧版所有有价值信息后,删除旧版
rm memory/<名称>-workflow.md
rm docs/<名称>-workflow.md
# 4. 推送备份
bash scripts/memory-backup.sh
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
GIT_REMOTE="${GIT_REMOTE:-}"
# TODO: 替换为你的 SSH 私钥路径
MEMORY_BACKUP_KEY="${MEMORY_BACKUP_KEY:-~/.ssh/id_rsa}"
# ---- 配置校验 ----
if [ -z "$GIT_REMOTE" ]; then
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
fi
# ---- SSH 配置(安全模式)----
KNOWN_HOSTS="${HOME}/.ssh/known_hosts"
export GIT_SSH_COMMAND="ssh -i ${MEMORY_BACKUP_KEY} -o IdentitiesOnly=yes -o UserKnownHostsFile=${KNOWN_HOSTS}"
# ---- 确保 git remote 已配置 ----
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
exit 1
fi
# 拒绝目录遍历(防止 ../etc/passwd 这类路径)
if [[ "$INPUT_FILE" == *..* ]]; then
echo "[memory-sync] 拒绝:路径不能包含 .. (目录遍历)"
exit 1
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
exit 1
fi
# 拒绝目录遍历(防止 ../etc/passwd 这类路径)
if [[ "$INPUT_FILE" == *..* ]]; then
echo "[memory-sync] 拒绝:路径不能包含 .. (目录遍历)"
exit 1
Allowing the skill to 'proactively' persist memory after 'important conversations' creates an ambiguous, agent-defined activation boundary for a data-exporting workflow. Because the skill stores conversation data and can push it to Git, vague autonomous triggering materially increases the risk of silent collection, retention, and remote disclosure without informed user approval.
Allowing the skill to 'proactively' persist memory after 'important conversations' creates an ambiguous, agent-defined activation boundary for a data-exporting workflow. Because the skill stores conversation data and can push it to Git, vague autonomous triggering materially increases the risk of silent collection, retention, and remote disclosure without informed user approval.
The document explicitly states that core memory files are automatically backed up to a remote Git repository every day, but it does not require informed user consent, destination transparency, or a warning about privacy consequences. In the context of a memory backup skill that stores conversation-derived notes, this can lead to unintentional exfiltration of personal, project, or sensitive contextual data to external infrastructure.
This guide operationalizes automatic backup of conversation-derived memory files to a remote Git repository, but its warning only mentions API keys and passwords. In this skill's context, the memory store is likely to contain personal data, confidential workflow notes, and cross-channel conversation content, so encouraging routine remote sync without strong data-classification, minimization, or encryption guidance creates a real privacy and data-exfiltration risk.
The cron-based scheduled backup creates persistent, unattended exfiltration of memory contents to a remote repository. In the context of a memory-backup skill, this increases risk because newly stored sensitive conversation content may be pushed automatically without human review, and the log redirection may also leave traces of backup activity or errors on disk.
# 编辑 crontab
crontab -e
# 每天早上 9 点自动备份
0 9 * * * cd /root/.openclaw/workspace && bash scripts/memory-backup.sh >> /root/.openclaw/logs/backup.log 2>&1
The document instructs operators to run destructive rm commands as part of a normal backup workflow, but it lacks explicit safety warnings, path validation steps, or safer alternatives. In an agent skill that may operationalize shell instructions, this creates a realistic risk of accidental data loss if filenames are mistyped, expanded unexpectedly, or applied to the wrong file.
The recovery phrase "从备份继续" is broad and can trigger loading and acting on backed-up workflow content without clear confirmation, scope checks, or exclusions. In a memory/backup skill, that increases the chance of unintended restoration of stale, sensitive, or adversarially planted instructions across conversations and channels.
The header comments, usage text, and operational messages are written only in Chinese, which imposes a specific language/locale on users. Under the policy, locale constraints should either offer user choice or be clearly documented as justified for a region-specific tool, which is not present here.
SQP-3 applies to all file types and includes language or locale policy violations. This setup guide is entirely Chinese and does not indicate that other languages are supported or that Chinese is a justified region-specific requirement, which can be interpreted as forcing a language without user opt-in.
The file is written as an instruction guide entirely in Chinese and provides a fixed Chinese recovery phrase, but it does not indicate that language selection is optional or limited to a China-specific context. This can constitute a locale-policy issue when a skill effectively forces one language without user opt-in.
The script's descriptive comments, usage guidance, environment variable explanations, and later user-facing prompts are written only in Chinese. Under the policy, forcing a specific language without offering a choice or documenting a justified locale constraint is a natural-language policy violation.
The inline documentation at L26 presents /tmp/my-notes.md as an example source file, while the enforced validation at L31-L35 rejects all absolute paths. This is an active contradiction between the script's documented usage and its actual behavior, which can mislead operators about what inputs are permitted.