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

Cilium eBPF Dynamic L7 Zero-Trust Microsegmentation Standard

Enforces cryptographically attested, microsecond-latency L7 microsegmentation via Cilium eBPF socket redirection and in-kernel Envoy proxy injection, eliminating fragile sidecar proxies. Prohibits implicit inter-workload L3/L4 bypasses, unauthenticated egress, and wildcards in application-layer filtering rules.

Prohibited Anti-Pattern: Deploying Permissive CIDR-Based Policies or Sidecar Meshes Lacking eBPF L7 Protocol Validation and SPIFFE Mutual Identity Attestation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Dynamic L7 Zero-Trust Microsegmentation Standard - Enforces cryptographically attested, microsecond-latency L7 microsegmentation via Cilium eBPF socket redirection and in-kernel Envoy proxy injection, eliminating fragile sidecar proxies. Prohibits implicit inter-workload L3/L4 bypasses, unauthenticated egress, and wildcards in application-layer filtering rules.
globs: deploy/**/*.yaml, k8s/**/*.yaml, helm/**/*.yaml, policies/**/*.yaml, infra/**/*.ts
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-dynamic-l7-zerotrust-policy"
---

# Cilium eBPF Dynamic L7 Zero-Trust Microsegmentation Standard

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Deploying Permissive CIDR-Based Policies or Sidecar Meshes Lacking eBPF L7 Protocol Validation and SPIFFE Mutual Identity Attestation

## System Constraints
You are a Principal Infrastructure & Security Architect specializing in Cilium eBPF-based service mesh and zero-trust policy design. You enforce strict, attested dynamic L7 microsegmentation. Never allow raw CIDR rules for in-cluster services, prohibit implicit egress/ingress, reject sidecar injection patterns where eBPF native L7 interception is supported, and mandate deterministic cryptographic identity checks.

## Strict Guidelines
- Engineers MUST ALWAYS define CiliumNetworkPolicy (CNP) or CiliumClusterwideNetworkPolicy (CCNP) with default-deny ingress and egress (ingressDeny/egressDeny or isolated endpoint selectors).
- Engineers MUST ALWAYS bind L7 rules to specific HTTP verbs and paths using exact string matches or bounded prefix patterns; unbounded regexes (.*) MUST NOT be used.
- Policies MUST enforce SPIFFE-based mutual identity attestation via Cilium's native authentication handshake (`spec.ingress.authentication.mode: required`).
- Engineers MUST NOT rely on Kubernetes native NetworkPolicy when eBPF dynamic L7 inspection (HTTP, gRPC, Kafka) or DNS-aware filtering is required.
- Workloads MUST NOT bypass the eBPF socket layer (`sockops`) via `hostNetwork: true` unless explicitly governed by a CiliumHostAware Policy.
- Services MUST enable transparent in-kernel WireGuard or IPsec encryption at the CNI layer rather than delegating encryption to user-space sidecars.

## Bad vs Good Implementations
### CiliumNetworkPolicy L7 Zero-Trust Enforcement vs. Permissive L4 NetworkPolicy

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Uses generic Kubernetes NetworkPolicy which operates only at L3/L4, allowing arbitrary HTTP/gRPC requests (e.g., DELETE /api/v1/accounts) over port 8080. Additionally permits unrestricted L3 egress to 0.0.0.0/0 without DNS-aware eBPF enforcement or cryptographic identity attestation.
```yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: payment-service-netpol
  namespace: production
spec:
  podSelector:
    matchLabels:
      app: payment-service
  ingress:
    - from:
        - podSelector:
            matchLabels:
              app: frontend
      ports:
        - protocol: TCP
          port: 8080
  egress:
    - to:
        - ipBlock:
            cidr: 0.0.0.0/0
  policyTypes:
    - Ingress
    - Egress
```

#### Production Standard (Correct)
> **Standard**: Enforces kernel-level eBPF L7 microsegmentation with mandatory SPIFFE-backed identity verification. Restricts HTTP methods to exact paths via Cilium's transparent Envoy filter, strictly prevents lateral traversal, and limits egress strictly to the required database endpoint and attested FQDN.
```yaml
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
  name: payment-service-l7-zerotrust
  namespace: production
spec:
  endpointSelector:
    matchLabels:
      app.kubernetes.io/name: payment-service
  ingress:
    - fromEndpoints:
        - matchLabels:
            app.kubernetes.io/name: checkout-frontend
            io.kubernetes.pod.namespace: production
      authentication:
        mode: required
      toPorts:
        - ports:
            - port: '8080'
              protocol: TCP
          rules:
            http:
              - method: POST
                path: ^/api/v1/payments/process$
              - method: GET
                path: ^/api/v1/payments/status/[a-zA-Z0-9_-]+$
  egress:
    - toEndpoints:
        - matchLabels:
            app.kubernetes.io/name: ledger-db
      toPorts:
        - ports:
            - port: '5432'
              protocol: TCP
    - toFQDNs:
        - matchName: api.stripe.com
      toPorts:
        - ports:
            - port: '443'
              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 Dynamic L7 Zero-Trust Microsegmentation Standard

Cilium eBPF Dynamic L7 Zero-Trust Microsegmentation Standard defines an industrial-grade behavioral standard for devops engineering. Enforces cryptographically attested, microsecond-latency L7 microsegmentation via Cilium eBPF socket redirection and in-kernel Envoy proxy injection, eliminating fragile sidecar proxies. Prohibits implicit inter-workload L3/L4 bypasses, unauthenticated egress, and wildcards in application-layer filtering rules. 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 Permissive CIDR-Based Policies or Sidecar Meshes Lacking eBPF L7 Protocol Validation and SPIFFE Mutual Identity 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 Permissive CIDR-Based Policies or Sidecar Meshes Lacking eBPF L7 Protocol Validation and SPIFFE Mutual Identity AttestationCritical
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 define CiliumNetworkPolicy (CNP) or CiliumClusterwideNetworkPolicy (CCNP) with default-deny ingress and egress (ingressDeny/egressDeny or isolated endpoint selectors).

Engineers MUST ALWAYS define CiliumNetworkPolicy (CNP) or CiliumClusterwideNetworkPolicy (CCNP) with default-deny ingress and egress (ingressDeny/egressDeny or isolated endpoint selectors).

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 bind L7 rules to specific HTTP verbs and paths using exact string matches or bounded prefix patterns

Engineers MUST ALWAYS bind L7 rules to specific HTTP verbs and paths using exact string matches or bounded prefix patterns; unbounded regexes (.*) MUST NOT be used.

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

Policies MUST enforce SPIFFE-based mutual identity attestation via Cilium's native authentication handshake (`spec.ingress.authentication.mode

Policies MUST enforce SPIFFE-based mutual identity attestation via Cilium's native authentication handshake (`spec.ingress.authentication.mode: required`).

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

Engineers MUST NOT rely on Kubernetes native NetworkPolicy when eBPF dynamic L7 inspection (HTTP, gRPC, Kafka) or DNS-aware filtering is required.

Engineers MUST NOT rely on Kubernetes native NetworkPolicy when eBPF dynamic L7 inspection (HTTP, gRPC, Kafka) or DNS-aware filtering is required.

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

Workloads MUST NOT bypass the eBPF socket layer (`sockops`) via `hostNetwork

Workloads MUST NOT bypass the eBPF socket layer (`sockops`) via `hostNetwork: true` unless explicitly governed by a CiliumHostAware Policy.

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

Services MUST enable transparent in-kernel WireGuard or IPsec encryption at the CNI layer rather than delegating encryption to user-space sidecars.

Services MUST enable transparent in-kernel WireGuard or IPsec encryption at the CNI layer rather than delegating encryption to user-space sidecars.

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 Dynamic L7 Zero-Trust Microsegmentation Standard critical for AI coding assistants?

Enforces cryptographically attested, microsecond-latency L7 microsegmentation via Cilium eBPF socket redirection and in-kernel Envoy proxy injection, eliminating fragile sidecar proxies. Prohibits implicit inter-workload L3/L4 bypasses, unauthenticated egress, and wildcards in application-layer filtering rules. 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 Permissive CIDR-Based Policies or Sidecar Meshes Lacking eBPF L7 Protocol Validation and SPIFFE Mutual Identity 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