More Info:
Verifies secret-like env vars are not set as literal values. Literal values land in the pod manifest, logs and kubectl describe.Risk Level
MediumAddress
SecurityCompliance Standards
- Cloudanix Best Practice
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify offending Pods and env vars (any machine with kubectl access)
-
For each offending Pod, determine the owning controller (any machine with kubectl access)
If
ownerReferencesis set (e.g., Deployment, StatefulSet, Job), you must edit that controller, not the live Pod. -
Create a Secret with the sensitive value (any machine with kubectl access)
- For a single key:
- Or from a file:
- For a single key:
-
Update the controller manifest to use
valueFrom.secretKeyRef(any machine with kubectl access)- Get the current manifest:
- In
/tmp/deployment.yaml, under the relevant container’senv:section, replace:with: - Apply the change:
- Get the current manifest:
-
For standalone Pods (no ownerReferences), recreate them using a manifest (any machine with kubectl access)
Edit
/tmp/pod.yaml:- Remove fields under
metadatasuch asuid,resourceVersion,creationTimestamp,managedFields,selfLink,generation. - Remove
status:entirely. - In each offending container’s
env:entry, changevalue:tovalueFrom.secretKeyRefas in step 4. Then delete and recreate:
- Remove fields under
-
Verify the cluster is compliant (any machine with kubectl access)
Confirm the output is
is_compliant=trueor that no offending env vars remain.
Using kubectl
Using kubectl
On any machine with kubectl access:Look under If the Secret must be changed later, use:Edit to:Repeat for every sensitive variable flagged by the check.This will roll out new Pods that reference the Secret.
- Inspect the offending Pod and identify the literal sensitive env var(s):
spec.containers[].env (and initContainers[].env) for entries like:- Create (or update) a Secret containing the sensitive value(s). Example:
- Patch the Pod’s controller (Deployment/StatefulSet/Job/etc.) manifest so the Pod uses
valueFrom.secretKeyRefinstead of a literalvalue. First, export the owning controller manifest:
deployment.yaml and change:- Apply the updated manifest:
- If the Pod is not managed by a higher-level controller (a naked Pod), you must delete and recreate it from a corrected manifest:
- Verify that no literal sensitive env vars remain and that the check passes:
Automation
Automation

