Stage 6, Part 3 of 9, RBAC, ServiceAccounts & Security

Text

PART 3: PRODUCTION FAILURE MODES

17. Top 10 Kubernetes Security Failures

#FailureSymptomRoot CauseFix
1Over-privileged SALateral movementBroad RBACLeast privilege
2cluster-admin for humansFull compromiseConvenienceOIDC + scoped RBAC
3Secrets in GitCredentials leakedNo secrets managementSealed Secrets, SOPS
4Privileged containersContainer escapeNo PSS enforcementPSA restricted
5No NetworkPolicyLateral movementDefault allow-allDefault deny
6Anonymous auth enabledUnauthorized accessDefault configDisable
7Webhook failurePolicy: FailCluster outageWebhook downHA webhook
8Unrotated certificatesAuth failuresNo rotationkubeadm certs renew
9No audit loggingCan't investigateNot configuredEnable audit logs
10Image without signature verificationBackdoored imageNo verifyImagesKyverno verify

18. Security Incident Runbook

"Suspected RBAC Breach" — Step-by-Step

text
STEP 1: Identify the incident
  # Alert source: audit logs, anomaly detection
  # Verify legitimacy

STEP 2: Isolate the affected identity
  # If ServiceAccount:
  $ kubectl delete sa <sa-name> -n <namespace>
  # If user:
  # Revoke credentials at the IdP

STEP 3: Audit what the identity did
  $ kubectl get events --field-selector reason=RBACDenied
  # Or check audit logs
  # Filter by the identity

STEP 4: Identify the breach vector
  # Was the SA over-privileged?
  $ kubectl get rolebindings,clusterrolebindings -A -o json | \
    jq '.items[] | select(.subjects[]?.name=="<sa-name>")'

  # Or for a user:
  $ kubectl auth can-i --list --as=<user>

STEP 5: Check for lateral movement
  # What else did the identity access?
  # Check audit logs for all requests

STEP 6: Rotate compromised credentials
  # Delete ServiceAccount and recreate
  # Rotate any tokens

STEP 7: Fix the RBAC misconfiguration
  # Remove over-privileged roles
  # Apply least privilege

STEP 8: Post-incident
  # Document
  # Update policies
  # Notify stakeholders

STEP 9: Escalate
  # Security team, management

Indicators of Compromise (IoCs)

IndicatorWhere to Look
Unexpected RBAC changesAudit logs
Anomalous API accessAudit logs
New ServiceAccount createdAudit logs
ClusterRoleBinding createdAudit logs
Secrets accessed outside hoursAudit logs
Unexpected kubectl execAudit logs
New IAM role assumptionCloudTrail (AWS), Cloud Audit Logs (GCP)

19. Blast Radius Analysis

What Happens When Security Fails?

ComponentImpactSeverity
cluster-admin compromisedFull cluster takeoverSEV-1
ServiceAccount compromisedDepends on RBACSEV-1 to SEV-3
Secret leakedDepends on secret scopeSEV-1 to SEV-3
Privileged container escapeNode compromiseSEV-1
Image backdoorFull service compromiseSEV-1
RBAC misconfigurationUnintended accessSEV-2
Webhook downBlocked admissionsSEV-2

Mitigation Strategies

StrategyImplementation
Least privilege RBACMinimal permissions
OIDC for humansCentralized identity
Pod Security StandardsRestricted enforcement
Network PoliciesDefault deny
Image signingcosign + admission
Audit loggingCentralized SIEM
Secret managementVault, External Secrets
Runtime securityFalco, Tetragon

1:1 copy of the class Google Doc, code in code blocks.