Skip to content

Istio mTLS and AuthorizationPolicy in production

Configure strict mTLS and identity-based AuthorizationPolicy in Istio, including PeerAuthentication, RequestAuthentication JWT, and deny-by-default rollout strategy.

You have Istio installed and pods are happily mTLS-encrypted, and management has asked for “zero-trust” between services. The temptation is to apply a single AuthorizationPolicy with action: DENY at the namespace level and call it done. That call breaks production within minutes — Istio’s policy stack has four objects (PeerAuthentication, RequestAuthentication, AuthorizationPolicy ALLOW/DENY/AUDIT/CUSTOM, plus default-deny semantics) and their interaction order is not what most teams expect.

How to verify

The mesh-wide mTLS mode should be STRICT once you are done:

kubectl -n istio-system get peerauthentication default -o yaml

A test call from outside the mesh (no mTLS) should be rejected:

kubectl run curl-test --image=curlimages/curl --restart=Never -n default -- \
  curl -s -o /dev/null -w "%{http_code}\n" http://payments.app.svc.cluster.local/health

You should see 000 (connection reset) or 503, not 200. From an in-mesh client, the same call should return 200:

kubectl exec -n app deploy/checkout -c checkout -- \
  curl -s -o /dev/null -w "%{http_code}\n" http://payments.app.svc.cluster.local/health

Authorization decisions are observable on the sidecar:

kubectl logs -n app deploy/payments -c istio-proxy | grep -E "rbac"

What’s happening

There are three policies and they evaluate independently. PeerAuthentication controls transport-level mTLS — does this workload accept plaintext or require mTLS? RequestAuthentication validates JWTs on inbound HTTP, exposing claims (iss, sub, custom claims) as request principals for downstream authorization. AuthorizationPolicy decides whether a request is allowed once it has reached the sidecar; it can match on source principal (the SPIFFE identity from mTLS), request principal (the JWT subject), HTTP method/path, and headers.

The evaluation order on inbound traffic is: CUSTOM (external authz) → DENY → ALLOW → AUDIT. The critical semantic is that if any ALLOW policy applies to a workload, that workload becomes default-deny — only requests matching an ALLOW pass. If no ALLOW policy applies, the workload is default-allow. This is the source of most production incidents: you write one narrow ALLOW for a debug endpoint, and everything else on that service is suddenly denied. Test policies on canary namespaces or use action: AUDIT before flipping to ALLOW.

The procedure

  1. Move to STRICT mTLS mesh-wide. Start with namespace-level PERMISSIVE while you confirm every workload is in the mesh, then promote:

    apiVersion: security.istio.io/v1
    kind: PeerAuthentication
    metadata:
      name: default
      namespace: istio-system
    spec:
      mtls:
        mode: STRICT

    With this in istio-system, the mode applies mesh-wide. Override per namespace or per workload only for clear exceptions (a scraper that legitimately needs plaintext from outside the mesh).

  2. Add identity-based ALLOW policies bottom-up. Define each service’s allowed callers explicitly:

    apiVersion: security.istio.io/v1
    kind: AuthorizationPolicy
    metadata:
      name: payments-allow
      namespace: app
    spec:
      selector:
        matchLabels:
          app: payments
      action: ALLOW
      rules:
        - from:
            - source:
                principals:
                  - cluster.local/ns/app/sa/checkout
                  - cluster.local/ns/app/sa/refund
          to:
            - operation:
                methods: ["POST"]
                paths: ["/api/v1/charge", "/api/v1/refund"]

    The principal format is <trust-domain>/ns/<ns>/sa/<service-account> — make sure each microservice has its own SA, not the default one.

  3. Validate JWTs at the edge with RequestAuthentication. If you accept inbound user traffic via an ingress gateway:

    apiVersion: security.istio.io/v1
    kind: RequestAuthentication
    metadata:
      name: jwt-auth
      namespace: istio-ingress
    spec:
      selector:
        matchLabels:
          istio: ingressgateway
      jwtRules:
        - issuer: "https://auth.example.com"
          jwksUri: "https://auth.example.com/.well-known/jwks.json"
          audiences: ["api.example.com"]
          forwardOriginalToken: true

    Then require an authenticated principal:

    apiVersion: security.istio.io/v1
    kind: AuthorizationPolicy
    metadata:
      name: require-jwt
      namespace: istio-ingress
    spec:
      selector:
        matchLabels:
          istio: ingressgateway
      action: ALLOW
      rules:
        - from:
            - source:
                requestPrincipals: ["*"]
  4. Roll out in AUDIT mode first. Before flipping any production workload to deny, replicate the policy with action: AUDIT and observe istio_requests_total{response_code_details="rbac_access_denied"} over a representative window (24-48h). If the count is non-zero, you have callers you did not know about.

  5. Add explicit DENY rules for known-bad patterns. DENY beats ALLOW, so a DENY is a clean way to block legacy paths during a migration:

    apiVersion: security.istio.io/v1
    kind: AuthorizationPolicy
    metadata:
      name: deny-legacy
      namespace: app
    spec:
      action: DENY
      rules:
        - to:
            - operation:
                paths: ["/v0/*"]
  6. Set a global default-deny once policies stabilize. A namespace-scoped empty ALLOW flips the namespace to default-deny:

    apiVersion: security.istio.io/v1
    kind: AuthorizationPolicy
    metadata:
      name: allow-nothing
      namespace: app
    spec: {}

    Now any request without a matching ALLOW is blocked.

Common pitfalls

  • {} empty spec means default-deny, not allow-all. This trips engineers who skim the docs and assume an empty policy is permissive. It is the opposite.
  • mTLS STRICT breaks NodePort and hostNetwork access. Anything that hits a pod without going through a sidecar (Kubernetes liveness probes are fine because kubelet bypasses iptables, but external scrapers are not) will fail. Use PERMISSIVE on the specific port or expose a dedicated non-mesh endpoint.
  • JWT validation requires reachable JWKS. If your auth issuer is behind a private network or rate-limits aggressively, sidecars will fail open with 403. Cache the JWKS via a sidecar listener or pin a short-TTL config map.
  • AUDIT does not log every denied request — it logs allowed-but-would-have-been-denied. It is the inverse of what most operators expect. Read the docs carefully before sizing dashboards off audit counters.
  • Default service account is shared. If every pod runs as default SA, all your principal-based ALLOWs become trivially bypassable. Run a Gatekeeper or Kyverno policy that rejects pods without an explicit serviceAccountName — see opa-gatekeeper-policies.

Stack Harbor designs and runs the policy lifecycle for Istio-meshed clusters — STRICT mTLS promotion, identity-based ALLOW catalogues per service, JWT issuer integration with the customer IdP, and the audit-then-enforce rollout that keeps the cluster auditable without breaking a production day. See how we operate that lifecycle inside our managed Kubernetes operations practice.