Assurance and response · wrap-up
Cheat sheet & self-check
Every command from this section on one page.
PostgreSQL row-level security
ALTER TABLE accounts ENABLE ROW LEVEL SECURITY; | Turn on RLS for a table |
ALTER TABLE accounts FORCE ROW LEVEL SECURITY; | Apply RLS to the table owner too |
CREATE POLICY tenant_isolation ON accounts USING (tenant_id = current_setting('app.tenant_id')::uuid); | Only rows for the session's tenant |
SET app.tenant_id = '…'; | Set the tenant for this connection or transaction (from the verified token) |
Quick isolation tests
curl -H "Authorization: Bearer $TENANT_A_TOKEN" https://api.example.com/tenants/B/users | Must be 403/404, never data |
kubectl get resourcequota,limitrange -n <tenant-ns> | Compute limits for a dedicated namespace |
Evidence you can pull from the platform
kubectl get policyreport,clusterpolicyreport -A | Kyverno policy results per namespace (pass/fail) |
kube-bench run --targets node,policies --json | CIS Kubernetes Benchmark results |
trivy image --format cyclonedx --output sbom.json <image> | SBOM for an image |
cosign verify --key cosign.pub <image>@<digest> | Proof an image was signed by your pipeline |
git log --merges --format='%h %an %s' -- clusters/prod | Reviewed, merged changes to production config |
STRIDE at a glance
S: Spoofing | Pretending to be someone else → strong authentication, mTLS, MFA |
T: Tampering | Changing data or code → signing, integrity checks, GitOps |
R: Repudiation | Denying an action → audit logs, signed commits, tamper-resistant logs |
I: Information disclosure | Leaking data → encryption, tenant isolation, least privilege |
D: Denial of service | Exhausting resources → rate limits, quotas, cells |
E: Elevation of privilege | Gaining more rights → least privilege, Pod Security, admission control |
Contain
kubectl label pod <pod> -n shop quarantine=true app- | Remove from Service endpoints (stop new traffic) and mark it |
kubectl apply -f quarantine-netpol.yaml | Deny all ingress and egress for quarantine=true pods |
kubectl cordon <node> | No new pods on the affected node |
Preserve and scope
kubectl get pod <pod> -n shop -o yaml > pod.yaml | Spec, image digest, ServiceAccount, node |
kubectl logs <pod> -n shop --all-containers --timestamps > logs.txt | Container logs before anything restarts |
kubectl debug node/<node> -it --image=busybox | Inspect the node from a debug pod (host filesystem under /host) |
kubectl auth can-i --list --as=system:serviceaccount:shop:<sa> | What the workload's identity could do in the cluster |
kubectl get clusterrolebindings,mutatingwebhookconfigurations,daemonsets -A --sort-by=.metadata.creationTimestamp | Recently created high-risk objects (persistence) |
Review questions per layer
Humans | SSO + MFA everywhere? Standing admin? JIT? Reviews? |
Workloads | One identity per service? Static cloud keys anywhere? |
Service to service | Default deny? Strict mTLS? Identity-based L7 policy? |
Edge and users | Token checks complete (aud, alg, tenant)? Identity headers stripped? |
Data | Tenant enforced in the database? Per-tenant keys where needed? |
Delivery | Signed images verified at admission? Pipeline credentials short-lived? |
Detect and respond | Runtime detection? Audit logs central? Quarantine runbook? |