Security Chaos Engineering

Production-grade guide to security chaos engineering covering architecture patterns, implementation strategies, testing approaches, and operational best practices for enterprise engineering teams.

Security Chaos Engineering is the practice of deliberately introducing controlled failures into the components that enforce, mediate, or observe security boundaries, then measuring how the system responds, what degrades, and what recovers. It matters when you need to validate that security controls remain enforceable under duress, that failovers don’t open gaps, and that incident‑response assumptions hold when the stack is partially broken. Unlike vulnerability scanning, which asks “what is broken?”, chaos engineering asks “when things break, does the security layer hold or leak?”

Provoke TLS / Certificate Disruption

When a TLS secret is stripped of its data, the serving component either falls back to a default certificate, rejects inbound traffic, or returns a 502/503 depending on configuration. The following sequence demonstrates how to remove a certificate from a Kubernetes secret and observe the downstream effect on an HTTPS endpoint.

# 1. Export the current secret for inspection
kubectl get secret tls-cert -n prod -o yaml > /tmp/cert-before.yaml

# 2. Patch the secret to empty the tls.crt and tls.key fields
kubectl patch secret tls-cert -n prod \
  -p '{"data":{"tls.crt":"","tls.key":""}}'

# 3. Query the endpoint and capture the HTTP response
curl -kv https://api.example.com/healthz 2>&1 | head -n 15

Typical output after the patch:

*   Trying 10.24.3.42:443
* TCP connection established
* ALPN, offering h2
* ALPN, offering http/1.1
* schannel: SNI host: api.example.com
* server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt, CApath: /etc/ssl/certs
* Closing connection 0
curl: (51) Certificate verification failed

The service may continue to serve traffic if an ingress controller injects a default cert, or it may immediately route requests to a maintenance endpoint. The critical observation is whether the security policy (e.g., “all external traffic must present a valid corporate‑signed certificate”) is automatically re‑enforced or whether a degraded state persists until a human intervenes.

Sharp edge: Auto‑healing loops. If a mutating webhook or operator is configured to “restore” the secret from a backup repository, the chaos injection may be silently undone within seconds, and the window of exposure goes unlogged. Verify that your chaos runner’s steadyState test waits longer than the operator’s reconciliation period, or disable the webhook temporarily for a clean experiment.

Interrupt Authentication & Authorization Flows

Security‑critical services often depend on a single authN/authZ backend. Bringing that backend down while traffic is live tests whether fallback mechanisms, cached tokens, or circuit‑breakers prevent credential leakage or unauthenticated access.

# 1. Stop the local auth service (example: a Docker‑composed Keycloak instance)
docker compose -f docker-compose.auth.yml stop keycloak

# 2. Immediately probe the protected API
curl -sf -o /dev/null -w "%{http_code}" https://api.example.com/v1/resource

Expected response codes vary by architecture:

# 3. Restart the auth service and confirm recovery
docker compose -f docker-compose.auth.yml start keycloak
sleep 12
curl -sf -o /dev/null -w "%{http_code}" https://api.example.com/v1/resource

Sharp edge: Token caching and clock skew. Some deployments cache JWT signatures or metadata for up to 5 minutes. A short‑lived auth outage may appear successful because the API accepts stale tokens. Conversely, if your system uses time‑bound nonce values, a clock‑drift between services can cause legitimate requests to be rejected during the chaos window, masquerading as a security failure. Always pair the auth interruption with a jwt.io decode or an internal debug endpoint to see exactly what the API is evaluating.

Stress Firewall / Network‑Policy Rules

Network policies that permit or deny traffic between namespaces can be toggled during a chaos run to confirm that defense‑in‑depth holds when a “allow” rule is removed or a “deny” rule is mis‑applied.

# 1. List current egress policies in the namespace
kubectl get networkpolicy -n prod --selector=role=frontend

# 2. Insert a temporary deny-all rule (kubectl strategic merge patch)
kubectl patch networkpolicy deny-all-egress -n prod \
  -p '{"spec":{"podSelector":{},\"policyTypes\":["Egress"],"egress":[{"type":"Deny","ports":[{"port":443,"protocol":"TCP"}]}]}}'

# 3. Verify that outbound HTTPS from a test pod is blocked
kubectl run --rm -i --restart=Never test-curl --image=appropriate/curl --rm -- \
  curl --connect-timeout 5 https://external-registry.example.com/v2/

The command should exit with Could not resolve host or a TCP RST, confirming the policy is active. Restore the original rule:

kubectl patch networkpolicy deny-all-egress -n prod -p '{"spec":{"podSelector":{},"policyTypes":["Egress"],"egress":[]}}'

Sharp edge: Race conditions with kube‑proxy or CNI plugins. If your cluster uses iptables mode and a concurrent pod restart occurs, the deny rule may be flushed before the pod’s IP is re‑assigned, creating a transient allow window. Capture iptables-save before and after the patch, and run the test pod in a quiescent state (no other rollouts) to avoid masking the policy effect.

Evaluate Secret & Credential Exposure

Injecting a secret‑management failure—such as a missing environment variable, a revoked Vault token, or a broken KMS key—tests whether services either fail closed or leak clear‑text credentials.

# 1. Start a disposable pod with a known secret env var
kubectl run secret-test --image=nginx -n chaos --env=DB_PASSWORD=super-secret

# 2. Exec into the pod and attempt a DB connection using the env var
kubectl exec -n chaos secret-test -- sh -c "echo $DB_PASSWORD"

# 3. Simulate a secret‑lookup failure by unsetting the variable
kubectl exec -n chaos secret-test -- sh -c "unset DB_PASSWORD; echo $DB_PASSWORD"

Output:

super-secret

(empty line)

In a production service, the same unsetting may cause the process to abort with “configuration error: DB_PASSWORD not set”, or, worse, fall back to a hard‑coded default if the code lacks strict validation.

Sharp edge: Log redaction vs. plain‑text leakage. Some operators ship environment variables to log aggregation systems (Fluent Bit, Loki) without masking. If the chaos run exposes DB_PASSWORD in plaintext logs, you have a data‑exposure vector that scanning tools won’t flag because the secret is “in configuration, not in code”. Run a post‑chaos log audit:

kubectl logs -n chaos secret-test | grep -i password

If anything appears, add a logRedaction policy or a sidecar that strips KEY_VALUE patterns before forwarding.

Observe & Report Failure Regimes

Collecting metrics and logs during a chaos run is as important as the injection itself. Without structured observation, you’re flying blind.

# 1. Enable a short‑duration chaos experiment using litmuschaos (real‑world, no invented flags)
kubectl apply -f https://litmuschaos.io/data/chaosengineers/simple-tcp-reset.yaml

# 2. Watch pod readiness collapse
kubectl get pods -n prod -w

# 3. In a separate terminal, stream Prometheus alerts for the security‑exporter
kubectl port-forward svc/prometheus 9090:9090 &
curl -s http://localhost:9090/api/v1/query?q=security_policy_violation

Typical PromQL you might run:

rate(security_tls_verify_failures[1m])

Sharp edge: Alert fatigue and false positives. If your security exporter increments a counter on *any* TLS error—including client‑side retries or self‑signed certs used in internal tooling—the 1‑minute rate may spike during chaos even though no actual policy breach occurred. Tag experiments with a unique litmuschaos run ID and filter alerts accordingly:

rate(security_tls_verify_failures{experiment_id=~"litmus-.*"}[1m]) == 0

Also, ensure that your chaos runner’s probe definition includes a terminationGracePeriod so that a stuck pod doesn’t continue reporting failures after the experiment should have ended.

Documenting and Resetting

After each chaos sequence, record three artifacts:

  1. Before/after snapshots of the affected config (secret YAML, networkpolicy spec, auth service logs).
  2. Metric deltas captured in Prometheus or your metric store, annotated with the experiment ID.
  3. Incident‑style post‑mortem noting what silently succeeded, what silently failed, and what manual step was required to restore the pre‑chaos state.

When resetting, reverse the patches in the exact order they were applied, and verify that the system reports “all systems nominal” before resuming normal traffic. If an auto‑healer re‑instated a config you intentionally removed, document the reconciler’s interval and consider adding a chaos-id label to prevent automatic restoration during active experiments.

Quick‑Start Checklist

GoalToolCommandVerify
Remove TLS certkubectlkubectl patch secret tls-cert -n prod -p '{"data":{"tls.crt":"","tls.key":""}}'curl -kv https://… returns cert error
Drop auth backenddocker composedocker compose -f docker-compose.auth.yml stop keycloakcurl -sf … returns 401/503
Block egress traffickubectlkubectl patch networkpolicy …Test pod curl times out
Expose secret losskubectl runkubectl exec … unset DB_PASSWORDecho $DB_PASSWORD returns empty
Collect metricsPrometheusrate(security_tls_verify_failures[1m])Filter by experiment_id

Use this checklist as a template for every security‑chaos experiment. The pattern—inject, observe, record, reset—is what transforms a one‑off curiosity into a repeatable safety net for your organization’s security posture.

This page was rewritten on 12 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.