T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/backup.py:20
- Finding
- Unencrypted backup archive contains sensitive Agent state<![CDATA[ ## Vulnerability Details **File Location**: `scripts/backup.py:20-30`, `scripts/backup.py:103-123`, and `scripts/backup.py:151-158` **Vulnerability Type**: Plaintext storage of sensitive data **Risk Level**: Medium ### Vulnerable Code ```python REQUIRED_ITEMS = [ "MEMORY.md", "memory", "skills", "SOUL.md", "IDENTITY.md", "USER.md", "AGENTS.md", "TOOLS.md", "HEARTBEAT.md", ] ``` ```python # 添加必选内容 manifest_lines.append("🟢 REQUIRED ITEMS:") for item in REQUIRED_ITEMS: src_path = WORKSPACE / item if src_path.exists(): if src_path.is_file(): files_to_backup.append((src_path, item)) file_hash = get_file_hash(src_path) manifest_lines.append(f" [FILE] {item} ({file_hash[:16]}...)") else: for root, dirs, files in os.walk(src_path): for file in files: file_path = Path(root) / file rel_path = file_path.relative_to(WORKSPACE) files_to_backup.append((file_path, str(rel_path))) manifest_lines.append(f" [DIR] {item}/") else: manifest_lines.append(f" [SKIP] {item} (不存在)") ``` ```python # 创建压缩包 with zipfile.ZipFile(backup_zip, "w", zipfile.ZIP_DEFLATED) as zipf: for src_path, arc_name in files_to_backup: try: zipf.write(src_path, f"{backup_name}/{arc_name}") except Exception as e: print(f"⚠️ 备份失败 {arc_name}: {e}") ``` ### Technical Analysis The required backup set includes long-term memory, user information, identity definitions, tool configuration, installed Skills, and Agent configuration. These files may contain private data, API credentials, operational instructions, or other sensitive state. The files are stored using `zipfile.ZIP_DEFLATED`, which provides compression but no confidentiality. The project documentation explicitly warns that the archive is unencrypted, but the implementation does not offer ...[truncated 1598 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Add authenticated encryption rather than relying on ZIP compression. Use a maintained encryption format or library with modern password-based key derivation and authenticated encryption. 2. Require explicit confirmation before including memory, user identity, tool configuration, or other highly sensitive categories. 3. Provide a secret-exclusion mechanism for known credential files and sensitive patterns. 4. Create the destination file with restrictive permissions, such as owner read/write only, independently of the user's current `umask`. 5. Warn when the output directory is synchronized, shared, or broadly accessible. 6. Avoid placing sensitive archives on the Desktop by default; prefer a dedicated private backup directory. 7. Clearly distinguish the SHA-256 integrity digest from encryption in user-facing output. 8. Consider generating a redacted manifest that does not reveal sensitive file names or metadata unnecessarily. ]]>
