T09 · Insecure Skill Coding Practices
- Location
scripts/backup.sh:5- Finding
Plaintext Backups of Sensitive Agent State Lack Enforced Access Controls
- Content
View full analysis
Vulnerability Details
File Location:
scripts/backup.sh, lines 5-27
Vulnerability Type: Plaintext sensitive-data exposure through insufficient filesystem permission enforcement
Risk Level: MediumVulnerable Code
bash BACKUP_DIR="$HOME/.openclaw/workspace/backups" DATE=$(date +%Y-%m-%d_%H%M%S) BACKUP_NAME="backup_$DATE" # 需要备份的关键文件 FILES=( "$HOME/.openclaw/workspace/IDENTITY.md" "$HOME/.openclaw/workspace/USER.md" "$HOME/.openclaw/workspace/MEMORY.md" "$HOME/.openclaw/workspace/SOUL.md" "$HOME/.openclaw/workspace/TOOLS.md" "$HOME/.openclaw/openclaw.json" "$HOME/.openclaw/workspace/memory/" ) mkdir -p "$BACKUP_DIR/$BACKUP_NAME" echo "🛡️ OpenClaw 备份中..." echo "=====================" for file in "${FILES[@]}"; do if [ -e "$file" ]; then cp -r "$file" "$BACKUP_DIR/$BACKUP_NAME/" echo "✓ 备份: $file" fi doneTechnical Analysis
The script copies identity information, user data, persistent memory, behavioral instructions, tool definitions, and the OpenClaw configuration into a plaintext backup tree. It does not establish a restrictive
umask, explicitly set directory or file permissions, validate ownership, or encrypt the resulting backup.Consequently, the effective permissions depend on the caller's environment, existing parent-directory permissions, source permissions, and platform-specific
cpbehavior. Under a permissive configuration, other local users or processes may be able to inspect the duplicated data. The backup operation also increases the number of locations from which potentially sensitive configuration and Agent state can be recovered.No remote transfer or deliberate data exfiltration was found. Exploitation requires filesystem access to the backup directory, directly or through another compromised local process.
Attack Path
- The user invokes
scripts/backup.shin an environment with ...[truncated 1016 chars]
- The user invokes
- Remediation
View remediation
Remediation Suggestions
- Set
umask 077at the beginning of the script before creating any backup content. - Create the backup root and each backup directory with explicit mode
0700. - Set copied regular files to mode
0600and directories to mode0700. - Verify that the backup directory is owned by the current user and refuse to proceed if ownership or permissions are unsafe.
- Avoid following symbolic links when collecting sensitive files, and verify source paths before copying.
- Consider encrypting backups at rest with an authenticated encryption mechanism and securely managing the encryption key.
- Check every
mkdir,cp, and permission-setting operation for failure and terminate safely if any operation fails. - Document retention and secure deletion procedures to prevent unnecessary accumulation of historical sensitive data.
- Set
