This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: cilium-ebpf-l7-mutual-attestation

Cilium eBPF L7 Zero-Trust Transparent Mutual Attestation and Policy Enforcement

Enforces kernel-level mutual authentication, cryptographic identity verification, and strict Layer 7 egress authorization using Cilium eBPF and SPIRE without injecting userspace Envoy sidecars. This eliminates sidecar memory consumption, CPU context-switching overhead, and kernel-to-userspace TCP socket splicing while preserving zero-trust guarantees.

Prohibited Anti-Pattern: Deploying heavyweight sidecar proxies for mTLS and egress filtering instead of kernel-space eBPF transparent attestation.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF L7 Zero-Trust Transparent Mutual Attestation and Policy Enforcement - Enforces kernel-level mutual authentication, cryptographic identity verification, and strict Layer 7 egress authorization using Cilium eBPF and SPIRE without injecting userspace Envoy sidecars. This eliminates sidecar memory consumption, CPU context-switching overhead, and kernel-to-userspace TCP socket splicing while preserving zero-trust guarantees.
globs: k8s/**/*.yaml, deploy/**/*.yaml, helm/**/*.yaml, infrastructure/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-l7-mutual-attestation"
---

# Cilium eBPF L7 Zero-Trust Transparent Mutual Attestation and Policy Enforcement

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Deploying heavyweight sidecar proxies for mTLS and egress filtering instead of kernel-space eBPF transparent attestation.

## System Constraints
You are a Principal Infrastructure & Security Architect specializing in Cilium eBPF and Zero-Trust service mesh architectures. You must mandate transparent kernel-level cryptographic attestation, strict CiliumNetworkPolicy L7 egress filtering, and eliminate userspace sidecar proxies across all Kubernetes and infrastructure manifests.

## Strict Guidelines
- Engineers MUST ALWAYS enforce CiliumNetworkPolicy or CiliumClusterwideNetworkPolicy with strict `specs.egress` rules defining explicit L7 HTTP/gRPC methods and paths instead of open L3/L4 egress CIDRs.
- Engineers MUST NOT inject userspace sidecar containers (such as Istio/Envoy sidecars) into application Pods; mutual authentication MUST be offloaded to Cilium's native node-level authentication engine configured with SPIFFE/SPIRE or WireGuard/IPsec transparent encryption.
- Manifests MUST configure `authentication.mode: test-always` or `authentication.mode: required` within CiliumNetworkPolicy to mandate mutual node/pod identity handshake before kernel socket transition.
- Services MUST enable eBPF host-routing (`bpf.masquerade=true`, `tunnel=disabled`, `kubeProxyReplacement=true`) to bypass the Linux netfilter conntrack table entirely for high-throughput zero-trust egress path traversal.
- Manifests NEVER define wildcard HTTP matchers (`path: ".*"` with `method: ".*"`) in Cilium L7 policy when accessing internal or external attested services.

## Bad vs Good Implementations
### CiliumNetworkPolicy L7 Egress Authorization with Transparent Mutual Attestation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Standard Kubernetes NetworkPolicy operates only up to Layer 4, allowing arbitrary payloads once TCP port 8443 connects. Teams often compensate by injecting heavy Envoy sidecars, adding 15-30MB RAM per pod, extra context switches, and complex certificate renewal lifecycles.
```yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: payment-service-egress
  namespace: core-payments
spec:
  podSelector:
    matchLabels:
      app.kubernetes.io/name: payment-service
  policyTypes:
    - Egress
  egress:
    # ANTI-PATTERN: Blind L4 CIDR allowance, no L7 inspection, no cryptographic
    # mutual attestation, relying instead on an injected userspace proxy.
    - to:
        - ipBlock:
            cidr: 10.0.0.0/8
      ports:
        - protocol: TCP
          port: 8443
```

#### Production Standard (Correct)
> **Standard**: Enforces Cilium's transparent kernel-level authentication (SPIFFE ID handshake) and evaluates L7 HTTP verbs and paths in eBPF/node proxy. Packets traverse directly between sockets without pod-level userspace proxy hops, preserving wire-speed throughput and zero-trust verification.
```yaml
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: payment-service-egress
  namespace: core-payments
spec:
  endpointSelector:
    matchLabels:
      app.kubernetes.io/name: payment-service
  egress:
    - toEndpoints:
        - matchLabels:
            app.kubernetes.io/name: ledger-service
            io.kubernetes.pod.namespace: financial-ledger
      # Kernel-level transparent mutual attestation via SPIRE/SPIFFE identity
      authentication:
        mode: required
      toPorts:
        - ports:
            - port: "8443"
              protocol: TCP
          rules:
            http:
              - method: "POST"
                path: "/v2/transactions/settle"
              - method: "GET"
                path: "/v2/transactions/[0-9a-fA-F-]+"
```

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 L7 Zero-Trust Transparent Mutual Attestation and Policy Enforcement

Cilium eBPF L7 Zero-Trust Transparent Mutual Attestation and Policy Enforcement defines an industrial-grade behavioral standard for devops engineering. Enforces kernel-level mutual authentication, cryptographic identity verification, and strict Layer 7 egress authorization using Cilium eBPF and SPIRE without injecting userspace Envoy sidecars. This eliminates sidecar memory consumption, CPU context-switching overhead, and kernel-to-userspace TCP socket splicing while preserving zero-trust guarantees. 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 heavyweight sidecar proxies for mTLS and egress filtering instead of kernel-space eBPF transparent attestation. 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 heavyweight sidecar proxies for mTLS and egress filtering instead of kernel-space eBPF transparent attestation.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 CiliumNetworkPolicy or CiliumClusterwideNetworkPolicy with strict `specs.egress` rules defining explicit L7 HTTP/gRPC methods and paths instead of open L3/L4 egress CIDRs.

Engineers MUST ALWAYS enforce CiliumNetworkPolicy or CiliumClusterwideNetworkPolicy with strict `specs.egress` rules defining explicit L7 HTTP/gRPC methods and paths instead of open L3/L4 egress CIDRs.

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 inject userspace sidecar containers (such as Istio/Envoy sidecars) into application Pods

Engineers MUST NOT inject userspace sidecar containers (such as Istio/Envoy sidecars) into application Pods; mutual authentication MUST be offloaded to Cilium's native node-level authentication engine configured with SPIFFE/SPIRE or WireGuard/IPsec transparent encryption.

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 configure `authentication.mode

Manifests MUST configure `authentication.mode: test-always` or `authentication.mode: required` within CiliumNetworkPolicy to mandate mutual node/pod identity handshake before kernel socket transition.

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 enable eBPF host-routing (`bpf.masquerade=true`, `tunnel=disabled`, `kubeProxyReplacement=true`) to bypass the Linux netfilter conntrack table entirely for high-throughput zero-trust egress path traversal.

Services MUST enable eBPF host-routing (`bpf.masquerade=true`, `tunnel=disabled`, `kubeProxyReplacement=true`) to bypass the Linux netfilter conntrack table entirely for high-throughput zero-trust egress path traversal.

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

Manifests NEVER define wildcard HTTP matchers (`path

Manifests NEVER define wildcard HTTP matchers (`path: ".*"` with `method: ".*"`) in Cilium L7 policy when accessing internal or external attested services.

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 L7 Zero-Trust Transparent Mutual Attestation and Policy Enforcement critical for AI coding assistants?

Enforces kernel-level mutual authentication, cryptographic identity verification, and strict Layer 7 egress authorization using Cilium eBPF and SPIRE without injecting userspace Envoy sidecars. This eliminates sidecar memory consumption, CPU context-switching overhead, and kernel-to-userspace TCP socket splicing while preserving zero-trust guarantees. 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 heavyweight sidecar proxies for mTLS and egress filtering instead of kernel-space eBPF transparent attestation.) 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