Impact & Risk Analysis
- Severity: Medium (Level 2 - Defense in Depth)
- CIS Benchmark: CIS 5.4.1
- Impact: Data Leakage via Logs. It is very common for application frameworks to log their entire environment context when they crash or encounter an unhandled exception. If secrets are stored as environment variables, they will be printed in cleartext to the application logs (and subsequently shipped to your logging aggregation system like Splunk or Elasticsearch), making them visible to anyone with log read access.
Common Misconfiguration
Usingenv with valueFrom and secretKeyRef. This is the easiest way to inject configuration, so developers default to it, ignoring the risk of crash dump leakage.
Vulnerable Example
Secure Example
/etc/secrets/password instead of reading os.environ['DB_PASSWORD'].
Audit Procedure
Run the following command to find any workloads that inject secrets into environment variables:- Result: A list of Deployments, StatefulSets, or DaemonSets.
- Analyze: Any item in this list is using
secretKeyRefin anenvblock and is potentially vulnerable to log leakage.
Remediation
- Refactor Code: Modify your application to read secrets from the filesystem (e.g.,
/etc/secrets/) rather than environment variables. - Update Manifests: Change your Deployment YAML to use
volumesandvolumeMountsinstead ofenv.

