Secrets in Kubernetes must not be stored as environment variables.
Overview
| Finding ID | Version | Rule ID | IA Controls | Severity |
| V-242415 | CNTR-K8-001160 | SV-242415r1069466_rule | CCI-004062 | high |
| Description | ||||
| Secrets, such as passwords, keys, tokens, and certificates must not be stored as environment variables. These environment variables are accessible inside Kubernetes by the "Get Pod" API call, and by any system, such as CI/CD pipeline, which has access to the definition file of the container. Secrets must be mounted from files or stored within password vaults. | ||||
| STIG | Date | |||
| Kubernetes Security Technical Implementation Guide | 2026-02-12 | |||
Related Frameworks
1 mapping across 4 frameworks
Related Frameworks
SCF0 mappings
No source states a mapping between these directly.
Also reachable in 3 hops (3) derived by us, not asserted by any source
Each of these is a route we composed by chaining published mappings. No publisher states a relationship between the two endpoints.
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- SCF Secure Traceability Relationship Mapping (STRM)2026.2intersects
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- SCF Secure Traceability Relationship Mapping (STRM)2026.2intersects
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- SCF Secure Traceability Relationship Mapping (STRM)2026.2intersects
NIST 800-530 mappings
No source states a mapping between these directly.
Also reachable in 2 hops (58) derived by us, not asserted by any source
Each of these is a route we composed by chaining published mappings. No publisher states a relationship between the two endpoints.
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA STIG Benchmark (XCCDF)V1R1our copyintersects(normalised)
- DISA STIG Benchmark (XCCDF)V1R1intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA STIG Benchmark (XCCDF)V1R1our copyintersects(normalised)
- DISA STIG Benchmark (XCCDF)V1R1intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA STIG Benchmark (XCCDF)2our copyintersects(normalised)
- DISA STIG Benchmark (XCCDF)2intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA STIG Benchmark (XCCDF)2our copyintersects(normalised)
- DISA STIG Benchmark (XCCDF)2intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA STIG Benchmark (XCCDF)2our copyintersects(normalised)
- DISA STIG Benchmark (XCCDF)2intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA STIG Benchmark (XCCDF)2our copyintersects(normalised)
- DISA STIG Benchmark (XCCDF)2intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA STIG Benchmark (XCCDF)2our copyintersects(normalised)
- DISA STIG Benchmark (XCCDF)2intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA STIG Benchmark (XCCDF)2our copyintersects(normalised)
- DISA STIG Benchmark (XCCDF)2intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA STIG Benchmark (XCCDF)2our copyintersects(normalised)
- DISA STIG Benchmark (XCCDF)2intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA STIG Benchmark (XCCDF)V1R1our copyintersects(normalised)
- DISA STIG Benchmark (XCCDF)V1R1intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
+48 more (top 10 by confidence shown)
NIST 800-1710 mappings
No source states a mapping between these directly.
Also reachable in 3 hops (4) derived by us, not asserted by any source
Each of these is a route we composed by chaining published mappings. No publisher states a relationship between the two endpoints.
3.5.10
1.00
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- NIST SP 800-171 Rev 2, Appendix DRev 2 (Feb 2020, errata Jan 2021)equal to(normalised)
3.5.7
1.00
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- NIST SP 800-171 Rev 2, Appendix DRev 2 (Feb 2020, errata Jan 2021)equal to(normalised)
3.5.8
1.00
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- NIST SP 800-171 Rev 2, Appendix DRev 2 (Feb 2020, errata Jan 2021)equal to(normalised)
3.5.9
1.00
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
- DISA CCI List2025-01-23equal to(normalised)
- NIST SP 800-171 Rev 2, Appendix DRev 2 (Feb 2020, errata Jan 2021)equal to(normalised)
CCI1 mapping
CCI-004062
1.00
- DISA STIG Benchmark (XCCDF)V2R6intersects(normalised)
Details
Check Text (C-242415r1069466_chk)
Follow these steps to check, from the Kubernetes control plane, if secrets are stored as environment variables.
1. Find All Pods Using Secrets in Environment Variables.
To list all pods using secrets as environment variables, execute:
kubectl get pods --all-namespaces -o yaml | grep -A5 "secretKeyRef"
If any of the values returned reference environment variables, this is a finding.
2. Check Environment Variables in a Specific Pod.
To check if a specific pod is using secrets as environment variables, execute:
kubectl get pods -n <namespace>
(Replace <namespace> with the actual namespace, or omit -n <namespace> to check in the default namespace.)
kubectl describe pod <pod-name> -n <namespace> | grep -A5 "Environment:"
If secrets are used, output like the following will be displayed:
Environment:
SECRET_USERNAME: <set from secret: my-secret key: username>
SECRET_PASSWORD: <set from secret: my-secret key: password>
If the output is similar to this, the pod is using Kubernetes secrets as environment variables, and this is a finding.
3. Check the Pod YAML for Secret Usage.
To check the full YAML definition for environment variables, execute:
kubectl get pod <pod-name> -n <namespace> -o yaml | grep -A5 "env:"
Example output:
yaml
CopyEdit
env:
- name: SECRET_USERNAME
valueFrom:
secretKeyRef:
name: my-secret
key: username
This means the pod is pulling the secret named my-secret and setting SECRET_USERNAME from its username key.
If the pod is pulling a secret and setting an environment variable in the "env:", this is a finding.
4. Check Secrets in a Deployment, StatefulSet, or DaemonSet.
If the pod is managed by a Deployment, StatefulSet, or DaemonSet, check their configurations:
kubectl get deployment <deployment-name> -n <namespace> -o yaml | grep -A5 "env:"
or
For all Deployments in all namespaces:
kubectl get deployments --all-namespaces -o yaml | grep -A5 "env:"
If the pod is pulling a secret and setting an environment variable in the "env:", this is a finding.
5. Check Environment Variables Inside a Running Pod.
If needed, check the environment variables inside a running pod:
kubectl exec -it <pod-name> -n <namespace> -- env | grep SECRET
If any of the values returned reference environment variables, this is a finding.
Fix Text (F-45648r712600_fix)
Any secrets stored as environment variables must be moved to the secret files with the proper protections and enforcements or placed within a password vault.