Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 36 ยท Projects and Practice

Project: Zero-Trust Audit and Hardening Checklist for Istio

Audit and harden an Istio mesh: mesh-wide STRICT mTLS, default-deny authorization, least-privilege allow rules, egress lockdown and gateway TLS, with a checklist and a runnable policy evaluator.

A mesh gives you the tools for zero trust, but nothing is secure until the policies are in place. In this closing project you audit an existing mesh, harden it step by step and verify the result. The product cannot run on this site, so the cluster steps are read-only commands for your own cluster; the Python stand-ins evaluate policies and audit manifests so you can practice the reasoning.

The idea of zero trust is simple: no request is trusted because of where it comes from. Every call is authenticated (who are you?), authorized (are you allowed to do this?) and encrypted. Network location (being inside the cluster) grants nothing.

The hardening ladder

  1. Encrypt everything. Move from PERMISSIVE to STRICT mTLS, namespace by namespace, then mesh-wide.
  2. Deny by default. An empty AuthorizationPolicy in the root namespace denies every request.
  3. Allow minimum access. Add ALLOW rules naming the caller's identity (service account), methods and paths.
  4. Lock the edges. TLS at the ingress gateway, REGISTRY_ONLY egress, NetworkPolicies as the second wall.
  5. Prove and monitor. Use telemetry to show that all traffic is mTLS and alert on denials.

Step 1: mTLS modes

First find out who still sends plaintext. Check the metric label connection_security_policy (value none marks plaintext) in Prometheus or look for edges without padlocks in Kiali. When none remain, enforce:

YAML
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
  name: default
  namespace: istio-system      # root namespace = mesh-wide
spec:
  mtls:
    mode: STRICT

Do this in a staging namespace first. Workloads without a sidecar (jobs, legacy services) will be refused; either mesh them or add a narrow PERMISSIVE exception with a PeerAuthentication that uses a selector or port-level setting.

Step 2: default deny

YAML
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: deny-all
  namespace: istio-system
spec: {}

An AuthorizationPolicy with an empty spec matches no allow rule, so every request is denied with 403 RBAC: access denied (TCP connections are reset). Expect an outage, so apply it namespace by namespace, after you have written the allow policies, or run it in dry-run mode first: the annotation istio.io/dry-run: "true" makes the policy log what it would deny without enforcing it.

Step 3: allow what is needed

YAML
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: reviews-allow
  namespace: bookinfo
spec:
  selector:
    matchLabels: { app: reviews }
  action: ALLOW
  rules:
    - from:
        - source:
            principals: ["cluster.local/ns/bookinfo/sa/bookinfo-productpage"]
      to:
        - operation:
            methods: ["GET"]
            paths: ["/reviews/*"]

Evaluation order matters. Istio evaluates CUSTOM policies first, then DENY, then ALLOW. If any DENY policy matches, the request is rejected. If there are no ALLOW policies for the workload, the request is allowed (unless denied). If ALLOW policies exist, the request must match at least one of them. A request that reaches no rule at all is denied.

Step 4: edges

  • Ingress: HTTPS on the gateway with minProtocolVersion: TLSV1_2, an HTTP-to-HTTPS redirect and rate limits (see the lessons on gateway TLS and rate limiting).
  • Egress: outboundTrafficPolicy: REGISTRY_ONLY, ServiceEntries for approved destinations and a NetworkPolicy that stops pods from reaching the internet directly.
  • Namespaces: keep the injection label under policy control (admission policies can forbid removing it).
  • Credentials: certificates rotate automatically (24 hours by default for workload certificates), but gateway certificates, remote secrets and CA keys need their own rotation plan.

Try it: evaluate AuthorizationPolicies

This stand-in implements the evaluation order described above for a handful of requests.

Python AuthorizationPolicy evaluator

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Try it: audit a set of manifests

Python Hardening audit script

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Deliverable

Write a one-page report for your own cluster with: the current state of each rung of the ladder, the findings sorted by risk, the order in which you will fix them and how you will verify each step (a Prometheus query, a curl that must now fail, a Kiali screenshot). Make the checks repeatable: put istioctl analyze and your policy tests into CI.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does an AuthorizationPolicy with an empty spec do?

    With no rules it matches nothing, so it works as a default deny when no other ALLOW policy permits the request.
  2. 2. In which order does Istio evaluate authorization actions?

    CUSTOM first, then DENY, then ALLOW; a matching DENY always wins.
  3. 3. How can you test a deny-all policy before enforcing it?

    Dry-run mode lets you see what would be denied before it causes an outage.
  4. 4. Why pair REGISTRY_ONLY with a NetworkPolicy?

    Defense in depth: a pod that avoids its sidecar is still stopped by the network policy.

Summary

  • Zero trust = authenticate, authorize and encrypt every request, regardless of network location.
  • Ladder: STRICT mTLS, default deny, minimal allow rules, locked-down edges, continuous verification.
  • Policy evaluation: CUSTOM, then DENY, then ALLOW; an unmatched request is denied when ALLOW policies exist.
  • Use dry-run, staging namespaces and CI checks to harden without outages.

Next: Back to the Istio track