Skip to main content

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

Medium

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Manual Steps

  1. Identify offending Pods and env vars (any machine with kubectl access)
  2. For each offending Pod, determine the owning controller (any machine with kubectl access)
    If ownerReferences is set (e.g., Deployment, StatefulSet, Job), you must edit that controller, not the live Pod.
  3. Create a Secret with the sensitive value (any machine with kubectl access)
    • For a single key:
    • Or from a file:
  4. 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’s env: section, replace:
      with:
    • Apply the change:
    This will roll the Pods for that controller and recreate them with the Secret reference.
  5. For standalone Pods (no ownerReferences), recreate them using a manifest (any machine with kubectl access)
    Edit /tmp/pod.yaml:
    • Remove fields under metadata such as uid, resourceVersion, creationTimestamp, managedFields, selfLink, generation.
    • Remove status: entirely.
    • In each offending container’s env: entry, change value: to valueFrom.secretKeyRef as in step 4. Then delete and recreate:
  6. Verify the cluster is compliant (any machine with kubectl access)
    Confirm the output is is_compliant=true or that no offending env vars remain.
On any machine with kubectl access:
  1. Inspect the offending Pod and identify the literal sensitive env var(s):
Look under spec.containers[].env (and initContainers[].env) for entries like:
  1. Create (or update) a Secret containing the sensitive value(s). Example:
If the Secret must be changed later, use:
  1. Patch the Pod’s controller (Deployment/StatefulSet/Job/etc.) manifest so the Pod uses valueFrom.secretKeyRef instead of a literal value. First, export the owning controller manifest:
Edit deployment.yaml and change:
to:
Repeat for every sensitive variable flagged by the check.
  1. Apply the updated manifest:
This will roll out new Pods that reference the Secret.
  1. If the Pod is not managed by a higher-level controller (a naked Pod), you must delete and recreate it from a corrected manifest:
  1. Verify that no literal sensitive env vars remain and that the check passes: