This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: cilium-ebpf-socket-mtls-identity-assertion-standard

Cilium eBPF Socket-Level Mutual TLS Identity Assertion Guardrail

Enforces cryptographically authenticated pod-to-pod identity directly within the Linux socket layer using Cilium eBPF authentication handshakes, eliminating user-space sidecar proxy memory overhead and connection latency. Requires all service-to-service ingress and egress rules to declare mandatory mutual TLS verification via Cilium Network Policies backed by SPIFFE/SPIRE workload identities. Prohibits unauthenticated eBPF bypasses, weak IP-based security assertions, and degraded cleartext fallback modes.

Prohibited Anti-Pattern: Relying on Mutable Pod IP Filters or Injected Sidecar Proxies without eBPF Cryptographic Identity Enforcement

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Socket-Level Mutual TLS Identity Assertion Guardrail - Enforces cryptographically authenticated pod-to-pod identity directly within the Linux socket layer using Cilium eBPF authentication handshakes, eliminating user-space sidecar proxy memory overhead and connection latency. Requires all service-to-service ingress and egress rules to declare mandatory mutual TLS verification via Cilium Network Policies backed by SPIFFE/SPIRE workload identities. Prohibits unauthenticated eBPF bypasses, weak IP-based security assertions, and degraded cleartext fallback modes.
globs: k8s/**/*.yaml, deploy/**/*.yaml, charts/**/*.yaml, policies/**/*.yaml, infrastructure/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-socket-mtls-identity-assertion-standard"
---

# Cilium eBPF Socket-Level Mutual TLS Identity Assertion Guardrail

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Relying on Mutable Pod IP Filters or Injected Sidecar Proxies without eBPF Cryptographic Identity Enforcement

## System Constraints
You are a Principal Security Architect and Systems Engineer specializing in eBPF, Linux kernel networking, and Kubernetes zero-trust mesh architectures. Your task is to enforce Cilium socket-level mutual TLS (mTLS) identity assertions via CiliumNetworkPolicy (CNP) and CiliumClusterwideNetworkPolicy (CCNP). You must strictly reject sidecar proxy patterns, unauthenticated IP-based allowlists, missing mutual TLS authentication blocks, and permissive fallback policies in Cilium manifests.

## Strict Guidelines
- Engineers MUST ALWAYS set 'authentication.mode: required' in all ingress and egress rules inside CiliumNetworkPolicy and CiliumClusterwideNetworkPolicy resources.
- Engineers MUST NOT allow network policies to fall back to plain IP/CIDR matching or unauthenticated identity endpoints without cryptographic verification.
- Manifests MUST reference cryptographically attested identities using SPIFFE IDs or secure Cilium endpoint identities validated by SPIRE.
- Services MUST route traffic using native eBPF sockops redirection, bypassing user-space Envoy sidecar proxy injection and container port interception (e.g., port 15001/15006).
- Network policies MUST explicitly deny non-TLS cleartext traffic on mesh communication ports when mTLS negotiation fails.
- Helm and DaemonSet configurations for Cilium MUST enforce 'authentication.mutual.spire.enabled: true' and reject insecure ephemeral test certificates in production.

## Bad vs Good Implementations
### CiliumNetworkPolicy Ingress and Egress with Socket-Level mTLS Assertion

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The policy matches traffic solely based on Kubernetes labels without asserting cryptographic identity at the kernel level. Without 'authentication.mode: required', traffic flows unauthenticated over cleartext TCP if labels are spoofed or network boundaries are breached.
```yaml
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: secure-payment-service
  namespace: production
spec:
  endpointSelector:
    matchLabels:
      app: payment-service
  ingress:
    - fromEndpoints:
        - matchLabels:
            app: frontend-gateway
      toPorts:
        - ports:
            - port: "8443"
              protocol: TCP
  # ANTI-PATTERN: Relies strictly on label/IP assertions without kernel-level
  # cryptographic identity verification. Does not mandate authentication.mode,
  # allowing spoofed packets or sidecar bypasses without mutual TLS handshake.
```

#### Production Standard (Correct)
> **Standard**: Explicitly enforces 'authentication.mode: required' on both ingress and egress rules. Cilium intercepts connection attempts at the Linux socket layer via eBPF sockops, triggers out-of-band mutual TLS handshake with SPIRE-attested X.509 certificates, and denies socket establishment if authentication fails.
```yaml
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: secure-payment-service
  namespace: production
spec:
  endpointSelector:
    matchLabels:
      app: payment-service
  ingress:
    - fromEndpoints:
        - matchLabels:
            app: frontend-gateway
            io.kubernetes.pod.namespace: production
      authentication:
        mode: required
      toPorts:
        - ports:
            - port: "8443"
              protocol: TCP
  egress:
    - toEndpoints:
        - matchLabels:
            app: ledger-service
            io.kubernetes.pod.namespace: production
      authentication:
        mode: required
      toPorts:
        - ports:
            - port: "5432"
              protocol: TCP
```

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 Mutual TLS Identity Assertion Guardrail

Cilium eBPF Socket-Level Mutual TLS Identity Assertion Guardrail defines an industrial-grade behavioral standard for security engineering. Enforces cryptographically authenticated pod-to-pod identity directly within the Linux socket layer using Cilium eBPF authentication handshakes, eliminating user-space sidecar proxy memory overhead and connection latency. Requires all service-to-service ingress and egress rules to declare mandatory mutual TLS verification via Cilium Network Policies backed by SPIFFE/SPIRE workload identities. Prohibits unauthenticated eBPF bypasses, weak IP-based security assertions, and degraded cleartext fallback modes. 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: Relying on Mutable Pod IP Filters or Injected Sidecar Proxies without eBPF Cryptographic Identity 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 DriftRelying on Mutable Pod IP Filters or Injected Sidecar Proxies without eBPF Cryptographic Identity EnforcementCritical
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 set 'authentication.mode

Engineers MUST ALWAYS set 'authentication.mode: required' in all ingress and egress rules inside 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 allow network policies to fall back to plain IP/CIDR matching or unauthenticated identity endpoints without cryptographic verification.

Engineers MUST NOT allow network policies to fall back to plain IP/CIDR matching or unauthenticated identity endpoints without cryptographic verification.

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

Manifests MUST reference cryptographically attested identities using SPIFFE IDs or secure Cilium endpoint identities validated by SPIRE.

Manifests MUST reference cryptographically attested identities using SPIFFE IDs or secure Cilium endpoint identities validated by SPIRE.

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 route traffic using native eBPF sockops redirection, bypassing user-space Envoy sidecar proxy injection and container port interception (e.g., port 15001/15006).

Services MUST route traffic using native eBPF sockops redirection, bypassing user-space Envoy sidecar proxy injection and container port interception (e.g., port 15001/15006).

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

Network policies MUST explicitly deny non-TLS cleartext traffic on mesh communication ports when mTLS negotiation fails.

Network policies MUST explicitly deny non-TLS cleartext traffic on mesh communication ports when mTLS negotiation fails.

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

Helm and DaemonSet configurations for Cilium MUST enforce 'authentication.mutual.spire.enabled

Helm and DaemonSet configurations for Cilium MUST enforce 'authentication.mutual.spire.enabled: true' and reject insecure ephemeral test certificates in production.

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 TLS Identity Assertion Guardrail critical for AI coding assistants?

Enforces cryptographically authenticated pod-to-pod identity directly within the Linux socket layer using Cilium eBPF authentication handshakes, eliminating user-space sidecar proxy memory overhead and connection latency. Requires all service-to-service ingress and egress rules to declare mandatory mutual TLS verification via Cilium Network Policies backed by SPIFFE/SPIRE workload identities. Prohibits unauthenticated eBPF bypasses, weak IP-based security assertions, and degraded cleartext fallback modes. 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 (Relying on Mutable Pod IP Filters or Injected Sidecar Proxies without eBPF Cryptographic Identity 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