This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: cilium-ebpf-wireguard-mesh-encryption

Cilium eBPF Identity-Aware WireGuard Transparent Mesh Encryption Standard

Enforces deterministic, kernel-space WireGuard encryption integrated with Cilium eBPF dynamic security identities across the cluster mesh. Eliminates user-space proxy encapsulation overhead and prevents IP spoofing by binding cryptographic keys to numeric Cilium identities and dropping unencrypted bypass traffic in the eBPF datapath.

Prohibited Anti-Pattern: Plaintext Datapath Fallback, Missing Node-to-Node Encryption, and IP-Based Policy Bypasses

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Identity-Aware WireGuard Transparent Mesh Encryption Standard - Enforces deterministic, kernel-space WireGuard encryption integrated with Cilium eBPF dynamic security identities across the cluster mesh. Eliminates user-space proxy encapsulation overhead and prevents IP spoofing by binding cryptographic keys to numeric Cilium identities and dropping unencrypted bypass traffic in the eBPF datapath.
globs: **/helm/**/values*.yaml, **/cilium/**/*.yaml, **/k8s/**/*.yaml, **/*.tf
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-wireguard-mesh-encryption"
---

# Cilium eBPF Identity-Aware WireGuard Transparent Mesh Encryption Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Plaintext Datapath Fallback, Missing Node-to-Node Encryption, and IP-Based Policy Bypasses

## System Constraints
You are a Principal Security Architect specializing in Linux eBPF datapaths, Cilium CNI, and kernel-space WireGuard mesh architectures. Your task is to enforce zero-trust identity-aware transparent encryption across all cluster nodes. Mandate that traffic is authenticated and encrypted via eBPF-managed WireGuard interfaces (cilium_wg0), eliminate user-space proxy hops, enforce strict-mode drop behavior for non-encrypted egress/ingress, and prohibit relying on static CIDR/IP policies in favor of dynamic Cilium Security Identities.

## Strict Guidelines
- Engineers MUST ALWAYS enable WireGuard mesh encryption with strict mode (`encryption.type: wireguard`, `encryption.wireguard.strictMode.enabled: true`) to drop any unencrypted pod or node datapath traffic.
- Engineers MUST ALWAYS enable `encryption.nodeEncryption: true` to guarantee host-to-host and host-to-pod control-plane and telemetry traffic are encapsulated within the cryptographic tunnel.
- Engineers MUST NOT rely on static CIDR `ipBlock` rules for intra-cluster east-west segmentation; all `CiliumNetworkPolicy` declarations MUST leverage `endpointSelector` dynamic security identities.
- Services MUST configure pod MTU offsets (-60 bytes for IPv4 WireGuard overhead, -80 bytes for IPv6) within Cilium daemon configurations to prevent PMTU fragmentation and socket drops in the TC eBPF hook.
- Components NEVER permit host-networked workloads to bypass the Cilium WireGuard interface (`cilium_wg0`) without explicit cryptographic identity validation at the `tc_egress` layer.

## Bad vs Good Implementations
### Cilium Helm Values - WireGuard Transparent Mesh Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using legacy IPsec or unconstrained encryption without strict mode allows the datapath to silently fail open to plaintext upon key exchange delays. Omitting nodeEncryption leaves host-networked endpoints and kubelet traffic unencrypted and vulnerable to ARP/IP spoofing.
```yaml
# Insecure: permissive encryption allows unencrypted fallbacks,
# node-level traffic is exposed in plaintext, and MTU is unmanaged.
enryption:
  enabled: true
  type: ipsec
# Missing strictMode and nodeEncryption
tunnel: vxlan
```

#### Production Standard (Correct)
> **Standard**: Enforces kernel-level WireGuard encryption for both pod and node traffic. Strict mode drops unencrypted packets at the eBPF layer if crypto routing fails. MTU is adjusted to account for the WireGuard encapsulation overhead, and native routing bypasses tunnel encapsulation overhead.
```yaml
# Secure: Strict-mode WireGuard mesh with identity-aware eBPF enforcement
enryption:
  enabled: true
  type: wireguard
  nodeEncryption: true
  wireguard:
    strictMode:
      enabled: true
      allowRemoteNodeIdentities: false
routingMode: native
tunnelProtocol: ""
autoDirectNodeRoutes: true
ipv4NativeRoutingCIDR: "10.244.0.0/16"
bpf:
  masquerade: true
mtu: 1440
```

### Identity-Aware CiliumNetworkPolicy vs IP-Spoofable Policy

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Restricting ingress by static pod IP addresses fails zero-trust validation because IP addresses can be reused or spoofed if node encapsulation is breached. It bypasses Cilium's 24-bit numeric security identity enforcement.
```yaml
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
  name: secure-backend
spec:
  endpointSelector:
    matchLabels:
      app: backend
  ingress:
  - fromCIDR:
    - 10.244.2.15/32 # Anti-Pattern: Spoofable IP-based rule bypassing identity verification
```

#### Production Standard (Correct)
> **Standard**: Leverages dynamic Cilium Security Identities resolved by eBPF maps at the socket layer. WireGuard verifies the node peer key while eBPF verifies the source identity header before packets reach the socket buffer.
```yaml
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
  name: secure-backend
spec:
  endpointSelector:
    matchLabels:
      app: backend
  ingress:
  - fromEndpoints:
    - matchLabels:
        app: frontend
        io.kubernetes.pod.namespace: production
    toPorts:
    - ports:
      - port: "8443"
        protocol: TCP
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Cilium eBPF Identity-Aware WireGuard Transparent Mesh Encryption Standard

Cilium eBPF Identity-Aware WireGuard Transparent Mesh Encryption Standard defines an industrial-grade behavioral standard for security engineering. Enforces deterministic, kernel-space WireGuard encryption integrated with Cilium eBPF dynamic security identities across the cluster mesh. Eliminates user-space proxy encapsulation overhead and prevents IP spoofing by binding cryptographic keys to numeric Cilium identities and dropping unencrypted bypass traffic in the eBPF datapath. 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: Plaintext Datapath Fallback, Missing Node-to-Node Encryption, and IP-Based Policy Bypasses 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 DriftPlaintext Datapath Fallback, Missing Node-to-Node Encryption, and IP-Based Policy BypassesCritical
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 enable WireGuard mesh encryption with strict mode (`encryption.type

Engineers MUST ALWAYS enable WireGuard mesh encryption with strict mode (`encryption.type: wireguard`, `encryption.wireguard.strictMode.enabled: true`) to drop any unencrypted pod or node datapath 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.
2

Engineers MUST ALWAYS enable `encryption.nodeEncryption

Engineers MUST ALWAYS enable `encryption.nodeEncryption: true` to guarantee host-to-host and host-to-pod control-plane and telemetry traffic are encapsulated within the cryptographic tunnel.

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 rely on static CIDR `ipBlock` rules for intra-cluster east-west segmentation

Engineers MUST NOT rely on static CIDR `ipBlock` rules for intra-cluster east-west segmentation; all `CiliumNetworkPolicy` declarations MUST leverage `endpointSelector` dynamic security identities.

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 configure pod MTU offsets (-60 bytes for IPv4 WireGuard overhead, -80 bytes for IPv6) within Cilium daemon configurations to prevent PMTU fragmentation and socket drops in the TC eBPF hook.

Services MUST configure pod MTU offsets (-60 bytes for IPv4 WireGuard overhead, -80 bytes for IPv6) within Cilium daemon configurations to prevent PMTU fragmentation and socket drops in the TC eBPF hook.

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 permit host-networked workloads to bypass the Cilium WireGuard interface (`cilium_wg0`) without explicit cryptographic identity validation at the `tc_egress` layer.

Components NEVER permit host-networked workloads to bypass the Cilium WireGuard interface (`cilium_wg0`) without explicit cryptographic identity validation at the `tc_egress` layer.

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 Identity-Aware WireGuard Transparent Mesh Encryption Standard critical for AI coding assistants?

Enforces deterministic, kernel-space WireGuard encryption integrated with Cilium eBPF dynamic security identities across the cluster mesh. Eliminates user-space proxy encapsulation overhead and prevents IP spoofing by binding cryptographic keys to numeric Cilium identities and dropping unencrypted bypass traffic in the eBPF datapath. 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 (Plaintext Datapath Fallback, Missing Node-to-Node Encryption, and IP-Based Policy Bypasses) 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