Encryption
How Supascale protects sensitive data with encryption.
Supascale uses industry-standard encryption to protect sensitive data at rest. This guide explains what's encrypted, how encryption works, and best practices for managing encryption keys.
What's Encrypted
Supascale automatically encrypts sensitive data including:
| Data Type | Storage Location | Encryption |
|---|---|---|
| Database passwords | SQLite database | AES-256 |
| OAuth client secrets | SQLite database | AES-256 |
| API key hashes | SQLite database | SHA-256 |
| SSL private keys | File system | AES-256 |
| Cloud storage credentials | SQLite database | AES-256 |
Encryption Algorithm
Supascale uses AES-256 (Advanced Encryption Standard with 256-bit keys) for symmetric encryption. This is the same standard used by:
- US Government for classified information
- Financial institutions
- Major cloud providers
AES-256 is considered secure against brute-force attacks - there are more possible keys than atoms in the observable universe.
Encryption Key
All encryption uses a master key configured via the DB_ENCRYPTION_KEY environment variable.
Key Requirements
- Minimum length: 32 characters
- Recommended: 64 hexadecimal characters (256 bits)
Generating a Key
Generate a secure encryption key using OpenSSL:
openssl rand -hex 32
This produces a 64-character hexadecimal string.
Configuring the Key
Set the encryption key in your .env file:
DB_ENCRYPTION_KEY=your_64_character_hex_key_here
Important: Keep this key secure. If lost, encrypted data cannot be recovered.
How Encryption Works
Encrypting Data
When sensitive data is stored:
- Plain text data is received
- AES-256 encryption is applied using the master key
- Encrypted data is stored in the database
- Original plain text is discarded
Decrypting Data
When encrypted data is accessed:
- Encrypted data is retrieved from storage
- AES-256 decryption is applied using the master key
- Plain text is returned to the application
- Plain text is used only in memory, never persisted
Masking in UI
Even after decryption, sensitive data is masked in the user interface:
- OAuth secrets show only first/last 4 characters:
abc1...xyz9 - API keys are never shown after creation (only hashed)
- Passwords are always masked:
••••••••
SSL Private Key Encryption
SSL private keys receive special handling:
- When a certificate is obtained/uploaded, the private key is encrypted
- Stored as
privkey.pem.encalongside the certificate - Decrypted only when needed for HTTPS configuration
- Original unencrypted key is never stored
Best Practices
Key Management
- Generate a strong key: Use the full 256-bit key space
- Never commit the key: Keep it out of version control
- Limit access: Only administrators should have access to the key
- Backup securely: Store a backup in a secure location (e.g., password manager, hardware security module)
Key Rotation
While Supascale doesn't currently support automatic key rotation, you can manually rotate:
- Export all encrypted data
- Generate a new encryption key
- Update the
DB_ENCRYPTION_KEYenvironment variable - Re-encrypt all data with the new key
Disaster Recovery
- Document the key location: Know where the key is stored
- Test recovery: Verify you can access the key if needed
- Maintain backups: Both encrypted data and the key (separately)
Hashing vs Encryption
Supascale uses both encryption and hashing:
| Method | Reversible | Use Case |
|---|---|---|
| AES-256 Encryption | Yes (with key) | OAuth secrets, passwords, private keys |
| SHA-256 Hashing | No | API keys, password verification |
API keys are hashed rather than encrypted because:
- The original key is shown once at creation
- We only need to verify keys, not retrieve them
- One-way hashing is more secure for authentication tokens
Security Considerations
Defense in Depth
Encryption is one layer of security. Also implement:
- Network security (firewalls, VPNs)
- Access control (authentication, authorization)
- Monitoring (logging, alerting)
- Physical security (server access)
Limitations
Encryption protects data at rest but:
- Data is decrypted in memory when used
- Anyone with the encryption key can decrypt data
- Encryption doesn't prevent authorized misuse