T09 · Insecure Skill Coding Practices
- Location
scripts/backup.sh:27- Finding
Unvalidated Configurable Paths Enable Privileged Filesystem Traversal and Destructive Operations
- Content
View full analysis
/dev/null # Mount the Samba share echo "Mounting Samba share..." echo "$source_admin_password" | sudo -S mount -t cifs "//$target_server_ip/$target_share_name" "$mount_point" \ -o username="$target_share_username",password="$target_share_password",vers="$mount_vers" ``` ```bash # Create the destination directory TARGET_DIR="$mount_point/$target_folder/$TIMESTAMP" echo "$source_admin_password" | sudo -S mkdir -p "$TARGET_DIR" # Perform the backup echo "Synchronizing files..." echo "$source_admin_password" | sudo -S cp -R "$source_dir/." "$TARGET_DIR/" ``` ```bash BACKUP_BASE="$mount_point/$target_folder" OLD_BACKUPS=$(ls -1r "$BACKUP_BASE" 2>/dev/null | grep -E '^[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}$' | tail -n +$((max_backups + 1))) if [ -n "$OLD_BACKUPS" ]; then for old_backup in $OLD_BACKUPS; do echo "Deleting old backup: $old_backup" echo "$source_admin_password" | sudo -S rm -rf "$BACKUP_BASE/$old_backup" 2>/dev/null || true done else echo "No old backu ...[truncated 2577 chars]- Remediation
View remediation
