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 one violating Pod, capture its manifest (any machine with kubectl access)
ReplaceNAMESPACEandPOD_NAMEwith values from step 1. -
Create a Secret containing the sensitive value (any machine with kubectl access)
Choose a Secret name and key, then run:Repeat with additional--from-literal=KEY='VALUE'flags for each sensitive env var. -
Edit the Pod’s manifest to use
valueFrom.secretKeyRef(any machine with kubectl access)
Open the file from step 2 and, under the relevant container’senv:section, replace:with:Do this for each sensitive variable, ensuringkey:matches what you stored in the Secret. -
Recreate the Pod so it uses the Secret-based env vars (any machine with kubectl access)
For Pods managed by a higher-level controller (e.g., Deployment, StatefulSet), edit the controller instead of the live Pod. Example for a Deployment:Apply the sameenv:changes to the Deployment spec, then let Kubernetes roll out new Pods.
If it is a standalone Pod (no controller), delete and recreate it from the edited manifest: -
Verify the cluster is compliant (any machine with kubectl access)
Confirm the output is
is_compliant=trueor that no lines for the fixed Pods remain.
Using kubectl
Using kubectl
On any machine with kubectl access:Assume it is a Deployment named c) Edit Remove any previous This will roll out new Pods using the Secret-based env var.
- Identify the violating Pod and env var (from the audit output):
- Example:
- Namespace:
default - Pod name:
my-app-abc123 - Container:
app - Offending env:
DB_PASSWORD
- Namespace:
- Create a Secret that will hold the sensitive value (one-time, per app/namespace):
- Export the current Pod manifest, edit it to use
valueFrom.secretKeyRef, and apply it via its controller (Deployment, StatefulSet, etc.).
If the Pod is standalone (no controller), you must recreate it from a manifest.
owner= field) or via:my-app.b) Export the Deployment manifest:my-app-deploy.yaml:Locate the container and replace the literal value: with valueFrom.secretKeyRef:value: ... line for DB_PASSWORD.d) Apply the updated manifest:- Verification:
is_compliant=true when all violations are fixed:Automation
Automation

