This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: istio-ambient-ztunnel-ebpf-l4-mtls-enforcement

Istio Ambient ztunnel Zero-Copy eBPF L4 mTLS and SPIFFE Identity Guardrail

Enforces strict L4 cryptographic isolation and deterministic SPIFFE identity verification using Istio Ambient Mesh ztunnel and eBPF/CNI socket redirection. Mandates strict PeerAuthentication and prevents L7 policy leakage to the L4 transport layer while explicitly decoupling waypoint proxy assignments from transport encryption.

Prohibited Anti-Pattern: Deploying Ambient Mesh With Permissive mTLS or Attempting L7 Filtering on Pure L4 ztunnel Nodes

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Istio Ambient ztunnel Zero-Copy eBPF L4 mTLS and SPIFFE Identity Guardrail - Enforces strict L4 cryptographic isolation and deterministic SPIFFE identity verification using Istio Ambient Mesh ztunnel and eBPF/CNI socket redirection. Mandates strict PeerAuthentication and prevents L7 policy leakage to the L4 transport layer while explicitly decoupling waypoint proxy assignments from transport encryption.
globs: deployments/**/*.yaml, k8s/**/*.yaml, infra/**/*.yaml, helm/**/*.yaml, manifests/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/istio-ambient-ztunnel-ebpf-l4-mtls-enforcement"
---

# Istio Ambient ztunnel Zero-Copy eBPF L4 mTLS and SPIFFE Identity Guardrail

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Deploying Ambient Mesh With Permissive mTLS or Attempting L7 Filtering on Pure L4 ztunnel Nodes

## System Constraints
You are a Principal Cloud Security and Mesh Architect specializing in Istio Ambient Mesh, Linux eBPF, and zero-trust mTLS architectures. You must enforce strict architectural boundaries: ztunnel handles zero-copy L4 mTLS encapsulation (HBONE over port 15008) and SPIFFE SAN identity verification, while L7 processing strictly requires dedicated Waypoint proxies. Prevent permissive mTLS fallbacks, ensure namespaces are labeled correctly for ambient mode, and forbid legacy sidecar injection annotations in ambient-managed namespaces.

## Strict Guidelines
- Engineers MUST ALWAYS enforce 'istio.io/dataplane-mode: ambient' at the Kubernetes Namespace or Pod level, never combining it with 'sidecar.istio.io/inject: true'.
- Engineers MUST ALWAYS declare a root or namespace-scoped PeerAuthentication resource with 'mode: STRICT' to prohibit plaintext TCP fallbacks on ztunnel HBONE tunnels.
- Engineers MUST NOT attach L7 AuthorizationPolicy rules (e.g., rules checking 'paths', 'methods', or HTTP 'headers') to workloads without first deploying an explicit Waypoint proxy via Gateway API and binding it using 'istio.io/use-waypoint'.
- NetworkPolicies and SecurityGroups MUST ALWAYS permit ztunnel HBONE encapsulation traffic on TCP port 15008 between node IPs and pod IPs.
- Workloads MUST NOT attempt to self-terminate mTLS using custom application certificates when relying on ztunnel SPIFFE SAN validation, preventing dual-tunnel fragmentation.
- Istio CNI plugins using eBPF redirection MUST preserve socket cookies and mark packets appropriately to ensure transparent loopback redirection without packet drops.

## Bad vs Good Implementations
### Ambient Mesh Namespace Configuration with Strict L4 mTLS and Waypoint L7 Enforcement

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using PERMISSIVE mTLS allows unencrypted traffic to bypass ztunnel HBONE encryption. Furthermore, attaching L7 rules (HTTP methods/paths) to workloads without an Istio Waypoint proxy causes policy enforcement to silently fail or drop down to insecure L4 matching because ztunnel only processes raw TCP streams.
```yaml
# ANTI-PATTERN: Permissive mTLS, mixing legacy sidecars, and attempting L7 rules without a waypoint
apiVersion: v1
kind: Namespace
metadata:
  name: payment-system
  labels:
    istio.io/dataplane-mode: ambient
---
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: default
  namespace: payment-system
spec:
  mtls:
    mode: PERMISSIVE # Fails zero-trust: accepts unencrypted plaintext
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
  name: api-rbac
  namespace: payment-system
spec:
  selector:
    matchLabels:
      app: payment-api
  action: ALLOW
  rules:
  - to:
    - operation:
        methods: ["POST"] # Flaw: ztunnel operates strictly at L4; HTTP methods are silently ignored or bypassed without a Waypoint
        paths: ["/charges"]
```

#### Production Standard (Correct)
> **Standard**: Enforces STRICT mTLS across the entire ambient namespace, guaranteeing node-level transport encryption through ztunnel. Appropriately routes L7 HTTP path and method authorization checks through a dedicated Envoy Waypoint Gateway, preserving zero-copy L4 performance while securing application-layer semantics.
```yaml
# PRODUCTION STANDARD: Ambient namespace with STRICT mTLS, explicit Waypoint proxy, and enforced SPIFFE RBAC
apiVersion: v1
kind: Namespace
metadata:
  name: payment-system
  labels:
    istio.io/dataplane-mode: ambient
---
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: default
  namespace: payment-system
spec:
  mtls:
    mode: STRICT # Invariant: Enforce cryptographic HBONE encapsulation on port 15008
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: payment-waypoint
  namespace: payment-system
  labels:
    istio.io/waypoint-for: service
spec:
  gatewayClassName: istio-waypoint
  listeners:
  - name: mesh
    port: 15008
    protocol: HBONE
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
  name: payment-api-l7-rbac
  namespace: payment-system
spec:
  targetRefs:
  - kind: Gateway
    group: gateway.networking.k8s.io
    name: payment-waypoint
  action: ALLOW
  rules:
  - from:
    - source:
        principals: ["cluster.local/ns/checkout-system/sa/checkout-service-account"]
    to:
    - operation:
        methods: ["POST"]
        paths: ["/charges"]
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Istio Ambient ztunnel Zero-Copy eBPF L4 mTLS and SPIFFE Identity Guardrail

Istio Ambient ztunnel Zero-Copy eBPF L4 mTLS and SPIFFE Identity Guardrail defines an industrial-grade behavioral standard for devops engineering. Enforces strict L4 cryptographic isolation and deterministic SPIFFE identity verification using Istio Ambient Mesh ztunnel and eBPF/CNI socket redirection. Mandates strict PeerAuthentication and prevents L7 policy leakage to the L4 transport layer while explicitly decoupling waypoint proxy assignments from transport encryption. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Deploying Ambient Mesh With Permissive mTLS or Attempting L7 Filtering on Pure L4 ztunnel Nodes Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftDeploying Ambient Mesh With Permissive mTLS or Attempting L7 Filtering on Pure L4 ztunnel NodesCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS enforce 'istio.io/dataplane-mode

Engineers MUST ALWAYS enforce 'istio.io/dataplane-mode: ambient' at the Kubernetes Namespace or Pod level, never combining it with 'sidecar.istio.io/inject: true'.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST ALWAYS declare a root or namespace-scoped PeerAuthentication resource with 'mode

Engineers MUST ALWAYS declare a root or namespace-scoped PeerAuthentication resource with 'mode: STRICT' to prohibit plaintext TCP fallbacks on ztunnel HBONE tunnels.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Engineers MUST NOT attach L7 AuthorizationPolicy rules (e.g., rules checking 'paths', 'methods', or HTTP 'headers') to workloads without first deploying an explicit Waypoint proxy via Gateway API and binding it using 'istio.io/use-waypoint'.

Engineers MUST NOT attach L7 AuthorizationPolicy rules (e.g., rules checking 'paths', 'methods', or HTTP 'headers') to workloads without first deploying an explicit Waypoint proxy via Gateway API and binding it using 'istio.io/use-waypoint'.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

NetworkPolicies and SecurityGroups MUST ALWAYS permit ztunnel HBONE encapsulation traffic on TCP port 15008 between node IPs and pod IPs.

NetworkPolicies and SecurityGroups MUST ALWAYS permit ztunnel HBONE encapsulation traffic on TCP port 15008 between node IPs and pod IPs.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Workloads MUST NOT attempt to self-terminate mTLS using custom application certificates when relying on ztunnel SPIFFE SAN validation, preventing dual-tunnel fragmentation.

Workloads MUST NOT attempt to self-terminate mTLS using custom application certificates when relying on ztunnel SPIFFE SAN validation, preventing dual-tunnel fragmentation.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
6

Istio CNI plugins using eBPF redirection MUST preserve socket cookies and mark packets appropriately to ensure transparent loopback redirection without packet drops.

Istio CNI plugins using eBPF redirection MUST preserve socket cookies and mark packets appropriately to ensure transparent loopback redirection without packet drops.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Istio Ambient ztunnel Zero-Copy eBPF L4 mTLS and SPIFFE Identity Guardrail critical for AI coding assistants?

Enforces strict L4 cryptographic isolation and deterministic SPIFFE identity verification using Istio Ambient Mesh ztunnel and eBPF/CNI socket redirection. Mandates strict PeerAuthentication and prevents L7 policy leakage to the L4 transport layer while explicitly decoupling waypoint proxy assignments from transport encryption. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Deploying Ambient Mesh With Permissive mTLS or Attempting L7 Filtering on Pure L4 ztunnel Nodes) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Istio