T09 · Insecure Skill Coding Practices
- Location
scripts/backup.sh:4- Finding
Sensitive credential backups are created without enforced access controls
- Content
View full analysis
Vulnerability Details
File Location:
scripts/backup.sh, lines 4–11
Vulnerability Type: Sensitive data exposure through insecure file permissions
Risk Level: Highbash BACKUP_DIR="${1:-$HOME/openclaw-backups}" DATE=$(date +%Y-%m-%d_%H%M) BACKUP_FILE="$BACKUP_DIR/openclaw-$DATE.tar.gz" mkdir -p "$BACKUP_DIR" # Create backup (exclude completions cache and logs) tar -czf "$BACKUP_FILE" \ --exclude='completions' \Technical Analysis
The script archives the user's complete
.openclawdirectory. According toSKILL.md, this includes API keys, tokens, authentication profiles, Telegram session data, agent state, user files, and scheduled tasks.Neither the backup directory nor the generated archive is assigned an explicit restrictive permission mode. The script does not set a secure
umask, usemkdirwith mode700, or apply mode600to the archive. Consequently, actual permissions depend on the caller's inherited environment and the permissions of an existing destination directory.If the script runs with a permissive
umask, or if the caller supplies a shared or inadequately protected backup directory, another local user may be able to list or read the unencrypted archive. The archive itself is compressed but not encrypted, so compression provides no confidentiality.Attack Path
- A user or automated task invokes
backup.shunder a permissiveumask, or specifies an inadequately protected shared directory asbackup_dir. - The script creates the directory and archive without enforcing owner-only permissions.
- Another local account discovers the generated
openclaw-*.tar.gzfile. - That account reads and extracts the archive.
- The attacker obtains credentials, API tokens, Telegram session material, configuration, agent state, and user workspace data.
Exploitation requires local access and effective read permission to the generated archive; the script does not ...[truncated 611 chars]
- A user or automated task invokes
- Remediation
View remediation
Remediation Suggestions
- Set
umask 077at the beginning of the script, before creating the destination directory or archive. - Create the destination with
mkdir -p -m 700 -- "$BACKUP_DIR"and explicitly enforcechmod 700 -- "$BACKUP_DIR"when appropriate. - Create the archive with owner-only access and run
chmod 600 -- "$BACKUP_FILE"after successful creation. - Validate that the destination is a directory owned by the current effective user and is not a symbolic link or an unexpectedly shared location.
- Refuse destinations that are group-writable or world-writable unless an explicit secure-use policy supports them.
- Consider authenticated encryption for archives because they contain long-lived credentials and session data. Encryption keys should be stored separately from the backups.
- Write to a securely created temporary file in the destination, verify successful archive creation, apply permissions, and then atomically rename it to the final filename.
- Set
