Security Overview
Uncloud’s security is built on several layers:- Network encryption: WireGuard encrypts all cluster communication
- SSH authentication: Machine access controlled through SSH keys
- TLS certificates: Automatic HTTPS for public-facing services
- Container isolation: Docker provides process and namespace isolation
- Firewall protection: Automatic iptables rules limit attack surface
WireGuard Encryption
All traffic between machines flows through WireGuard, which provides strong cryptographic protection.Encryption Primitives
WireGuard uses modern, peer-reviewed cryptography:- Data encryption: ChaCha20 stream cipher
- Authentication: Poly1305 MAC
- Key exchange: Curve25519 elliptic curve Diffie-Hellman
- Handshake: Noise protocol framework
- Hashing: BLAKE2s
What WireGuard Protects
WireGuard encrypts:- Container-to-container traffic across machines
- Machine-to-machine API calls (Uncloud daemon gRPC)
- State synchronization (Corrosion gossip)
- Image transfers (Unregistry communication)
Key Management
WireGuard keys are generated automatically when machines join the cluster:- Key generation: Each machine generates a random 32-byte private key
- Public key derivation: Public key is derived from private key
- Key distribution: Public keys are distributed via Corrosion state
- Automatic configuration: Keys are configured in WireGuard without manual intervention
Key Storage
Private keys are stored in the machine state file:Rotating WireGuard Keys
Currently, Uncloud doesn’t support automatic key rotation. The WireGuard private key is generated once when the machine joins the cluster and remains constant. To rotate keys manually:- Remove the machine from the cluster:
uc machine rm <name> - Reinitialize or add the machine:
uc machine add user@host - This generates a new key pair and updates all peers
Key rotation will cause brief connectivity disruption as peers update their configurations.
SSH Authentication
SSH is the primary authentication mechanism for accessing machines and managing the cluster.SSH Key Requirements
Uncloud requires SSH key-based authentication. Password authentication is not supported. When initializing a machine:Supported Key Types
Uncloud supports all SSH key types:- Ed25519 (recommended): Modern, secure, fast
- RSA 2048+: Widely compatible, requires minimum 2048-bit key
- ECDSA: Supported but Ed25519 is preferred
SSH Key Distribution
When initializing a cluster, Uncloud:- Uses your SSH key to connect to the machine
- Installs the Uncloud daemon
- Creates a non-root
unclouduser (if not root) - Adds your SSH public key to authorized_keys
Multi-User Access
To grant cluster access to multiple users:SSH Security Best Practices
- Use Ed25519 keys: Stronger and faster than RSA
- Protect private keys: Use passphrase-protected keys
- Use SSH agent: Avoid typing passphrases repeatedly
- Disable password auth: Ensure
/etc/ssh/sshd_confighasPasswordAuthentication no - Limit SSH access: Use firewall rules to restrict SSH to known IPs
- Rotate keys periodically: Generate new SSH keys and update authorized_keys
TLS Certificates
Caddy automatically obtains and renews TLS certificates for HTTPS endpoints.Automatic HTTPS
When you publish a service with a domain:- Receives the request for
app.example.com - Checks if it has a valid certificate
- If not, requests one from Let’s Encrypt using ACME HTTP-01 challenge
- Stores the certificate locally
- Serves HTTPS traffic with the certificate
Certificate Storage
Caddy stores certificates in:Certificate Challenges
Caddy supports multiple ACME challenge types:- HTTP-01 (default): Requires port 80 to be accessible
- TLS-ALPN-01: Uses port 443
- DNS-01: Requires DNS provider API access (for wildcards)
Custom Certificates
To use your own certificates instead of Let’s Encrypt:compose.yaml
TLS Best Practices
- Use strong ciphers: Caddy defaults to secure TLS 1.2+ ciphersuites
- Enable HSTS: Configure Caddy to send
Strict-Transport-Securityheaders - Monitor certificate expiration: Set up alerts for certificate renewal failures
- Use certificate transparency: Let’s Encrypt certificates are automatically logged
Container Isolation
Docker provides multiple layers of isolation between containers and the host system.Process Isolation
Each container runs in its own set of Linux namespaces:- PID namespace: Container processes can’t see host processes
- Network namespace: Separate network stack per container
- Mount namespace: Isolated filesystem view
- UTS namespace: Separate hostname
- IPC namespace: Isolated inter-process communication
Resource Limits
Set resource limits to prevent containers from consuming excessive resources:compose.yaml
Security Profiles
Docker uses security profiles to restrict container capabilities:- AppArmor (Ubuntu/Debian): Confines containers with mandatory access control
- SELinux (RHEL/CentOS): Enforces security policies
- Seccomp: Filters system calls available to containers
User Namespaces
For enhanced isolation, enable user namespaces to remap container UIDs:Read-Only Root Filesystem
Run containers with read-only root filesystems when possible:compose.yaml
Network Security
Firewall Rules
Uncloud automatically configures iptables rules to:- Accept WireGuard traffic: Allow UDP port 51820 from anywhere
- Accept Unregistry traffic: Allow TCP port 5000 from cluster machines
- Accept cluster traffic: Allow traffic from WireGuard mesh network
- Drop other traffic: Default deny for other incoming connections
Port Exposure
By default, containers don’t expose ports to the public internet. You must explicitly publish them:compose.yaml
Network Segmentation
For additional security, segment services using Docker networks:compose.yaml
web can’t directly access database.
Restricting Outbound Traffic
To prevent data exfiltration, restrict outbound connections:Best Practices for Production
1. Minimize Attack Surface
- Run only necessary services
- Disable unused features (for example, SSH password auth)
- Keep software updated (OS, Docker, Uncloud)
- Remove default accounts and weak credentials
2. Use Strong Authentication
- Use Ed25519 SSH keys
- Protect private keys with passphrases
- Rotate SSH keys periodically
- Use multi-factor authentication for SSH (for example, Google Authenticator)
3. Enable Logging and Monitoring
- Monitor for failed authentication attempts
- Alert on suspicious activity (unusual process, network connections)
- Retain logs for forensic analysis
4. Secure Container Images
- Scan images for vulnerabilities (for example,
docker scan, Trivy) - Use minimal base images (Alpine, distroless)
- Don’t include secrets in images
- Regularly update base images
- Sign images for integrity verification
5. Implement Defense in Depth
- Network segmentation (Docker networks)
- Resource limits (CPU, memory)
- Read-only filesystems where possible
- Principle of least privilege
- Regular security audits
6. Protect Sensitive Data
compose.yaml
- Use Docker secrets for sensitive configuration
- Encrypt data at rest (for example, encrypted volumes)
- Use TLS for all external communication
- Rotate secrets regularly
7. Plan for Incident Response
- Document incident response procedures
- Practice disaster recovery scenarios
- Maintain backups of critical data
- Have a process for patching vulnerabilities quickly
8. Network Isolation
For highly sensitive environments:- Run Uncloud cluster on a private network
- Use VPN or bastion hosts for SSH access
- Implement network policies to restrict traffic
- Use dedicated security machines as entry points
9. Regular Security Audits
10. Keep Uncloud Updated
Uncloud receives security updates and bug fixes:Security Limitations
What Uncloud Protects Against
- External attackers intercepting cluster traffic
- Unauthorized access to machines (via SSH)
- Man-in-the-middle attacks on cluster communication
- Container breakout (via Docker isolation)
What Uncloud Doesn’t Protect Against
- Malicious cluster administrators with SSH access
- Compromised SSH keys
- Vulnerabilities in container applications
- Social engineering attacks
- Physical access to machines
Compliance Considerations
If you’re subject to compliance requirements (GDPR, HIPAA, PCI-DSS):- Data encryption: WireGuard provides encryption in transit; use encrypted volumes for data at rest
- Access control: Implement strict SSH key management and logging
- Audit trails: Enable comprehensive logging and retain for required periods
- Data residency: Deploy machines in compliant regions
- Vulnerability management: Establish patching procedures and scan images regularly
Reporting Security Issues
If you discover a security vulnerability in Uncloud:- Do not open a public GitHub issue
- Email security details to the maintainer (check GitHub profile)
- Include steps to reproduce and potential impact
- Allow time for a fix before public disclosure
