T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/cashu/backup.sh:63
- Finding
- Unencrypted Cashu Wallet Backup Uploaded to IPFS<![CDATA[ ## Vulnerability Details **File Location**: `scripts/cashu/backup.sh`, lines 63-99 **Vulnerability Type**: Plaintext exposure of sensitive wallet data **Risk Level**: Critical ### Vulnerable Code ```bash # Step 1: Export wallet data # Copy wallet database if [ -d "$CASHU_WALLET_DIR" ]; then cp -r "$CASHU_WALLET_DIR" "$BACKUP_DIR/cashu-wallet" else echo "⚠️ No wallet directory at $CASHU_WALLET_DIR" rm -rf "$BACKUP_DIR" exit 1 fi # Step 2: Record balance for verification BALANCE=$($CASHU_BIN balance 2>&1 || echo "unknown") echo "$BALANCE" > "$BACKUP_DIR/balance.txt" # Step 3: Record metadata cat > "$BACKUP_DIR/metadata.json" << EOF { "timestamp": "$TIMESTAMP", "date": "$(date -Iseconds)", "balance": "$BALANCE", "mint": "$CASHU_MINT_URL", "wallet_dir": "$CASHU_WALLET_DIR", "hostname": "$(hostname)", "sha256": "$(find "$BACKUP_DIR/cashu-wallet" -type f -exec sha256sum {} \; | sha256sum | cut -d' ' -f1)" } EOF # Step 4: Create tarball TARBALL="/tmp/cashu-backup-${TIMESTAMP}.tar.gz" tar -czf "$TARBALL" -C "$BACKUP_DIR" . # Step 5: Upload to IPFS and store CID in vault echo "🔐 Uploading encrypted backup to IPFS..." # Add to IPFS IPFS_RESULT=$(curl -s -X POST "http://localhost:5001/api/v0/add" \ -F "file=@${TARBALL}" 2>/dev/null) ``` ### Technical Analysis The script copies the complete Cashu wallet directory and creates a gzip-compressed tar archive. Compression does not provide confidentiality, and no encryption command or authenticated-encryption operation occurs before the archive is submitted to the local IPFS API. The comment at line 3 and the status message at line 95 describe the backup as encrypted, but the implementation uploads plaintext wallet contents inside a compressed archive. This misleading security claim can cause users to upload sensitive wallet material under the false assumption that it is cryptographically protected. IPFS is content-addressed and designed for distribution and r ...[truncated 1403 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Encrypt the archive locally before making any IPFS request. Use authenticated encryption, such as age, a properly configured OpenPGP implementation, or AES-GCM through a reviewed library. 2. Store the encryption key outside the archive and outside the public CID metadata. Prefer a recipient public key or a hardware-backed secret. 3. Verify that the output is an encrypted container before upload and fail closed if encryption fails. 4. Never upload the plaintext archive, even temporarily. 5. Replace the misleading “encrypted backup” message with an accurate status message and document IPFS replication and retention risks. 6. Require explicit user confirmation before the first remote or distributed backup unless a separately reviewed noninteractive policy has been configured. 7. Consider limiting the backup to the minimum files required for recovery rather than copying the complete wallet directory. 8. Implement and test a restore workflow that validates authenticity and integrity before extracting wallet data. ]]>
