Interview Prep/DevSecOps/Container image and IaC scanning

KICS or Checkov on Kubernetes manifests flags "Container should not run as root" even though the image sets `USER 10001`

IntermediateTroubleshootingContainer image and IaC scanning
Answer

Likely causes → Manifest scanners only see YAML; they cannot read the image USER. Without runAsNonRoot in securityContext, the check fails.

Diagnose → Look for securityContext at pod and container level in the rendered manifest (helm template . | yq '.spec.template.spec').

Fix →

securityContext:
  runAsNonRoot: true
  runAsUser: 10001
  allowPrivilegeEscalation: false
  capabilities: { drop: ["ALL"] }

Prevent → Put the hardened securityContext in the shared Helm library chart so every service inherits it.

All DevSecOps questions

More on Container image and IaC scanning