Common Attack Vectors
| Attack Vector | Description | Mitigation |
|---|---|---|
| etcd Access | Direct reads or writes to etcd can expose Secrets, ConfigMaps, and cluster state. | Enable TLS for etcd, use RBAC for etcd API, rotate encryption keys. |
| Kubelet API | Exposed kubelet endpoints may reveal logs, exec shells, and pod details. | Restrict kubelet API with TLS client certs and network policies. |
| Application Logs | Logs containing passwords, tokens, or PII become high-value targets if compromised. | Redact sensitive fields and centralize logs in an access-controlled store. |
| Persistent Volumes | Mounting volumes in another pod or network-exposed volumes can leak data. | Use volume accessModes, encryption at rest, and Pod Security Policies. |
| Network Shares (NFS) | Unprotected NFS/SMB shares may be read by unauthorized clients. | Enforce mount restrictions, network segmentation, and authentication. |
| Cluster Encryption Keys | If master encryption keys are compromised, all encrypted data at rest becomes accessible. | Rotate keys regularly and store them in Hardware Security Modules. |
Example: Over-Permissive RBAC in a Node.js Backend
Imagine a Node.js service running in thebackend namespace. Its ServiceAccount (backend-sa) has read access to Secrets and ConfigMaps. An attacker who compromises the pod could enumerate sensitive data.
Secret Definition
Misconfigured RBAC
This Role grants broad read access to Secrets and pods:Granting
get/list on Secrets lets any pod with that ServiceAccount access database credentials, API keys, or other secrets.Hardened RBAC
Limit the ServiceAccount to only the resources it truly needs:Always follow the principle of least privilege when defining RBAC rules.
Securing Application Logs
Logging sensitive data can expose credentials, tokens, and PII if logs are compromised.Risky Logging Example
Redacted Logging Example
- Avoid logging credentials, tokens, or other secrets.
- Mask or redact sensitive fields before writing logs.
- Centralize logs in a secure, access-controlled system (e.g., Elasticsearch with RBAC).
- Continuously monitor log access and anomalies.
Encrypting Network Traffic
All inter-service communication should use TLS to prevent packet sniffing and man-in-the-middle attacks.Unencrypted HTTP Example
Encrypted HTTPS Example
Summary & Best Practices
- Apply least-privilege RBAC so pods only have the permissions they require.
- Never log sensitive information; mask or omit secrets in application logs.
- Enforce TLS/mTLS for all inter-service and external communications.
- Rotate encryption keys and Secrets regularly.