Scenario
An SRE team manages multiple Kubernetes clusters with default RBAC that allows developers to create privileged Pods. Security audit reveals a malicious Pod mounted host directories to gain node-level access.
Symptoms
- Unknown Pods appear with host volume mounts.
- Audit logs show non-admin users using
privileged: trueorhostPID: true. - Security scanners report missing Pod security policies.
Diagnosis
- Check RBAC bindings:
kubectl get clusterrolebindings -o widefor overly broadcluster-adminbindings. - Inspect PodSecurityPolicy (PSP) or Pod Security Admission (PSA) status:
kubectl get psporkubectl get admissionregistration.k8s.io/v1/mutatingwebhookconfigurations. - Audit Pod specs:
kubectl get pods --all-namespaces -o jsonpath="{range .items[*]}{.metadata.name}{'\t'}{.spec.containers[*].securityContext.privileged}{'\n'}{end}".
Hardening Commands
- Apply Pod Security Standards (PSA):
kubectl label ns default pod-security.kubernetes.io/enforce=restricted. - Create minimal RBAC: Bind developers to a Role with only
get,listpermissions, avoidcluster-admin.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: developer-restricted
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- Remove risky ClusterRoleBinding:
kubectl delete clusterrolebinding <name>.
Risk Controls
- Test PSA labels in non-production first to avoid impacting running workloads.
- Apply in audit mode initially, then switch to enforce after reviewing violations.
- Maintain break-glass admin accounts for emergency access.
Rollback
- Remove PSA label:
kubectl label ns default pod-security.kubernetes.io/enforce-. - Restore RBAC: Reapply previous RoleBinding backups.
Verification
- Check PSA rejects privileged Pods:
kubectl run test --image=nginx --privilegedshould error. - Confirm non-admin cannot list cluster secrets:
kubectl get secrets --as=developer.
When to Submit an OpsGlobal Ticket
- Cluster scales beyond 20 nodes requiring unified policy management.
- Need custom admission controllers or dynamic security policies.
- Compliance mandates (e.g., PCI-DSS) require professional audit reports.
Use cases
Useful for teams handling Security issues and needing a clear troubleshooting and delivery workflow.
Problem background
A practical guide to diagnosing and hardening Kubernetes RBAC and Pod Security vulnerabilities, with step-by-step commands, risk controls, rollback, and verification. Ideal for SRE teams aiming to boost platform security.
Troubleshooting steps
Confirm impact and recent changes, collect logs, configuration and metrics, then apply fixes from low to high risk.
Command examples
Replace sample resource names with real values and store passwords, tokens and keys in environment variables.
Risks
Before production changes, confirm backups, access boundaries, change windows and rollback paths.
Rollback plan
Keep original configuration and release versions; roll back config, images or database changes if metrics degrade.
Deliverables
Root-cause notes, key commands, remediation steps, verification results and follow-up recommendations.
Need help with a similar technical issue?
If your servers, Kubernetes, Docker, CI/CD, databases or monitoring systems have similar issues, submit logs and config files for remote diagnosis.