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

Istio Ambient Mesh ztunnel eBPF Transparent Redirection Invariants

Enforces deterministic node-level socket capture and HBONE encapsulation invariants across ambient mesh workloads without in-pod sidecars or host-cgroup mutation. Guarantees that ztunnel retains cryptographic identity attestation (SPIFFE ID matching) and non-invasive eBPF/iptables redirection without breaking CNI compatibility or exposing cleartext socket bypasses.

Prohibited Anti-Pattern: Bypassing ztunnel HBONE redirection via unpinned eBPF sockops or colliding iptables MARK rules

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Istio Ambient Mesh ztunnel eBPF Transparent Redirection Invariants - Enforces deterministic node-level socket capture and HBONE encapsulation invariants across ambient mesh workloads without in-pod sidecars or host-cgroup mutation. Guarantees that ztunnel retains cryptographic identity attestation (SPIFFE ID matching) and non-invasive eBPF/iptables redirection without breaking CNI compatibility or exposing cleartext socket bypasses.
globs: deploy/helm/**/*.yaml, manifests/**/*.yaml, infra/**/*.tf, scripts/**/*.sh, pkg/ambient/**/*.go
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/istio-ambient-ztunnel-ebpf-redirection-guardrail"
---

# Istio Ambient Mesh ztunnel eBPF Transparent Redirection Invariants

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Bypassing ztunnel HBONE redirection via unpinned eBPF sockops or colliding iptables MARK rules

## System Constraints
You are a Principal Platform Engineer and Mesh Security Architect enforcing Istio Ambient Mesh ztunnel eBPF transparent socket redirection invariants. You must mandate zero-touch workload cgroup preservation, explicit Geneve/HBONE encapsulation compliance (port 15008), strict SPIFFE identity attestation via the node-local ztunnel, and conflict-free coexistence with underlying CNI routing structures (e.g., Cilium, Calico, AWS-VPC-CNI). Reject any configuration attempting manual namespace network tampering, iptables chain clobbering, or permissive plain-text fallback on mesh-enrolled namespaces.

## Strict Guidelines
- Workload namespaces enrolled in ambient mesh MUST ONLY use the label `istio.io/dataplane-mode: ambient`; manual proxy injection (`istio-injection: enabled`) MUST NOT be combined with ambient namespaces.
- The ztunnel daemonset MUST be pinned to host-network (`hostNetwork: true`) and run with explicit `CAP_NET_ADMIN` and `CAP_NET_RAW` privileges without granting unnecessary root-level capabilities.
- Custom CNI chaining or eBPF configurations MUST NOT overwrite the Istio packet mark (`0x100/0x100` and socket mark `0x539`) utilized by ztunnel for transparent socket diversion.
- Inter-node and node-to-ztunnel transit MUST route strictly over HBONE (HTTP/2 Based Overlay Network Encapsulation) on mutual TLS port 15008, rejecting raw TCP socket leaks.
- eBPF sockops programs MUST NOT mutate workload container cgroups directly; redirection MUST be established through the Istio CNI node agent using host-level routing policies (`ip rule` and network namespace socket cookies).
- Network policies MUST NOT block internal loopback redirection to ztunnel proxy inbound port 15006 or outbound capture port 15001.

## Bad vs Good Implementations
### Namespace Ambient Labeling and CNI-Safe ztunnel Redirection Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Enabling both classic sidecar injection and ambient dataplane on the same namespace causes double proxying, broken TLS state machines, and connection resets. Running ztunnel with blanket privileged: true instead of scoped Linux capabilities bypasses kernel guardrails, and disabling HBONE exposes unencrypted plaintext traffic.
```yaml
apiVersion: v1
kind: Namespace
metadata:
  name: payment-service
  labels:
    # ANTI-PATTERN: Blending sidecar injection with ambient mesh causes dual-proxying and broken mTLS handshakes
    istio-injection: enabled
    istio.io/dataplane-mode: ambient
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: ztunnel
  namespace: istio-system
spec:
  template:
    spec:
      containers:
      - name: istio-proxy
        image: docker.io/istio/ztunnel:1.22.0
        securityContext:
          privileged: true # ANTI-PATTERN: Over-privileged container violating minimal least-privilege for eBPF/NetAdmin
        env:
        - name: ISTIO_META_ENABLE_HBONE
          value: "false" # ANTI-PATTERN: Disabling HBONE breaks tunnel integrity and mutual identity attestation
```

#### Production Standard (Correct)
> **Standard**: Correctly applies single-mode ambient dataplane labeling, preserves workload pod isolation, grants minimal requisite network capabilities (NET_ADMIN, NET_RAW) for eBPF socket tracking, and dedicates port 15008 exclusively to secure HBONE encapsulation.
```yaml
apiVersion: v1
kind: Namespace
metadata:
  name: payment-service
  labels:
    # Enforce pure ambient mesh transparent capture without workload pod mutation
    istio.io/dataplane-mode: ambient
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: ztunnel
  namespace: istio-system
spec:
  template:
    spec:
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      containers:
      - name: istio-proxy
        image: docker.io/istio/ztunnel:1.22.0
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            drop: ["ALL"]
            add: ["NET_ADMIN", "NET_RAW"]
          readOnlyRootFilesystem: true
          runAsNonRoot: false # Required for eBPF socket map attachments
        env:
        - name: CA_ADDRESS
          value: istiod.istio-system.svc:15012
        - name: XDS_ADDRESS
          value: istiod.istio-system.svc:15012
        ports:
        - name: hbone
          containerPort: 15008
          hostPort: 15008
          protocol: TCP
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Istio Ambient Mesh ztunnel eBPF Transparent Redirection Invariants

Istio Ambient Mesh ztunnel eBPF Transparent Redirection Invariants defines an industrial-grade behavioral standard for devops engineering. Enforces deterministic node-level socket capture and HBONE encapsulation invariants across ambient mesh workloads without in-pod sidecars or host-cgroup mutation. Guarantees that ztunnel retains cryptographic identity attestation (SPIFFE ID matching) and non-invasive eBPF/iptables redirection without breaking CNI compatibility or exposing cleartext socket bypasses. 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: Bypassing ztunnel HBONE redirection via unpinned eBPF sockops or colliding iptables MARK rules 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 DriftBypassing ztunnel HBONE redirection via unpinned eBPF sockops or colliding iptables MARK rulesCritical
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

Workload namespaces enrolled in ambient mesh MUST ONLY use the label `istio.io/dataplane-mode

Workload namespaces enrolled in ambient mesh MUST ONLY use the label `istio.io/dataplane-mode: ambient`; manual proxy injection (`istio-injection: enabled`) MUST NOT be combined with ambient namespaces.

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

The ztunnel daemonset MUST be pinned to host-network (`hostNetwork

The ztunnel daemonset MUST be pinned to host-network (`hostNetwork: true`) and run with explicit `CAP_NET_ADMIN` and `CAP_NET_RAW` privileges without granting unnecessary root-level capabilities.

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

Custom CNI chaining or eBPF configurations MUST NOT overwrite the Istio packet mark (`0x100/0x100` and socket mark `0x539`) utilized by ztunnel for transparent socket diversion.

Custom CNI chaining or eBPF configurations MUST NOT overwrite the Istio packet mark (`0x100/0x100` and socket mark `0x539`) utilized by ztunnel for transparent socket diversion.

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

Inter-node and node-to-ztunnel transit MUST route strictly over HBONE (HTTP/2 Based Overlay Network Encapsulation) on mutual TLS port 15008, rejecting raw TCP socket leaks.

Inter-node and node-to-ztunnel transit MUST route strictly over HBONE (HTTP/2 Based Overlay Network Encapsulation) on mutual TLS port 15008, rejecting raw TCP socket leaks.

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

eBPF sockops programs MUST NOT mutate workload container cgroups directly

eBPF sockops programs MUST NOT mutate workload container cgroups directly; redirection MUST be established through the Istio CNI node agent using host-level routing policies (`ip rule` and network namespace socket cookies).

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

Network policies MUST NOT block internal loopback redirection to ztunnel proxy inbound port 15006 or outbound capture port 15001.

Network policies MUST NOT block internal loopback redirection to ztunnel proxy inbound port 15006 or outbound capture port 15001.

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 Mesh ztunnel eBPF Transparent Redirection Invariants critical for AI coding assistants?

Enforces deterministic node-level socket capture and HBONE encapsulation invariants across ambient mesh workloads without in-pod sidecars or host-cgroup mutation. Guarantees that ztunnel retains cryptographic identity attestation (SPIFFE ID matching) and non-invasive eBPF/iptables redirection without breaking CNI compatibility or exposing cleartext socket bypasses. 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 (Bypassing ztunnel HBONE redirection via unpinned eBPF sockops or colliding iptables MARK rules) 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