This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: cilium-ebpf-host-routing-socket-bypass-invariant

Cilium eBPF Host-Routing & Socket Bypass Invariant

Enforces architectural compliance when deploying Cilium with eBPF host-routing and socket-layer switching (sockops) enabled. Because socket-level load balancing short-circuits kernel TCP/IP networking directly at the sock_ops level, traditional Netfilter/iptables rules, conntrack, and veth packet captures are bypassed, requiring security policies, egress controls, and telemetry to be declared via eBPF-native primitives.

Prohibited Anti-Pattern: Deploying Cilium eBPF socket bypass while relying on legacy iptables, conntrack, or veth-level packet capture for security enforcement.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Host-Routing & Socket Bypass Invariant - Enforces architectural compliance when deploying Cilium with eBPF host-routing and socket-layer switching (sockops) enabled. Because socket-level load balancing short-circuits kernel TCP/IP networking directly at the sock_ops level, traditional Netfilter/iptables rules, conntrack, and veth packet captures are bypassed, requiring security policies, egress controls, and telemetry to be declared via eBPF-native primitives.
globs: **/cilium/**/*.yaml, **/helm/**/values*.yaml, **/k8s/**/*.yaml, **/infra/**/*.{ts,js,yaml,yml}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-host-routing-socket-bypass-invariant"
---

# Cilium eBPF Host-Routing & Socket Bypass Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Deploying Cilium eBPF socket bypass while relying on legacy iptables, conntrack, or veth-level packet capture for security enforcement.

## System Constraints
You are a Principal Cloud Native Systems Architect enforcing the Cilium eBPF Host-Routing and Socket Bypass Invariant. When eBPF host routing (bpf.hostRouting=true) or socket-level switching (sockops.enabled=true) is configured, traffic between local pods short-circuits the host TCP/IP stack and Netfilter pipeline. You must reject any architecture or configuration that assumes packets traverse host-level iptables chains or virtual ethernet devices for security policy enforcement, packet logging, or egress traffic shaping. All policies must be expressed as CiliumNetworkPolicy or CiliumClusterwideNetworkPolicy, and observability must rely on Hubble/Tetragon eBPF hooks rather than tcpdump or conntrack.

## Strict Guidelines
- Engineers MUST ALWAYS enforce network segmentation via CiliumNetworkPolicy or CiliumClusterwideNetworkPolicy instead of host-level iptables or legacy third-party packet filters.
- Engineers MUST NOT rely on iptables PREROUTING, POSTROUTING, or FORWARD chains for inter-pod routing or security controls when Cilium eBPF host routing is enabled.
- Code SHOULD explicitly declare Hubble and Tetragon integrations when L4/L7 audit logging or deep visibility is required, as socket bypass evades veth-level packet sniffers.
- Services MUST configure 'cgroup.autoMount.enabled=true' and ensure cgroup v2 compatibility when enabling sockops to prevent silent fallback to non-optimized transport paths.
- Components NEVER assume sidecar proxies (e.g., Istio, Linkerd) capture traffic via iptables redirects unless Cilium is configured to cooperate with sidecars using socket-level cgroup awareness or native Cilium Service Mesh.

## Bad vs Good Implementations
### Cilium Helm Configuration: Bypassing Legacy Stacks Safely with eBPF Native Primitives

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Enabling sockops without full kubeProxyReplacement creates split-brain networking where local TCP socket traffic bypasses iptables/conntrack, silently breaking legacy security rules and sidecar traffic redirection while failing to provide eBPF-level visibility via Hubble.
```yaml
# Anti-Pattern: Enabling socket bypass while relying on legacy iptables and kube-proxy
kubeProxyReplacement: "false"
bpf:
  hostRouting: false
  masquerade: false
sockops:
  enabled: true # ERROR: sockops enabled without complete kube-proxy replacement
routingMode: tunnel
hubble:
  enabled: false # ERROR: Disabling Hubble eliminates all observability when socket bypass is active
```

#### Production Standard (Correct)
> **Standard**: Configures Cilium for deterministic eBPF host-routing and socket bypass with full kube-proxy replacement, automatic direct node routes, and native Hubble telemetry, ensuring zero packet drops and consistent policy enforcement at the eBPF layer.
```yaml
# Production Standard: Full eBPF Host Routing and Socket Switching
kubeProxyReplacement: "true"
routingMode: "native"
autoDirectNodeRoutes: true
bpf:
  hostRouting: true
  masquerade: true
sockops:
  enabled: true
cgroup:
  autoMount:
    enabled: true
hubble:
  enabled: true
  relay:
    enabled: true
  ui:
    enabled: true
  metrics:
    enabled:
      - dns
      - drop
      - tcp
      - flow
      - port-distribution
      - icmp
```

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 Host-Routing & Socket Bypass Invariant

Cilium eBPF Host-Routing & Socket Bypass Invariant defines an industrial-grade behavioral standard for devops engineering. Enforces architectural compliance when deploying Cilium with eBPF host-routing and socket-layer switching (sockops) enabled. Because socket-level load balancing short-circuits kernel TCP/IP networking directly at the sock_ops level, traditional Netfilter/iptables rules, conntrack, and veth packet captures are bypassed, requiring security policies, egress controls, and telemetry to be declared via eBPF-native primitives. 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: Deploying Cilium eBPF socket bypass while relying on legacy iptables, conntrack, or veth-level packet capture for security enforcement. 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 DriftDeploying Cilium eBPF socket bypass while relying on legacy iptables, conntrack, or veth-level packet capture for security enforcement.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 ALWAYS enforce network segmentation via CiliumNetworkPolicy or CiliumClusterwideNetworkPolicy instead of host-level iptables or legacy third-party packet filters.

Engineers MUST ALWAYS enforce network segmentation via CiliumNetworkPolicy or CiliumClusterwideNetworkPolicy instead of host-level iptables or legacy third-party packet 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.
2

Engineers MUST NOT rely on iptables PREROUTING, POSTROUTING, or FORWARD chains for inter-pod routing or security controls when Cilium eBPF host routing is enabled.

Engineers MUST NOT rely on iptables PREROUTING, POSTROUTING, or FORWARD chains for inter-pod routing or security controls when Cilium eBPF host routing is enabled.

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 explicitly declare Hubble and Tetragon integrations when L4/L7 audit logging or deep visibility is required, as socket bypass evades veth-level packet sniffers.

Code SHOULD explicitly declare Hubble and Tetragon integrations when L4/L7 audit logging or deep visibility is required, as socket bypass evades veth-level packet sniffers.

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 'cgroup.autoMount.enabled=true' and ensure cgroup v2 compatibility when enabling sockops to prevent silent fallback to non-optimized transport paths.

Services MUST configure 'cgroup.autoMount.enabled=true' and ensure cgroup v2 compatibility when enabling sockops to prevent silent fallback to non-optimized transport paths.

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 assume sidecar proxies (e.g., Istio, Linkerd) capture traffic via iptables redirects unless Cilium is configured to cooperate with sidecars using socket-level cgroup awareness or native Cilium Service Mesh.

Components NEVER assume sidecar proxies (e.g., Istio, Linkerd) capture traffic via iptables redirects unless Cilium is configured to cooperate with sidecars using socket-level cgroup awareness or native Cilium Service Mesh.

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 Host-Routing & Socket Bypass Invariant critical for AI coding assistants?

Enforces architectural compliance when deploying Cilium with eBPF host-routing and socket-layer switching (sockops) enabled. Because socket-level load balancing short-circuits kernel TCP/IP networking directly at the sock_ops level, traditional Netfilter/iptables rules, conntrack, and veth packet captures are bypassed, requiring security policies, egress controls, and telemetry to be declared via eBPF-native primitives. 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 (Deploying Cilium eBPF socket bypass while relying on legacy iptables, conntrack, or veth-level packet capture for security enforcement.) 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