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

Cilium eBPF Socket-Level TCP Bypass with Kernel-Enforced mTLS Guardrail

Enforces Cilium sockops eBPF socket map shunting for east-west container communication without compromising kernel-level cryptographic identity fences. Ensures sockops programs correctly evaluate Cilium Network Policies (CNP) and mTLS handshakes before establishing direct socket redirection (sk_msg / BPF_MAP_TYPE_SOCKHASH).

Prohibited Anti-Pattern: Bypassing Kernel Network Stack and mTLS Handshakes via Premature sockops Redirection

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Socket-Level TCP Bypass with Kernel-Enforced mTLS Guardrail - Enforces Cilium sockops eBPF socket map shunting for east-west container communication without compromising kernel-level cryptographic identity fences. Ensures sockops programs correctly evaluate Cilium Network Policies (CNP) and mTLS handshakes before establishing direct socket redirection (sk_msg / BPF_MAP_TYPE_SOCKHASH).
globs: deploy/**/*.yaml, k8s/**/*.yaml, helm/**/*.yaml, charts/**/templates/*.yaml, infra/cilium/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-sockops-mtls-bypass-guardrail"
---

# Cilium eBPF Socket-Level TCP Bypass with Kernel-Enforced mTLS Guardrail

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Bypassing Kernel Network Stack and mTLS Handshakes via Premature sockops Redirection

## System Constraints
You are a Principal Systems and Platform Architect enforcing zero-trust microsegmentation using Cilium eBPF socket-level TCP acceleration (sockops/sk_msg). Your mandate is to prevent sockops map injection from bypassing Cilium Network Policy (CNP) enforcement, WireGuard/IPsec node-to-node encapsulation, or Envoy/SPIRE mTLS cryptographic verification. Every Cilium configuration and Helm manifest MUST guarantee that socket-level bypass only occurs AFTER pod identity assertion and session authentication.

## Strict Guidelines
- Engineers MUST ALWAYS configure `sockops.enabled: true` alongside strict Cilium Network Policies (`CiliumNetworkPolicy` or `CiliumClusterwideNetworkPolicy`) specifying cryptographic authentication via `authentication.mode: "mutual-tls"` or WireGuard integration.
- Engineers MUST NOT activate `sockops` in unconstrained host-networked environments where namespace transitions lack pod label identity verification in the BPF tail calls.
- Cilium manifests MUST enforce `bpf.masquerade: true` and `kubeProxyReplacement: "true"` when sockops is enabled to ensure conntrack state synchronizes between socket maps and TCP flow tables.
- Configurations MUST NEVER permit pod-to-pod sockops shunting across nodes unless eBPF native routing and underlying node encapsulation (Geneve/WireGuard) preserve Cilium security identities.
- Engineers MUST explicitly set `authentication.mutual.spire.enabled: true` or equivalent PKI integration when socket acceleration interacts with L7 microsegmentation policies.

## Bad vs Good Implementations
### Insecure Cilium DaemonSet Configuration Enabling sockops without Identity Guardrails

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Enabling sockops without strict kube-proxy replacement, unified BPF masquerading, and mutual TLS authentication creates an unauthenticated data path where packets bypass standard tc-eBPF firewall filters and L7 security inspectors, exposing workloads to arbitrary socket injection.
```yaml
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: cilium
  namespace: kube-system
spec:
  values:
    # FLUID VIOLATION: sockops bypasses stack without requiring mutual auth verification
    sockops:
      enabled: true
    kubeProxyReplacement: "partial"
    l7Proxy: false
    bpf:
      masquerade: false
    authentication:
      enabled: false
```

#### Production Standard (Correct)
> **Standard**: This configuration establishes complete eBPF kube-proxy replacement, native routing with WireGuard node encryption, and SPIRE-backed mTLS authentication. The sockops bypass accelerates payloads only after cryptographic authentication and identity checks pass in the eBPF datapath.
```yaml
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: cilium
  namespace: kube-system
spec:
  values:
    sockops:
      enabled: true
    kubeProxyReplacement: "true"
    routingMode: native
    ipv4NativeRoutingCIDR: 10.244.0.0/16
    bpf:
      masquerade: true
      tproxy: true
    encryption:
      enabled: true
      type: wireguard
    authentication:
      enabled: true
      mode: "mutual-tls"
      mutual:
        spire:
          enabled: true
          serverAddress: spire-server.spire.svc.cluster.local:8081
```

### CiliumNetworkPolicy Enforcing mTLS Fences with Socket-Level Acceleration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: This policy allows unauthenticated socket shortcuts between frontend and backend pods. A compromised frontend pod can bypass L7 inspection and identity validation via the kernel sockops table.
```yaml
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: secure-backend-access
  namespace: production
spec:
  endpointSelector:
    matchLabels:
      app: backend
  ingress:
  - fromEndpoints:
    - matchLabels:
        app: frontend
    toPorts:
    - ports:
      # FLUID VIOLATION: Plain TCP rule allows raw sockops hook to bridge sockets without mTLS validation
      - port: "8080"
        protocol: TCP
```

#### Production Standard (Correct)
> **Standard**: The policy enforces `authentication.mode: mutual-tls` and L7 application constraints. Cilium validates peer identities and executes the TLS handshake before shunting verified data frames via sockops maps, guaranteeing zero-trust microsegmentation at maximum throughput.
```yaml
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: secure-backend-access
  namespace: production
spec:
  endpointSelector:
    matchLabels:
      app: backend
  ingress:
  - fromEndpoints:
    - matchLabels:
        app: frontend
    authentication:
      mode: "mutual-tls"
    toPorts:
    - ports:
      - port: "8080"
        protocol: TCP
      rules:
        http:
        - method: POST
          path: "/api/v1/orders"
```

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 Socket-Level TCP Bypass with Kernel-Enforced mTLS Guardrail

Cilium eBPF Socket-Level TCP Bypass with Kernel-Enforced mTLS Guardrail defines an industrial-grade behavioral standard for devops engineering. Enforces Cilium sockops eBPF socket map shunting for east-west container communication without compromising kernel-level cryptographic identity fences. Ensures sockops programs correctly evaluate Cilium Network Policies (CNP) and mTLS handshakes before establishing direct socket redirection (sk_msg / BPF_MAP_TYPE_SOCKHASH). 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: Bypassing Kernel Network Stack and mTLS Handshakes via Premature sockops Redirection 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 DriftBypassing Kernel Network Stack and mTLS Handshakes via Premature sockops RedirectionCritical
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 configure `sockops.enabled

Engineers MUST ALWAYS configure `sockops.enabled: true` alongside strict Cilium Network Policies (`CiliumNetworkPolicy` or `CiliumClusterwideNetworkPolicy`) specifying cryptographic authentication via `authentication.mode: "mutual-tls"` or WireGuard integration.

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 activate `sockops` in unconstrained host-networked environments where namespace transitions lack pod label identity verification in the BPF tail calls.

Engineers MUST NOT activate `sockops` in unconstrained host-networked environments where namespace transitions lack pod label identity verification in the BPF tail calls.

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

Cilium manifests MUST enforce `bpf.masquerade

Cilium manifests MUST enforce `bpf.masquerade: true` and `kubeProxyReplacement: "true"` when sockops is enabled to ensure conntrack state synchronizes between socket maps and TCP flow tables.

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

Configurations MUST NEVER permit pod-to-pod sockops shunting across nodes unless eBPF native routing and underlying node encapsulation (Geneve/WireGuard) preserve Cilium security identities.

Configurations MUST NEVER permit pod-to-pod sockops shunting across nodes unless eBPF native routing and underlying node encapsulation (Geneve/WireGuard) preserve Cilium 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.
5

Engineers MUST explicitly set `authentication.mutual.spire.enabled

Engineers MUST explicitly set `authentication.mutual.spire.enabled: true` or equivalent PKI integration when socket acceleration interacts with L7 microsegmentation policies.

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 TCP Bypass with Kernel-Enforced mTLS Guardrail critical for AI coding assistants?

Enforces Cilium sockops eBPF socket map shunting for east-west container communication without compromising kernel-level cryptographic identity fences. Ensures sockops programs correctly evaluate Cilium Network Policies (CNP) and mTLS handshakes before establishing direct socket redirection (sk_msg / BPF_MAP_TYPE_SOCKHASH). 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 (Bypassing Kernel Network Stack and mTLS Handshakes via Premature sockops Redirection) 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