T09 · Insecure Skill Coding Practices
Warning
- Location
- openclaw-backup.sh:26
- Finding
- Sensitive OpenClaw backups are created without enforced access restrictions or encryption<![CDATA[ ## Vulnerability Details **File Location**: `openclaw-backup.sh`, lines 26–44 **Vulnerability Type**: Plaintext storage of sensitive information with insufficiently enforced permissions **Risk Level**: Medium ### Vulnerable Code ```bash cmd_create() { mkdir -p "$BACKUP_DIR" DATE=$(date +%Y-%m-%d_%H%M%S) BACKUP_FILE="$BACKUP_DIR/openclaw-backup-$DATE.tar.gz" cd "$HOME" # Backup workspace and config tar -czf "$BACKUP_FILE" \ --exclude='*.log' \ --exclude='*.tmp' \ --exclude='node_modules' \ --exclude='.git' \ .openclaw/workspace \ .openclaw/openclaw.json \ .openclaw/identity \ .openclaw/agents echo "✅ Backup created: $BACKUP_FILE" ls -lh "$BACKUP_FILE" ``` ### Technical Analysis The backup includes the OpenClaw workspace, configuration, identity, and agent data. These locations may contain private memories, session information, identity material, configuration values, or credentials. The script stores all of this information in an unencrypted gzip-compressed TAR archive. Compression does not provide confidentiality. It also does not establish a restrictive `umask` or explicitly set permissions on either the backup directory or the generated archive. Consequently, resulting permissions depend on the invoking process's environment. With a common `022` umask, the backup directory may be created with mode `755` and the archive with mode `644`, allowing other local users to discover and read the backup. ### Attack Path 1. A user runs `openclaw-backup.sh create`. 2. The script archives sensitive OpenClaw data into `~/openclaw-backups/openclaw-backup-*.tar.gz`. 3. The user's current `umask` permits group or world read access. 4. Another local user, compromised process, or service account reads the archive. 5. The attacker extracts the archive and obtains the contained workspace, configuration, identity, and agent information. ### Impact ...[truncated 551 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Set a restrictive file-creation mask before creating backup artifacts: ```bash umask 077 ``` 2. Create and enforce restrictive directory permissions: ```bash mkdir -p "$BACKUP_DIR" chmod 700 "$BACKUP_DIR" ``` 3. Explicitly restrict the completed archive: ```bash chmod 600 "$BACKUP_FILE" ``` 4. Offer authenticated encryption for backups containing identity, memory, session, or credential data. For example, encrypt the archive using a user-supplied key through an established tool that provides authenticated encryption. 5. Avoid passing encryption secrets directly on command lines, where they can appear in process listings or shell history. Prefer protected key files, file descriptors, or interactive secret input. 6. Document that backup archives contain sensitive data and must not be transferred through untrusted channels without encryption. 7. Consider writing the archive to a securely created temporary file, validating successful completion, applying mode `600`, and then atomically moving it to the final destination. ]]>
