Encryption Architecture
Zero-Knowledge Design
Bitwarden’s security model ensures:- Client-side encryption: All encryption/decryption happens on the client
- Server-blind storage: Server stores only encrypted data
- Master password never transmitted: Used only locally to derive encryption keys
- Account recovery requires user action: Server cannot decrypt user data
Encryption Types
Bitwarden supports multiple encryption schemes: Implementation:src/Core/Utilities/EncryptedStringAttribute.cs:14
Encrypted String Format
Structure:2= Encryption type (AesCbc128_HmacSha256_B64)abc123= Base64-encoded IVdef456= Base64-encoded ciphertextghi789= Base64-encoded MAC
src/Core/Utilities/EncryptedStringAttribute.cs:60
User Encryption Keys
Account Encryption Versions
Bitwarden supports two account encryption schemes:V1 Encryption (Legacy)
Key Derivation:- Master Password → PBKDF2 → Master Key
- Master Key → HKDF → Encryption Key + MAC Key
- Master Key → PBKDF2 → Master Password Hash (for authentication)
- Encrypted symmetric key
- Public encryption key (RSA 2048-bit)
- Private encryption key (encrypted with symmetric key)
V2 Encryption (Current)
Enhanced Features:- Separate signature keys (Ed25519 or RSA 2048-bit)
- Improved key derivation
- Support for trusted device encryption
- Account recovery capabilities
src/Core/KeyManagement/Models/Data/UserAccountKeysData.cs
Key Rotation
Bitwarden supports cryptographic key rotation: When to Rotate:- Master password change
- Suspected key compromise
- Compliance requirements
- Migration to V2 encryption
1
Generate New Keys
Create new user key and asymmetric key pairs:
2
Re-encrypt Vault Data
Re-encrypt all ciphers, folders, and sends with new key:
3
Update Shares and Emergency Access
Re-encrypt shared items and emergency access keys:
4
Atomic Update
Update all keys in a single transaction to maintain consistency.
src/Core/KeyManagement/Kdf/Implementations/ChangeKdfCommand.cs
Organization Encryption
Organization Keys
Key Structure:- Organization key encrypted with each user’s public key
- User decrypts org key with their private key
- User uses org key to decrypt organization items
Collection Encryption
Collections use the organization key:- Collection membership determines access
- Encryption key shared via organization membership
- Permissions enforced server-side
- Data remains encrypted at rest
Data Protection Keys
ASP.NET Core Data Protection
Bitwarden uses Data Protection for server-side sensitive data: Configuration:src/Core/Settings/GlobalSettings.cs:548
Protected Data Types
Server-side protection for:- Temporary tokens (email verification, password reset)
- Session state
- Anti-forgery tokens
- Organization sponsorship offers
- Provider user invitations
- Emergency access invitations
src/Core/Tokens/DataProtectorTokenFactory.cs
Data Protection Purposes
Purpose Strings:Certificate Management
Identity Server Certificates
Signing Certificates:- RSA 2048-bit or higher
- Valid for signing operations
- Stored securely with restricted permissions
Data Protection Certificates
Configuration:Certificate Storage
Secure Storage:Encryption at Rest
Database Encryption
SQL Server Transparent Data Encryption (TDE):1
Create Master Key
2
Create Certificate
3
Create Database Encryption Key
4
Enable TDE
5
Backup Certificate
File Storage Encryption
Local Storage:- Storage Service Encryption (SSE)
- Customer-managed keys (CMK) in Azure Key Vault
- Private endpoints for secure access
Encryption Best Practices
Key Management
Key Generation
- Use cryptographically secure random number generators
- Generate keys with appropriate length (AES-256, RSA-2048+)
- Never reuse keys across different purposes
Key Storage
- Store keys encrypted when at rest
- Use hardware security modules (HSM) for production
- Implement key rotation policies
- Backup encryption keys securely
Key Distribution
- Use asymmetric encryption for key exchange
- Validate recipient identity before sharing
- Implement secure channel for key transmission
- Audit all key access and distribution
Key Destruction
- Securely delete keys when no longer needed
- Use cryptographic erasure techniques
- Maintain key destruction audit trail
- Verify data encrypted with key is also destroyed
Cryptographic Operations
Do’s:- Use authenticated encryption (AES-GCM, AES-CBC + HMAC)
- Generate unique IVs for each encryption operation
- Use constant-time comparison for MACs
- Implement proper error handling without leaking information
- Never roll your own crypto
- Don’t use ECB mode
- Don’t reuse IVs with the same key
- Don’t use MD5 or SHA-1 for security purposes
- Don’t store passwords in reversible encryption
Algorithm Selection
Recommended:Troubleshooting Encryption Issues
Invalid Encryption String
Error:Invalid encryption string format
Causes:
- Corrupted database data
- Incomplete migration
- Incorrect encryption type
Key Mismatch Errors
Symptoms:- Cannot decrypt vault items
- “Invalid key” errors
- Items appear empty
- Verify user has correct encryption key
- Check for key rotation issues
- Validate organization membership
- Restore from backup if corruption detected
Certificate Issues
Error:Certificate not found or Invalid certificate
Troubleshooting:
Migration to V2 Encryption
Migration Process
For users still on V1 encryption:1
Check Current Version
2
Initiate Migration
User must log in to web vault and complete migration flow:
- Verify master password
- Generate new V2 keys
- Re-encrypt vault data
3
Verify Migration