Security Architecture
CockroachDB implements a defense-in-depth security model:Transport Encryption
TLS 1.2/1.3 for all inter-node and client communication
Authentication
Certificate-based and password authentication
Authorization
Role-based access control with granular privileges
Encryption at Rest
AES encryption for data stored on disk
Certificate Management
Creating the Certificate Authority (CA)
Establish a certificate authority for your cluster:Creating Node Certificates
Generate certificates for each node in the cluster:Create Node Certificate
Include all hostnames, IP addresses, and DNS names that clients might use to connect to the node.
Creating Client Certificates
Create certificates for database users:Root User Certificate
Application User Certificate
Certificate Distribution
Copy Certificates to Nodes
Each node needs:
ca.crt(CA certificate)node.crt(node certificate)node.key(node private key)
Starting a Secure Cluster
Start Nodes with TLS
Start Secure Node
Omitting
--insecure requires TLS certificates. The cluster will not start without proper certificates.Initialize Secure Cluster
Authentication Methods
Certificate Authentication
Connect using client certificates:SQL Client with Certificate
Application Connection String
Password Authentication
Create users with password authentication:Create User with Password
Change User Password
Connect with Password
Disable Root Password Login
For enhanced security, disable password authentication for the root user:Role-Based Access Control
Creating Roles
Create Custom Role
Granting Privileges
Assigning Users to Roles
Assign Roles to Users
Viewing Privileges
Show User Grants
Revoking Privileges
Revoke Access
Network Security
Firewall Configuration
Configure firewalls to allow only necessary traffic:Required Ports
Required Ports
- 26257: Inter-node and client SQL connections (TCP)
- 8080: Admin UI and HTTP endpoints (TCP)
- 26258: Internal communication (TCP, optional)
- Allow port 26257 from application servers to database nodes
- Allow port 26257 between all database nodes
- Restrict port 8080 to admin networks only
- Block all other inbound traffic
Connection Security
Enforce SSL Connections
Bind Address Configuration
Restrict Listening Address
Use
--listen-addr to bind to specific network interfaces. Never use 0.0.0.0 in production unless behind a firewall.Encryption at Rest
Enable encryption for data stored on disk:Enable Encryption at Rest
Managing Encryption Keys
Audit Logging
Enable audit logging for compliance and security monitoring:Enable Audit Logging
Audit Specific Operations
Viewing Audit Logs
Audit events are logged to the SQL audit log:Security Best Practices
Use Certificate Authentication
Prefer certificate-based authentication over passwords for automated systems and inter-service communication.
Implement Least Privilege
Grant users and applications only the minimum privileges required for their function.
Rotate Certificates Regularly
Establish a certificate rotation schedule (annually or more frequently) and automate the process.
Enable Encryption at Rest
Use encryption at rest for all production clusters, especially those handling sensitive data.
Secure the Admin UI
Restrict Admin UI access to VPN or internal networks and use certificate authentication.
Monitor Authentication Failures
Set up alerts for repeated authentication failures which may indicate attacks.
Certificate Expiration Monitoring
Check Certificate Expiration
Troubleshooting Security Issues
Certificate Errors
Certificate Not Found
Verify file paths and permissions in
--certs-dirCertificate Expired
Generate new certificates and distribute to nodes
Hostname Mismatch
Recreate certificates with correct hostnames/IPs
CA Verification Failed
Ensure all nodes use the same CA certificate
Authentication Failures
Check User Permissions
Verify User Exists
Security Checklist
Production Security Checklist
Production Security Checklist
- TLS enabled for all connections
- Certificate-based authentication configured
- Strong passwords enforced (min 12 characters)
- Root password login disabled
- Principle of least privilege applied to all users
- Firewall rules configured to restrict access
- Encryption at rest enabled
- Audit logging enabled for sensitive tables
- Certificate expiration monitoring in place
- Regular security audits scheduled
- Admin UI access restricted to internal networks
- Backup encryption enabled
- Connection strings secured (no hardcoded passwords)
- Network segregation between tiers
Next Steps
Backup & Restore
Secure your backup strategy
Migration
Securely migrate data
Upgrade
Upgrade with security in mind