This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: cilium-ebpf-zero-trust-socketops-production-standard

Cilium eBPF Socket-Level Mutual Authentication and WireGuard Invariant

Mandates in-kernel socket-level zero-trust mutual authentication and WireGuard encapsulation using Cilium eBPF, replacing legacy user-space sidecar proxies. Guarantees cryptographically attested pod identities and line-rate L3/L4/L7 policy enforcement without sidecar memory footprint, connection latency penalties, or bypass vulnerabilities.

Prohibited Anti-Pattern: Injecting memory-intensive user-space sidecars or relying on unencrypted, unauthenticated plain-text pod transit.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Socket-Level Mutual Authentication and WireGuard Invariant - Mandates in-kernel socket-level zero-trust mutual authentication and WireGuard encapsulation using Cilium eBPF, replacing legacy user-space sidecar proxies. Guarantees cryptographically attested pod identities and line-rate L3/L4/L7 policy enforcement without sidecar memory footprint, connection latency penalties, or bypass vulnerabilities.
globs: k8s/**/*.yaml, helm/**/*.yaml, deploy/**/*.yaml, cilium/**/*.yaml, infrastructure/**/*.tf
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-zero-trust-socketops-production-standard"
---

# Cilium eBPF Socket-Level Mutual Authentication and WireGuard Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Injecting memory-intensive user-space sidecars or relying on unencrypted, unauthenticated plain-text pod transit.

## System Constraints
You are a Principal Infrastructure & Security Architect enforcing Cilium eBPF Socket-Level Zero-Trust Mutual Authentication Invariants. You must ensure zero-trust pod identity and encryption are delegated to the Linux kernel via Cilium eBPF sockops and transparent WireGuard/IPsec tunnels. Reject sidecar-based mTLS architectures (Envoy/Istio sidecars) that induce compute bloat and socket traversal latency. Enforce strict CiliumNetworkPolicy/CiliumClusterwideNetworkPolicy resources with cryptographic identity verification, transparent encryption, and socket-level short-circuiting.

## Strict Guidelines
- Engineers MUST configure Cilium with transparent encryption enabled (`encryption.enabled=true`, `encryption.type=wireguard`) in Helm values or DaemonSet definitions.
- Engineers MUST enable socket-level eBPF load balancing and acceleration (`sockops.enabled=true`, `bpf.hostRouting=true`) to bypass unnecessary TCP/IP host stack hops for local endpoint routing.
- Engineers MUST declare explicit `CiliumNetworkPolicy` or `CiliumClusterwideNetworkPolicy` CRDs enforcing cryptographically verified endpoint labels, forbidding unauthenticated wildcard ingress/egress rules.
- Engineers MUST NOT inject Envoy sidecars (`istio-injection=enabled` or manual sidecar containers) for mTLS termination when Cilium eBPF mutual authentication is active.
- Policies MUST explicitly configure `authentication.mode` to enforce mutual authentication handshakes (e.g., SPIRE/mTLS authentication) for sensitive intra-cluster RPC communication.
- Services MUST enforce strict egress lockdown matching only required peer identities using `toEndpoints` with exact `k8s:io.kubernetes.pod.namespace` and service selector boundaries.
- Components NEVER fall back to standard unmanaged Linux bridge interfaces or unencrypted overlay networking for cross-node Pod traffic.

## Bad vs Good Implementations
### Kubernetes Pod & Policy: Legacy Sidecar Proxy vs. Cilium eBPF Zero-Trust Policy

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Injects an unneeded user-space Envoy sidecar proxy consuming hundreds of megabytes of RAM and adding socket-hop latency. Simultaneously relies on a naive Kubernetes NetworkPolicy that allows all unauthenticated CIDR traffic without cryptographic peer identity attestation or transparent in-kernel encryption.
```yaml
# INSECURE & RESOURCE INEFFICIENT: Legacy sidecar injection with unverified networking
apiVersion: apps/v1
kind: Deployment
metadata:
  name: payment-service
  namespace: core-banking
spec:
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "true"
    spec:
      containers:
        - name: app
          image: payment-service:v2.1.0
---
# Flawed NetworkPolicy: Missing mutual authentication and cryptographic verification
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-all-traffic
  namespace: core-banking
spec:
  podSelector: {}
  ingress:
    - from:
        - ipBlock:
            cidr: 0.0.0.0/0
```

#### Production Standard (Correct)
> **Standard**: Eliminates the sidecar proxy entirely, leaving identity management and encryption to the Cilium eBPF kernel layer. Employs a CiliumNetworkPolicy that enforces strict source pod namespace verification and mandates cryptographic mutual authentication (`authentication.mode: required`) over transparent WireGuard node tunnels.
```yaml
# HARDENED: Sidecarless zero-trust workload enforced at eBPF socket layer
apiVersion: apps/v1
kind: Deployment
metadata:
  name: payment-service
  namespace: core-banking
spec:
  template:
    metadata:
      labels:
        app.kubernetes.io/name: payment-service
        tier: backend
    spec:
      containers:
        - name: app
          image: payment-service:v2.1.0
---
# Secure Cilium eBPF Policy with mutual authentication invariant
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: secure-payment-service-auth
  namespace: core-banking
spec:
  endpointSelector:
    matchLabels:
      app.kubernetes.io/name: payment-service
  ingress:
    - fromEndpoints:
        - matchLabels:
            app.kubernetes.io/name: checkout-frontend
            "k8s:io.kubernetes.pod.namespace": checkout-system
      toPorts:
        - ports:
            - port: "8443"
              protocol: TCP
      authentication:
        mode: "required"
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Cilium eBPF Socket-Level Mutual Authentication and WireGuard Invariant

Cilium eBPF Socket-Level Mutual Authentication and WireGuard Invariant defines an industrial-grade behavioral standard for devops engineering. Mandates in-kernel socket-level zero-trust mutual authentication and WireGuard encapsulation using Cilium eBPF, replacing legacy user-space sidecar proxies. Guarantees cryptographically attested pod identities and line-rate L3/L4/L7 policy enforcement without sidecar memory footprint, connection latency penalties, or bypass vulnerabilities. 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: Injecting memory-intensive user-space sidecars or relying on unencrypted, unauthenticated plain-text pod transit. 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 DriftInjecting memory-intensive user-space sidecars or relying on unencrypted, unauthenticated plain-text pod transit.Critical
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 configure Cilium with transparent encryption enabled (`encryption.enabled=true`, `encryption.type=wireguard`) in Helm values or DaemonSet definitions.

Engineers MUST configure Cilium with transparent encryption enabled (`encryption.enabled=true`, `encryption.type=wireguard`) in Helm values or DaemonSet definitions.

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 enable socket-level eBPF load balancing and acceleration (`sockops.enabled=true`, `bpf.hostRouting=true`) to bypass unnecessary TCP/IP host stack hops for local endpoint routing.

Engineers MUST enable socket-level eBPF load balancing and acceleration (`sockops.enabled=true`, `bpf.hostRouting=true`) to bypass unnecessary TCP/IP host stack hops for local endpoint routing.

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 declare explicit `CiliumNetworkPolicy` or `CiliumClusterwideNetworkPolicy` CRDs enforcing cryptographically verified endpoint labels, forbidding unauthenticated wildcard ingress/egress rules.

Engineers MUST declare explicit `CiliumNetworkPolicy` or `CiliumClusterwideNetworkPolicy` CRDs enforcing cryptographically verified endpoint labels, forbidding unauthenticated wildcard ingress/egress rules.

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

Engineers MUST NOT inject Envoy sidecars (`istio-injection=enabled` or manual sidecar containers) for mTLS termination when Cilium eBPF mutual authentication is active.

Engineers MUST NOT inject Envoy sidecars (`istio-injection=enabled` or manual sidecar containers) for mTLS termination when Cilium eBPF mutual authentication is active.

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

Policies MUST explicitly configure `authentication.mode` to enforce mutual authentication handshakes (e.g., SPIRE/mTLS authentication) for sensitive intra-cluster RPC communication.

Policies MUST explicitly configure `authentication.mode` to enforce mutual authentication handshakes (e.g., SPIRE/mTLS authentication) for sensitive intra-cluster RPC communication.

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

Services MUST enforce strict egress lockdown matching only required peer identities using `toEndpoints` with exact `k8s

Services MUST enforce strict egress lockdown matching only required peer identities using `toEndpoints` with exact `k8s:io.kubernetes.pod.namespace` and service selector boundaries.

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.
7

Components NEVER fall back to standard unmanaged Linux bridge interfaces or unencrypted overlay networking for cross-node Pod traffic.

Components NEVER fall back to standard unmanaged Linux bridge interfaces or unencrypted overlay networking for cross-node Pod traffic.

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 Socket-Level Mutual Authentication and WireGuard Invariant critical for AI coding assistants?

Mandates in-kernel socket-level zero-trust mutual authentication and WireGuard encapsulation using Cilium eBPF, replacing legacy user-space sidecar proxies. Guarantees cryptographically attested pod identities and line-rate L3/L4/L7 policy enforcement without sidecar memory footprint, connection latency penalties, or bypass vulnerabilities. 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 (Injecting memory-intensive user-space sidecars or relying on unencrypted, unauthenticated plain-text pod transit.) 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