Pod stores secrets in environment variables Affecting Service service in Kubernetes
Severity Framework
Snyk CCSS
Rule category
Containers / Best Practices
Is your enviroment affected by this misconfiguration?
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applicationsFrameworks
CIS-Kubernetes
- Snyk ID SNYK-CC-00658
- credit Snyk Research Team
Description
Any secrets stored in environment variables could be exposed if the environment is logged or otherwise exposed by an application. Providing access to secrets via volume mounts is preferred.
How to fix?
Ensure spec.containers.env.valueFrom
attribute of pod
doesn't contain secretKeyRef
.
Example Configuration
apiVersion: v1
kind: Pod
metadata:
name: valud-pod
spec:
containers:
- name: mysql
image: mysql:8.0
volumeMounts:
- name: mysql-pass
mountPath: "/etc//mysql/credentials"
volumes:
- name: mysql-pass
secret:
secretName: basic-auth