Interview Prep/DevSecOps/Certificates, TLS and security incident response

The Kubernetes audit log shows successful `list pods` requests from `system:anonymous`

AdvancedTroubleshootingCertificates, TLS and security incident response
Answer

Likely causes → Anonymous auth is on (the API server default) and someone bound a role to system:anonymous or system:unauthenticated, often a quick fix for a monitoring tool or a tutorial.

Diagnose →

kubectl get clusterrolebindings,rolebindings -A -o json | \
  jq -r '.items[] | select(.subjects[]?.name | test("system:(anonymous|unauthenticated)")) | "\(.kind) \(.metadata.namespace // "-") \(.metadata.name) -> \(.roleRef.name)"'
kubectl auth can-i --list --as=system:anonymous

Fix → Delete those bindings. Review the audit log for what anonymous callers accessed and from which IPs. Restrict API endpoint exposure (private endpoint or authorized networks).

Prevent → Run a policy or CI check that rejects bindings to anonymous or unauthenticated subjects. Where possible, restrict anonymous auth to health endpoints only (AuthenticationConfiguration anonymous conditions in recent Kubernetes versions).

All DevSecOps questions

More on Certificates, TLS and security incident response