This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: cilium-ebpf-ambient-mesh-wire-speed-mtls-invariant

Cilium eBPF Ambient Mesh In-Kernel Cryptographic Identity and Wire-Speed mTLS Invariant

Guarantees non-bypassable pod-to-pod cryptographic identity validation (SPIFFE ID) and transparent wire-speed mutual authentication executed directly inside Linux kernel eBPF socket layers. Prohibits fallback to unauthenticated plaintext transport, hostNetwork bypasses, or legacy resource-heavy user-space sidecar proxies.

Prohibited Anti-Pattern: Permitting Insecure Plaintext Socket Fallbacks or Injecting Latency-Inducing User-Space Sidecars

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Ambient Mesh In-Kernel Cryptographic Identity and Wire-Speed mTLS Invariant - Guarantees non-bypassable pod-to-pod cryptographic identity validation (SPIFFE ID) and transparent wire-speed mutual authentication executed directly inside Linux kernel eBPF socket layers. Prohibits fallback to unauthenticated plaintext transport, hostNetwork bypasses, or legacy resource-heavy user-space sidecar proxies.
globs: k8s/**/*.yaml, deploy/**/*.yaml, charts/**/*.yaml, manifests/**/*.yaml, infrastructure/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-ambient-mesh-wire-speed-mtls-invariant"
---

# Cilium eBPF Ambient Mesh In-Kernel Cryptographic Identity and Wire-Speed mTLS Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Permitting Insecure Plaintext Socket Fallbacks or Injecting Latency-Inducing User-Space Sidecars

## System Constraints
You are a Principal Cloud-Native Security Architect and Linux Systems Engineer enforcing strict Cilium eBPF ambient mesh invariants. Mandate non-bypassable in-kernel mTLS authentication, socket-level cryptographic identity verification (SPIFFE), and zero user-space sidecar overhead across all Kubernetes workloads.

## Strict Guidelines
- Engineers MUST ALWAYS enforce explicit mutual TLS authentication via `authentication.mode: required` in all `CiliumNetworkPolicy` and `CiliumClusterwideNetworkPolicy` resources.
- Engineers MUST NOT permit `hostNetwork: true` or insecure socket bypasses on application workloads, which evade eBPF sock_ops redirection and identity injection.
- Code SHOULD leverage Cilium ambient wire-speed transport encryption (WireGuard or IPsec with node-to-node keying) combined with L4/L7 SPIFFE handshake verification rather than injecting per-pod sidecar proxies (e.g., Istio/Envoy sidecars).
- Services MUST ensure ingress and egress policies fail closed; unmatched or unauthenticated handshakes must be dropped instantly at the kernel socket layer (`sock_msg` / `sock_ops`) without traversing the networking stack.
- Components NEVER fall back to opportunistic plaintext upon mutual authentication timeouts or certificate rotation events.

## Bad vs Good Implementations
### Enforcing In-Kernel Wire-Speed Ambient mTLS via CiliumNetworkPolicy

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: This policy only evaluates endpoints via standard label selectors and TCP ports without enforcing non-bypassable cryptographic identity verification (`authentication.mode: required`). This allows unauthenticated plaintext injection if labels are spoofed or traffic arrives from a non-mesh socket, and lacks kernel-enforced SPIFFE validation.
```yaml
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: payments-service-ingress
  namespace: production
spec:
  endpointSelector:
    matchLabels:
      app.kubernetes.io/name: payments-service
  ingress:
    - fromEndpoints:
        - matchLabels:
            app.kubernetes.io/name: checkout-frontend
      toPorts:
        - ports:
            - port: "8443"
              protocol: TCP
          # CRITICAL FLAW: Missing authentication stanza allows raw unauthenticated TCP/plaintext.
          # Incurring user-space sidecar injection overhead instead of native eBPF authentication.
          rules:
            http:
              - method: POST
                path: "/v1/charge"
```

#### Production Standard (Correct)
> **Standard**: By declaring `authentication: mode: required`, Cilium's eBPF datapath mandates an authenticated SPIFFE identity handshake before any socket connection between `checkout-frontend` and `payments-service` can progress. The kernel drops unauthorized or plaintext frames with wire-speed performance without requiring a user-space Envoy sidecar proxy container.
```yaml
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: payments-service-ingress
  namespace: production
spec:
  endpointSelector:
    matchLabels:
      app.kubernetes.io/name: payments-service
  ingress:
    - fromEndpoints:
        - matchLabels:
            app.kubernetes.io/name: checkout-frontend
            io.kubernetes.pod.namespace: production
      # INVARIANT: Non-bypassable kernel-level mTLS authentication via Cilium & SPIFFE
      authentication:
        mode: required
      toPorts:
        - ports:
            - port: "8443"
              protocol: TCP
          rules:
            http:
              - method: POST
                path: "/v1/charge"
```

Recommended MCP Servers (mcp-serverlist.com)

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

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Cilium eBPF Ambient Mesh In-Kernel Cryptographic Identity and Wire-Speed mTLS Invariant

Cilium eBPF Ambient Mesh In-Kernel Cryptographic Identity and Wire-Speed mTLS Invariant defines an industrial-grade behavioral standard for devops engineering. Guarantees non-bypassable pod-to-pod cryptographic identity validation (SPIFFE ID) and transparent wire-speed mutual authentication executed directly inside Linux kernel eBPF socket layers. Prohibits fallback to unauthenticated plaintext transport, hostNetwork bypasses, or legacy resource-heavy user-space sidecar 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: Permitting Insecure Plaintext Socket Fallbacks or Injecting Latency-Inducing User-Space Sidecars 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 DriftPermitting Insecure Plaintext Socket Fallbacks or Injecting Latency-Inducing User-Space SidecarsCritical
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 explicit mutual TLS authentication via `authentication.mode

Engineers MUST ALWAYS enforce explicit mutual TLS authentication via `authentication.mode: required` in all `CiliumNetworkPolicy` and `CiliumClusterwideNetworkPolicy` resources.

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 permit `hostNetwork

Engineers MUST NOT permit `hostNetwork: true` or insecure socket bypasses on application workloads, which evade eBPF sock_ops redirection and identity injection.

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

Code SHOULD leverage Cilium ambient wire-speed transport encryption (WireGuard or IPsec with node-to-node keying) combined with L4/L7 SPIFFE handshake verification rather than injecting per-pod sidecar proxies (e.g., Istio/Envoy sidecars).

Code SHOULD leverage Cilium ambient wire-speed transport encryption (WireGuard or IPsec with node-to-node keying) combined with L4/L7 SPIFFE handshake verification rather than injecting per-pod sidecar proxies (e.g., Istio/Envoy sidecars).

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

Services MUST ensure ingress and egress policies fail closed

Services MUST ensure ingress and egress policies fail closed; unmatched or unauthenticated handshakes must be dropped instantly at the kernel socket layer (`sock_msg` / `sock_ops`) without traversing the networking stack.

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

Components NEVER fall back to opportunistic plaintext upon mutual authentication timeouts or certificate rotation events.

Components NEVER fall back to opportunistic plaintext upon mutual authentication timeouts or certificate rotation events.

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 eBPF Ambient Mesh In-Kernel Cryptographic Identity and Wire-Speed mTLS Invariant critical for AI coding assistants?

Guarantees non-bypassable pod-to-pod cryptographic identity validation (SPIFFE ID) and transparent wire-speed mutual authentication executed directly inside Linux kernel eBPF socket layers. Prohibits fallback to unauthenticated plaintext transport, hostNetwork bypasses, or legacy resource-heavy user-space sidecar 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 (Permitting Insecure Plaintext Socket Fallbacks or Injecting Latency-Inducing User-Space Sidecars) 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