Secrets in Plain Environment Variables or ConfigMaps
Credentials are placed in plain environment variables or ConfigMaps instead of being handled as secrets, so anyone who can read workload definitions can read them.
| Severity | Medium |
| CVSS 3.1 | 6.5 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N Open in the calculator |
| CVSS 4.0 | 7.1 CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-312: Cleartext Storage of Sensitive Information |
| OWASP Top 10 | A06:2025 Insecure Design |
| MITRE ATT&CK | T1552.007 Container API |
| Category | Information Disclosure |
Description
Workloads receive credentials, such as database passwords, API keys and tokens, as literal values in the environment variables of their pod specifications, or from ConfigMaps. Both are stored and shown as ordinary configuration: anyone with read access to the pods, deployments or ConfigMaps in the namespace, which is usually granted far more widely than access to Secrets, can see the values with kubectl get -o yaml or kubectl describe and use them against the databases, cloud services and third-party APIs they protect. Kubernetes documents that ConfigMaps provide no secrecy or encryption.
The values also appear in the manifests, Helm values and repositories used to deploy the workload, and tend to leak through repositories, CI/CD logs and diagnostic output. They are rarely rotated, so a single exposure can give lasting access, and the impact depends on what the credentials unlock. Environment variables add further exposure even when their values come from a Secret: they are inherited by child processes, visible in the process environment under /proc, and often included in crash reports, debug pages and logs.
The issue is identified by reviewing manifests and the output of kubectl get pods,deployments,configmaps -A -o yaml for credential-like names and values, and with secret scanning tools run against manifests, images and repositories. Kubernetes Secrets are themselves only base64-encoded and are stored unencrypted in etcd unless encryption at rest is configured, so moving a value into a Secret is necessary but not sufficient.
Remediation
- Move credentials into Kubernetes Secrets, or preferably an external secrets manager integrated through a CSI driver or an operator, and remove them from pod specifications, ConfigMaps, images and repositories.
- Mount secrets as files in read-only volumes rather than environment variables where the application allows it.
- Restrict
get,listandwatchon Secrets to the identities that need them, remembering that permission to create pods in a namespace also allows its Secrets to be read. - Enable encryption at rest for Secrets on the API server, preferably with a KMS provider, and rewrite existing Secrets so that they are stored encrypted.
- Rotate every credential that has been held in plain configuration, since it should be assumed to be exposed.
Confirm the fix by checking that no credential values remain in pod specifications, ConfigMaps or deployment repositories, and that the rotated credentials are read only from their new location.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.