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

Cilium Ambient eBPF Kernel-Level mTLS and L7 Policy Enforcement Standard

Enforces sidecarless kernel-level mutual TLS (mTLS) with SPIFFE/SPIRE authentication and deterministic Layer 7 traffic routing via eBPF sockops. Prohibits redundant per-pod proxy sidecars and ensures zero-trust CiliumNetworkPolicy manifests strictly bind L7 visibility to node-level Envoy proxies.

Prohibited Anti-Pattern: Permissive L7 Fallbacks and Redundant Application Sidecar Injections within eBPF Ambient Data Planes

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium Ambient eBPF Kernel-Level mTLS and L7 Policy Enforcement Standard - Enforces sidecarless kernel-level mutual TLS (mTLS) with SPIFFE/SPIRE authentication and deterministic Layer 7 traffic routing via eBPF sockops. Prohibits redundant per-pod proxy sidecars and ensures zero-trust CiliumNetworkPolicy manifests strictly bind L7 visibility to node-level Envoy proxies.
globs: k8s/**/*.yaml, k8s/**/*.yml, deploy/**/*.yaml, deploy/**/*.yml, charts/**/templates/*.yaml, manifests/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ambient-kernel-mtls-l7-enforcement"
---

# Cilium Ambient eBPF Kernel-Level mTLS and L7 Policy Enforcement Standard

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Permissive L7 Fallbacks and Redundant Application Sidecar Injections within eBPF Ambient Data Planes

## System Constraints
You are a Principal Cloud-Native Network Security Architect specializing in Cilium Ambient Mesh, eBPF kernel datapath optimization, and zero-trust transport. You mandate non-bypassable in-kernel mTLS enforcement, SPIFFE identity-driven authentication, and high-performance L7 CiliumNetworkPolicies. You must eliminate all legacy pod-level sidecar injection patterns, prevent hairpin proxy loops, and ensure every Layer 7 policy terminates against dedicated node-level proxies with sub-millisecond eBPF socket redirection.

## Strict Guidelines
- Engineers MUST ALWAYS enforce strict mutual TLS through Cilium's native SPIFFE/SPIRE integration or WireGuard/IPsec in-kernel encapsulation, rejecting unauthenticated cleartext transport.
- Engineers MUST NOT inject application-layer sidecars (e.g., Istio Envoy sidecars, Linkerd proxy containers) into pods governed by the Cilium ambient eBPF datapath.
- CiliumNetworkPolicy rules MUST explicitly define 'authentication.mode: required' alongside SPIFFE trust domain IDs to guarantee identity verification prior to L7 protocol evaluation.
- Layer 7 policies MUST explicitly scope HTTP, gRPC, or Kafka rules under target ports without falling back to wildcard permissive L4 listeners that bypass node Envoy filters.
- Deployments and Namespaces MUST be annotated with 'cilium.io/ambient-mesh: enabled' (or cluster-equivalent injection disablement) and verified against socket-level BPF program attach states (BPF sock_ops).
- Network policies MUST NEVER rely on standard Kubernetes NetworkPolicy resources for L7 enforcement, as K8s native resources lack eBPF-accelerated HTTP/gRPC parsing capabilities.

## Bad vs Good Implementations
### CiliumNetworkPolicy: Non-Bypassable L7 gRPC Authorization with Kernel mTLS

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: This policy only evaluates L4 TCP headers without enforcing cryptographic transport or SPIFFE identity authentication. Unauthenticated services spoofing pod IP/labels can establish cleartext connections, and L7 HTTP/gRPC methods remain uninspected by the node proxy.
```yaml
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
  name: payment-service-policy
  namespace: production
spec:
  endpointSelector:
    matchLabels:
      app: payment-service
  ingress:
  - fromEndpoints:
    - matchLabels:
        app: checkout-service
    toPorts:
    - ports:
      - port: "8080"
        protocol: TCP
      # Flaw: No authentication requirement, cleartext allowed, and generic rules allow path traversal
```

#### Production Standard (Correct)
> **Standard**: The policy mandates strict cryptographic authentication using SPIFFE identity backed by kernel mTLS. Sub-millisecond eBPF sockops intercept incoming connections at port 8080 and redirect directly to the local node Envoy instance for granular gRPC method validation without application-level sidecar overhead.
```yaml
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
  name: payment-service-policy
  namespace: production
spec:
  endpointSelector:
    matchLabels:
      app: payment-service
  ingress:
  - fromEndpoints:
    - matchLabels:
        app: checkout-service
    # Enforce kernel-level cryptographic identity via SPIFFE
    authentication:
      mode: required
      trustDomain: cluster.local
    toPorts:
    - ports:
      - port: "8080"
        protocol: TCP
      rules:
        http:
        - method: POST
          path: "/payments.PaymentService/ProcessPayment"
          headers:
          - ":authority: payment-service.production.svc.cluster.local"
          - "content-type: application/grpc"
```

### Pod Deployment: Elimination of Sidecar Injector with Cilium Ambient Direct Socket Forwarding

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Injecting legacy sidecar containers inside pods managed by Cilium Ambient Mesh leads to duplicate TCP stack traversals, conflicting iptables NAT rules, proxy hairpin latency loops, and heavy memory overhead per pod.
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: order-processor
  namespace: production
spec:
  replicas: 3
  template:
    metadata:
      annotations:
        # Flaw: Injecting legacy Envoy sidecar causes packet duplication and hairpinning in eBPF datapath
        sidecar.istio.io/inject: "true"
      labels:
        app: order-processor
    spec:
      containers:
      - name: order-processor
        image: registry.internal/order-processor:v2.1.0
        ports:
        - containerPort: 8080
```

#### Production Standard (Correct)
> **Standard**: Explicitly disables legacy proxy injection while labeling the workload for Cilium ambient eBPF routing. Network traffic transitions through optimized in-kernel socket redirection (sockops) to node-level proxies and uses kernel cryptographic offload.
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: order-processor
  namespace: production
spec:
  replicas: 3
  template:
    metadata:
      annotations:
        # Ensure sidecar injectors are completely deactivated
        sidecar.istio.io/inject: "false"
        linkerd.io/inject: "disabled"
      labels:
        app: order-processor
        # Ambient eBPF routing hook enabled for the endpoint
        io.cilium.ambient: "enabled"
    spec:
      containers:
      - name: order-processor
        image: registry.internal/order-processor:v2.1.0
        ports:
        - containerPort: 8080
        securityContext:
          allowPrivilegeEscalation: false
          readOnlyRootFilesystem: true
          runAsNonRoot: true
          runAsUser: 10001
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Cilium Ambient eBPF Kernel-Level mTLS and L7 Policy Enforcement Standard

Cilium Ambient eBPF Kernel-Level mTLS and L7 Policy Enforcement Standard defines an industrial-grade behavioral standard for devops engineering. Enforces sidecarless kernel-level mutual TLS (mTLS) with SPIFFE/SPIRE authentication and deterministic Layer 7 traffic routing via eBPF sockops. Prohibits redundant per-pod proxy sidecars and ensures zero-trust CiliumNetworkPolicy manifests strictly bind L7 visibility to node-level Envoy proxies. 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: Permissive L7 Fallbacks and Redundant Application Sidecar Injections within eBPF Ambient Data Planes 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 DriftPermissive L7 Fallbacks and Redundant Application Sidecar Injections within eBPF Ambient Data PlanesCritical
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 strict mutual TLS through Cilium's native SPIFFE/SPIRE integration or WireGuard/IPsec in-kernel encapsulation, rejecting unauthenticated cleartext transport.

Engineers MUST ALWAYS enforce strict mutual TLS through Cilium's native SPIFFE/SPIRE integration or WireGuard/IPsec in-kernel encapsulation, rejecting unauthenticated cleartext transport.

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 NOT inject application-layer sidecars (e.g., Istio Envoy sidecars, Linkerd proxy containers) into pods governed by the Cilium ambient eBPF datapath.

Engineers MUST NOT inject application-layer sidecars (e.g., Istio Envoy sidecars, Linkerd proxy containers) into pods governed by the Cilium ambient eBPF datapath.

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

CiliumNetworkPolicy rules MUST explicitly define 'authentication.mode

CiliumNetworkPolicy rules MUST explicitly define 'authentication.mode: required' alongside SPIFFE trust domain IDs to guarantee identity verification prior to L7 protocol evaluation.

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

Layer 7 policies MUST explicitly scope HTTP, gRPC, or Kafka rules under target ports without falling back to wildcard permissive L4 listeners that bypass node Envoy filters.

Layer 7 policies MUST explicitly scope HTTP, gRPC, or Kafka rules under target ports without falling back to wildcard permissive L4 listeners that bypass node Envoy filters.

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

Deployments and Namespaces MUST be annotated with 'cilium.io/ambient-mesh

Deployments and Namespaces MUST be annotated with 'cilium.io/ambient-mesh: enabled' (or cluster-equivalent injection disablement) and verified against socket-level BPF program attach states (BPF sock_ops).

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 NEVER rely on standard Kubernetes NetworkPolicy resources for L7 enforcement, as K8s native resources lack eBPF-accelerated HTTP/gRPC parsing capabilities.

Network policies MUST NEVER rely on standard Kubernetes NetworkPolicy resources for L7 enforcement, as K8s native resources lack eBPF-accelerated HTTP/gRPC parsing 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.
Technical Questions & Answers

Frequently Asked Technical Questions

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

Q:Why is Cilium Ambient eBPF Kernel-Level mTLS and L7 Policy Enforcement Standard critical for AI coding assistants?

Enforces sidecarless kernel-level mutual TLS (mTLS) with SPIFFE/SPIRE authentication and deterministic Layer 7 traffic routing via eBPF sockops. Prohibits redundant per-pod proxy sidecars and ensures zero-trust CiliumNetworkPolicy manifests strictly bind L7 visibility to node-level Envoy proxies. 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 (Permissive L7 Fallbacks and Redundant Application Sidecar Injections within eBPF Ambient Data Planes) 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

Cilium