HeliosDB Key Management and Migration Guide
HeliosDB Key Management and Migration Guide
Table of Contents
- Overview
- Security Risk: InMemory MEK Provider
- Production-Safe Alternatives
- Migration Paths
- MEK Rotation
- Operational Procedures
- Troubleshooting
Overview
HeliosDB implements a two-tier key hierarchy for Transparent Data Encryption (TDE):
- Master Encryption Key (MEK): Top-level key that encrypts all Table Encryption Keys
- Table Encryption Key (TEK): Per-table keys encrypted with the MEK
This document provides guidance for securely managing MEKs in production environments.
Security Risk: InMemory MEK Provider
Critical Security Issue
The in-memory MEK provider stores Master Encryption Keys in UNPROTECTED MEMORY and is ABSOLUTELY NOT SECURE for production use.
Vulnerabilities
Keys stored in memory are vulnerable to:
- Memory dumps and core files - Keys exposed in crash dumps
- Process memory inspection - Tools like
gdb,gcorecan extract keys - Swap space exposure - Keys may be written to unencrypted swap
- Container/VM snapshots - Memory snapshots capture keys
- Debugger attachment - Attackers can attach debuggers to running process
- Memory forensics - Cold boot attacks, RAM analysis
- Supply chain attacks - Malicious code can read process memory
Production Mode Protection
Starting in HeliosDB v5.0, the in-memory MEK provider is automatically rejected in production mode.
Security Mode Detection
Security mode is determined by:
- Environment variable:
HELIOSDB_SECURITY_MODE=production|development - Build type: Release builds default to
Production, debug builds toDevelopment - Explicit configuration: Set
security_modein the TDE configuration
# Force production mode (recommended for production)export HELIOSDB_SECURITY_MODE=production
# Allow insecure providers (ONLY for development/testing)export HELIOSDB_SECURITY_MODE=developmentProduction-Safe Alternatives
1. HSM (Hardware Security Module) - RECOMMENDED
Security Level: ⭐⭐⭐⭐⭐ (Highest)
Hardware security modules provide the strongest protection for encryption keys.
Advantages
- Hardware-backed key protection - Keys never leave the HSM
- FIPS 140-2 Level 2+ compliance - Meets regulatory requirements
- Tamper resistance - Physical and logical tamper detection
- Cryptographic operations in hardware - No key exposure during encryption
- Audit logging - Complete key usage audit trail
- Key backup and recovery - Secure key backup mechanisms
Supported HSMs
- SoftHSM - Software HSM for testing/development
- Thales Luna - Enterprise HSM
- Utimaco - High-performance HSM
- AWS CloudHSM - Cloud-based HSM
- Azure Dedicated HSM - Azure HSM service
- YubiHSM - Compact USB HSM
Requirements
- PKCS#11 library for your HSM
- Proper HSM initialization and key generation
- Network connectivity (for network HSMs)
Cost
- Hardware: $5,000 - $50,000+ per device
- Cloud HSM: $1.00 - $2.00 per hour
- SoftHSM: Free (testing only)
2. Cloud KMS (Key Management Service)
Security Level: ⭐⭐⭐⭐ (High)
Cloud providers offer managed key management services.
AWS KMS
- Managed service with hardware-backed keys
- Integrated with AWS services
- Automatic key rotation
- CloudTrail audit logging
- Cost: $1/key/month + $0.03 per 10,000 requests
Azure Key Vault
- Hardware-backed or software-backed keys
- FIPS 140-2 Level 2 validated
- Managed HSM option available
- Cost: $0.03 per 10,000 transactions
HashiCorp Vault
- Self-hosted or cloud-hosted
- Multiple backend options (AWS KMS, Azure, GCP)
- Dynamic secrets and encryption as a service
- Cost: Free (OSS) or $0.03 per hour (Enterprise)
3. Secure File Provider
Security Level: ⭐⭐⭐ (Medium)
Encrypted files with OS-level security controls.
Advantages
- No external dependencies
- Simple to deploy
- Works offline
- Low cost
Limitations
- Keys still in filesystem (albeit encrypted)
- Requires secure passphrase management
- Manual key rotation
- No tamper detection
Best Practices
- Use strong passphrases (25+ characters)
- Store passphrase in secure credential manager
- Set file permissions to 600 (owner-only)
- Enable filesystem encryption (LUKS, BitLocker)
- Use dedicated encrypted partition for keys
- Regular backups to secure location
How to Configure
TDE, the key provider (local key store, cloud KMS or HSM over PKCS#11), and the “Configure HeliosDB” and “Generate MEK” steps of the migration paths are not set through a public configuration file or environment variables. Configuration for this feature is provided during onboarding — contact support@heliosdb.com (or sales@heliosdb.com if you are not yet a customer).
The heliosdb.toml file of the HeliosDB Full server accepts only the documented storage keys (storage.data_dir, storage.memtable_size_mb, storage.compaction_strategy, storage.read_cache_mb and the storage.prefetch_* settings). The server refuses to start if the file contains any other key.
Migration Paths
Migration 1: InMemory → Secure File Provider
Complexity: ⭐ (Easy) Downtime: None Cost: Free
Steps
- Generate MEK passphrase
# Generate strong passphraseopenssl rand -base64 32 > /secure/location/mek-passphrase.txtchmod 600 /secure/location/mek-passphrase.txt
# Set environment variableexport HELIOSDB_MEK_PASSPHRASE=$(cat /secure/location/mek-passphrase.txt)-
Update configuration
-
Generate new MEK
-
Re-encrypt all TEKs (if migrating existing data)
-
Verify
# Check MEK file exists with correct permissionsls -la /var/lib/heliosdb/mek/# Should show: -rw------- (600) for .mek files
# Test encryption/decryption# (Run integration tests)Migration 2: InMemory → Cloud KMS (AWS KMS)
Complexity: ⭐⭐ (Medium) Downtime: None Cost: ~$1/month + API costs
Prerequisites
- AWS account with KMS access
- IAM role with KMS permissions
- AWS credentials configured
Steps
- Create KMS key
aws kms create-key \ --description "HeliosDB Master Encryption Key" \ --key-usage ENCRYPT_DECRYPT \ --origin AWS_KMS
# Output: KeyId (e.g., arn:aws:kms:us-east-1:123456789:key/abc-def-123)-
Configure HeliosDB
-
Deploy and verify
Migration 3: InMemory → HSM (PKCS#11)
Complexity: ⭐⭐⭐⭐ (Hard) Downtime: Minimal Cost: $5,000+ (hardware) or $1-2/hour (cloud)
Prerequisites
- HSM hardware or SoftHSM for testing
- PKCS#11 library installed
- HSM initialized with security officer PIN
- Slot created and initialized
Steps
- Initialize HSM (example with SoftHSM)
# Install SoftHSMapt-get install softhsm2
# Initialize tokensofthsm2-util --init-token --slot 0 --label "heliosdb" \ --so-pin 123456 --pin 654321-
Configure HeliosDB
-
Generate MEK in HSM
MEK Rotation
Why Rotate MEKs?
- Compliance requirements - Many regulations require periodic key rotation
- Cryptographic best practices - Limit key exposure over time
- Compromise mitigation - Reduce impact of potential key disclosure
- Personnel changes - Rotate after employee departures
Rotation Frequency
- High security: Every 90 days
- Medium security: Every 180 days
- Minimum: Annually
Dual-Encryption Period
During MEK rotation, HeliosDB maintains both old and new MEK versions:
- Day 0: Generate new MEK, re-encrypt all TEKs
- Day 0-30: Both MEKs valid, gradual re-encryption
- Day 30: Verify all TEKs use new MEK
- Day 31: Deactivate old MEK
This allows zero-downtime rotation and rollback capability.
Operational Procedures
Daily Operations
# Check security modeheliosdb-cli security status
# Verify MEK provider typeheliosdb-cli security mek-info
# Monitor key usageheliosdb-cli security key-statsEmergency Procedures
MEK Compromise
If you suspect MEK compromise:
- Immediately rotate MEK
- Generate new TEKs for all tables
- Re-encrypt all data (gradual or immediate based on risk)
- Review audit logs for unauthorized access
- Investigate root cause
Lost MEK
If MEK is lost (no backup):
- All encrypted data is PERMANENTLY LOST
- Restore from backup if available
- Rebuild database from application data sources
- Implement proper backup procedures (see below)
Backup and Recovery
MEK Backup (Secure File Provider)
# Backup MEK files (encrypted)tar -czf mek-backup-$(date +%Y%m%d).tar.gz /var/lib/heliosdb/mek/
# Store in secure location (separate from database backups)aws s3 cp mek-backup-*.tar.gz s3://secure-backup-bucket/mek/ --sse AES256
# Store passphrase separately (use password manager or secret store)MEK Recovery
# Restore MEK filesaws s3 cp s3://secure-backup-bucket/mek/mek-backup-20241025.tar.gz .tar -xzf mek-backup-20241025.tar.gz -C /
# Set passphraseexport HELIOSDB_MEK_PASSPHRASE=$(cat /secure/location/mek-passphrase.txt)
# Restart HeliosDBsystemctl restart heliosdbTroubleshooting
Error: “Insecure MEK provider in production”
Production mode requires a secure MEK provider. Current provider: In-Memory (INSECURE - testing only) is NOT suitable for production.Solution: Configure a production-safe MEK provider (HSM, Cloud KMS, or Secure File).
Temporary workaround (NOT RECOMMENDED):
export HELIOSDB_SECURITY_MODE=developmentError: “Passphrase environment variable not found”
MEK provider error: Passphrase environment variable HELIOSDB_MEK_PASSPHRASE not foundSolution: Set the required environment variable:
export HELIOSDB_MEK_PASSPHRASE="your-strong-passphrase"Error: “Permission denied” on MEK files
IO error: Permission denied (os error 13)Solution: Fix file permissions:
chmod 700 /var/lib/heliosdb/mekchmod 600 /var/lib/heliosdb/mek/*.mekchown heliosdb:heliosdb /var/lib/heliosdb/mek -RError: HSM “CKR_PIN_INCORRECT”
HSM error: CKR_PIN_INCORRECTSolution: Verify HSM PIN is correct and not locked:
# Check token statussofthsm2-util --show-slots
# If locked, reinitialize (WARNING: destroys keys)softhsm2-util --init-token --slot 0 --label "heliosdb"Performance: Slow key operations
If key operations are slow:
- Increase key cache size in the TDE configuration
- Use local HSM instead of network HSM
- Batch key operations where possible
- Monitor HSM latency and network connectivity
Security Checklist
- In-memory MEK provider disabled in production
- Production MEK provider configured (HSM, Cloud KMS, or Secure File)
- MEK passphrase stored securely (not in code or config files)
- File permissions set correctly (600 for MEK files, 700 for directories)
- MEK backup procedure established
- MEK rotation schedule defined
- Audit logging enabled
- Access controls configured (only authorized personnel)
- Incident response plan documented
- Regular security audits scheduled
References
- NIST SP 800-57: Key Management
- OWASP Key Management Cheat Sheet
- PCI DSS Key Management Requirements
- FIPS 140-2 Security Requirements
Support
For security-related questions or incident response:
- Security Team: security@heliosdb.com