T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/backup.py:21
- Finding
- Unencrypted backups expose API credentials and other sensitive agent data<![CDATA[ ## Vulnerability Details **File Location**: `scripts/backup.py:21-29`, `scripts/backup.py:65-82`; documented in `SKILL.md:17-25` **Vulnerability Type**: Plaintext storage of credentials and sensitive information **Risk Level**: High ### Vulnerable Code ```python BACKUP_PATHS = [ # Core configuration ".openclaw/openclaw.json", ".openclaw/.env", ".openclaw/cron/jobs.json", # Credentials ".openclaw/credentials", ".openclaw/identity", ``` ```python with tarfile.open(backup_path, "w:gz") as tar: for rel_path in BACKUP_PATHS: full_path = HOME / rel_path if not full_path.exists(): skipped.append(f" ⚠️ 不存在: {rel_path}") continue if should_exclude(str(full_path)): skipped.append(f" ⏭️ 已排除: {rel_path}") continue tar.add(full_path, arcname=rel_path, filter=lambda ti: None if should_exclude(ti.name) else ti) included.append(f" ✅ {rel_path}") ``` ### Technical Analysis The backup includes `~/.openclaw/.env`, the complete credentials directory, identity material, configuration, memory, and workspace files by default. These files are written to a gzip-compressed tar archive. Gzip compression does not provide confidentiality, integrity protection, or authentication. The script does not encrypt the archive, explicitly set restrictive permissions on the backup directory or archive, or ask the user to opt in before collecting credentials. Resulting permissions depend on the process umask and existing directory permissions. The documentation describes API credentials as required backup content, even though secret restoration should be separable from ordinary configuration and workspace backup. Although a source comment states that credentials are encrypted, this does not establish that every file under the credentials directory is protected, and it does not protect plaintext environment files or other sensitive workspace con ...[truncated 1054 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Exclude `.env` and credential directories from the default backup profile. 2. Require an explicit option such as `--include-secrets` and show a prominent confirmation before collecting credentials. 3. Encrypt secret-bearing backups with authenticated encryption using a user-supplied key or a supported key-management facility. 4. Create `~/backups` with mode `0700` and archives and manifests with mode `0600`, without relying solely on the process umask. 5. Separate workspace/configuration backups from credential exports so users can apply different retention and handling controls. 6. Avoid following symlinks when collecting sensitive paths and verify that every source resolves beneath the intended OpenClaw directory. 7. Document that compressed archives are not encrypted and provide secure storage, transfer, deletion, and key-recovery guidance. ]]>
