Common Attack Vectors
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.