Pod stores secrets in environment variables Affecting Service service in Kubernetes


Severity

0.0
medium
0
10
Severity Framework
Snyk CCSS
Rule category
Containers/ Best Practices

Is your environment 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 applications
Frameworks
CIS-Kubernetes
  • Snyk IDSNYK-CC-00658
  • creditSnyk 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

Kubernetes