Security Overview
CockroachDB provides multiple layers of security:- Authentication: Verify identity of users and nodes
- Encryption: Protect data in transit and at rest
- Authorization: Control access to database objects
- Network Security: Restrict network access to the cluster
- Auditing: Track database operations for compliance
Authentication
TLS Certificates for Node Communication
Secure inter-node communication with TLS 1.3:Create CA certificate
Store the CA key (
ca.key) in a secure location, separate from the certificates directory. You’ll need it to create additional certificates.Create node certificates
- Node’s hostname and IP address
- Any DNS names or wildcards used to access the node
localhostif connecting locally
SQL User Authentication
Password authentication (SCRAM-SHA-256)
Password authentication (SCRAM-SHA-256)
CockroachDB uses SCRAM-SHA-256 for secure password authentication:Password requirements:
- Enforce strong passwords in your application
- Rotate passwords regularly
- Store passwords securely (never in source code)
- Use password managers for credential management
Certificate authentication
Certificate authentication
Use client certificates for authentication:Benefits:
- No passwords to manage
- Strong cryptographic authentication
- Suitable for service accounts and automation
Single Sign-On (SSO)
Single Sign-On (SSO)
Integrate with enterprise identity providers:Supported protocols:
- OpenID Connect (OIDC)
- GSSAPI with Kerberos (Enterprise)
- SAML (via third-party proxy)
Encryption
Encryption in Transit
All network communication should use TLS:Enable TLS for all connections
Enable TLS for all connections
disable: No encryption (insecure, dev only)allow: Opportunistic encryption (insecure)prefer: Use encryption if available (insecure)require: Require encryption (secure)verify-ca: Require encryption and verify CA (more secure)verify-full: Require encryption and verify hostname (most secure)
Encryption at Rest
Infrastructure-level encryption
Infrastructure-level encryption
All major cloud providers offer encryption at rest:
- AWS: Amazon EBS encryption with KMS
- GCP: Persistent disk encryption with Cloud KMS
- Azure: Managed disk encryption with Key Vault
CockroachDB Enterprise Encryption at Rest
CockroachDB Enterprise Encryption at Rest
CockroachDB Enterprise provides application-level encryption:Features:
- AES-128, AES-192, or AES-256 encryption
- Key rotation support
- Per-store encryption keys
- Integration with key management systems
Authorization
Role-Based Access Control (RBAC)
Default Privileges
Set privileges automatically for new objects:Network Security
IP Allowlisting
Configure host-based authentication
Configure host-based authentication
Restrict connections by IP address:HBA rules:
- Rules are evaluated in order (first match wins)
- Use
cert-passwordfor certificate or password auth - Use
certfor certificate-only auth - Use
passwordfor password-only auth - Use
rejectto explicitly deny
Firewall Configuration
Restrict network access at the infrastructure level:26257: SQL and inter-node (PostgreSQL wire protocol)8080: DB Console HTTP interface26258: Node status and metrics
Private Network Connectivity
VPC Peering
VPC Peering
Connect application VPC to database VPC:
AWS PrivateLink / GCP Private Service Connect
AWS PrivateLink / GCP Private Service Connect
Private connectivity without VPC peering:
- AWS PrivateLink: Expose CockroachDB through VPC endpoint
- GCP Private Service Connect: Connect via private service connection
- Azure Private Link: Use private endpoints
- No IP conflicts between VPCs
- Simplified network management
- Enhanced security
Audit Logging
Track database operations for compliance and security:Audit Log Configuration
- All SQL statements affecting audited tables
- User who executed the statement
- Timestamp of execution
- Source IP address
- Application name
Security Best Practices
Deployment security
Deployment security
- Always use TLS in production (never
--insecure) - Store CA keys offline, separate from certificates
- Use separate certificates for each node (not wildcard)
- Rotate certificates before expiration (monitor with
cockroach cert list) - Enable certificate revocation checking (OCSP)
Access control
Access control
- Implement role-based access control (RBAC)
- Use principle of least privilege
- Create service accounts with minimal permissions
- Disable the
rootuser for regular operations - Require MFA for admin access to DB Console
- Regularly audit user permissions and remove unused accounts
Network security
Network security
- Use private networks for database nodes
- Restrict DB Console access to admin networks
- Implement IP allowlisting via HBA or firewall
- Use VPC peering or PrivateLink for application connectivity
- Enable DDoS protection at infrastructure layer
- Monitor unusual network traffic patterns
Data protection
Data protection
- Enable encryption at rest (infrastructure or Enterprise)
- Use encrypted backups for sensitive data
- Implement data masking for non-production environments
- Set up automated backup testing and validation
- Store backups in separate regions/accounts
- Enable object locking on backup storage
Monitoring and response
Monitoring and response
- Enable SQL audit logging for sensitive tables
- Monitor failed authentication attempts
- Set up alerts for security events
- Implement log aggregation and SIEM integration
- Conduct regular security assessments
- Maintain incident response procedures
- Test disaster recovery regularly
Compliance Considerations
GDPR / Data Privacy
GDPR / Data Privacy
- Use row-level TTL for data retention policies
- Implement data masking for PII
- Enable audit logging for access to personal data
- Use geo-partitioning for data residency
- Document data processing activities
SOC 2 / ISO 27001
SOC 2 / ISO 27001
- Enable comprehensive audit logging
- Implement least privilege access
- Encrypt data in transit and at rest
- Regular security assessments and penetration testing
- Maintain security policies and procedures
PCI DSS (for payment data)
PCI DSS (for payment data)
- Use strong encryption (TLS 1.2+, AES-256)
- Implement network segmentation
- Enable audit logging for all data access
- Regular vulnerability scanning
- Restrict access to cardholder data
- Use tokenization when possible