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

Cilium eBPF Kernel mTLS Decoupling with SPIFFE Pod Attestation Standard

Enforces cryptographic mTLS handshake decoupling into node-level Cilium agents using kernel-space eBPF redirection while maintaining cryptographic zero-trust identity via SPIRE/SPIFFE attestation. Eliminates vulnerable user-space sidecar proxies and private key leakage by delegating authentication verification to the kernel-attested node infrastructure.

Prohibited Anti-Pattern: Bypassing Kernel-Attested mTLS via Insecure User-Space Sidecars or Unvalidated SPIFFE Identity Selectors

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF Kernel mTLS Decoupling with SPIFFE Pod Attestation Standard - Enforces cryptographic mTLS handshake decoupling into node-level Cilium agents using kernel-space eBPF redirection while maintaining cryptographic zero-trust identity via SPIRE/SPIFFE attestation. Eliminates vulnerable user-space sidecar proxies and private key leakage by delegating authentication verification to the kernel-attested node infrastructure.
globs: k8s/**/*.{yaml,yml}, charts/**/*.{yaml,yml}, manifests/**/*.{yaml,yml}, deployments/**/*.{yaml,yml}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-spiffe-mtls-kernel-attestation"
---

# Cilium eBPF Kernel mTLS Decoupling with SPIFFE Pod Attestation Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Bypassing Kernel-Attested mTLS via Insecure User-Space Sidecars or Unvalidated SPIFFE Identity Selectors

## System Constraints
You are a Principal Security and Infrastructure Architect enforcing Cilium eBPF Kernel-Level mTLS Decoupling with SPIFFE Pod Attestation. Mandate zero-trust mutual authentication where user-space containers NEVER manage private keys, handshake handoffs are managed via Cilium Node Agents with SPIRE integration, and all CiliumNetworkPolicies strictly bind endpoints to authenticated SPIFFE identities.

## Strict Guidelines
- Engineers MUST ALWAYS enforce CiliumNetworkPolicy authentication mode 'spiffe' on all ingress and egress rules carrying sensitive or cross-namespace traffic.
- Engineers MUST NOT mount SPIRE agent workload sockets or raw X.509 private keys directly into application containers when eBPF mesh mTLS is active.
- Cilium Helm values MUST enable `authentication.mutual.spiffe.enabled=true` and pin trust domains explicitly to prevent foreign trust federation bypass.
- Services MUST validate SPIFFE IDs against canonical SAN patterns (e.g., `spiffe://<trust-domain>/ns/<namespace>/sa/<serviceaccount>`) and reject wildcard trust bindings.
- Components NEVER fall back to plaintext TCP transport when a SPIFFE handshake fails or an unverified certificate is encountered during eBPF policy enforcement.

## Bad vs Good Implementations
### CiliumNetworkPolicy SPIFFE Authentication Enforcement

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Network policy relies solely on easily spoofable Kubernetes labels at Layer 3/4. It lacks cryptographic SPIFFE attestation and allows traffic if labels match, failing zero-trust transport requirements.
```yaml
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
  name: secure-payment-ingress
  namespace: payments
spec:
  endpointSelector:
    matchLabels:
      app: payment-gateway
  ingress:
  - fromEndpoints:
    - matchLabels:
        app: checkout
    # ANTI-PATTERN: Relies solely on ephemeral Kubernetes labels without
    # cryptographic mTLS identity verification or kernel attestation.
    toPorts:
    - ports:
      - port: "8443"
        protocol: TCP
```

#### Production Standard (Correct)
> **Standard**: Requires mutual authentication with SPIFFE mode. Cilium intercepts the connection via eBPF sockops, triggers the node-level handshake using cryptographically attested SPIFFE SVIDs, and only permits traffic once cryptographic identity is validated.
```yaml
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
  name: secure-payment-ingress
  namespace: payments
spec:
  endpointSelector:
    matchLabels:
      app: payment-gateway
  ingress:
  - fromEndpoints:
    - matchLabels:
        app: checkout
    # PRODUCTION INVARIANT: Decoupled kernel mTLS handshake verified via SPIFFE
    authentication:
      mode: spiffe
    toPorts:
    - ports:
      - port: "8443"
        protocol: TCP
      rules:
        http:
        - method: POST
          path: "/v1/charge"
```

### Cilium Helm Configuration for SPIFFE Workload Attestation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Disabling SPIFFE mutual authentication forces operators to deploy vulnerable, resource-heavy user-space sidecars where containers store TLS private keys directly in memory.
```yaml
# ANTI-PATTERN: Default insecure settings disabling SPIFFE mesh attestation
authentication:
  mutual:
    spiffe:
      enabled: false
envoy:
  enabled: true
```

#### Production Standard (Correct)
> **Standard**: Configures Cilium to interface directly with SPIRE using the node agent socket, allowing eBPF to enforce mTLS at connection time using cryptographically verified identities without sidecar injection.
```yaml
# PRODUCTION INVARIANT: Kernel-decoupled mTLS using SPIRE Node Agent integration
authentication:
  mutual:
    spiffe:
      enabled: true
      trustDomain: prod.infra.internal
      spireAgentSocketPath: /run/spire/sockets/agent.sock
mtls:
  backend: spire
encryption:
  enabled: true
  type: wireguard # Optional L3 underlay encryption beneath eBPF L7 SPIFFE auth
```

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 Kernel mTLS Decoupling with SPIFFE Pod Attestation Standard

Cilium eBPF Kernel mTLS Decoupling with SPIFFE Pod Attestation Standard defines an industrial-grade behavioral standard for security engineering. Enforces cryptographic mTLS handshake decoupling into node-level Cilium agents using kernel-space eBPF redirection while maintaining cryptographic zero-trust identity via SPIRE/SPIFFE attestation. Eliminates vulnerable user-space sidecar proxies and private key leakage by delegating authentication verification to the kernel-attested node infrastructure. 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-Attested mTLS via Insecure User-Space Sidecars or Unvalidated SPIFFE Identity Selectors 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-Attested mTLS via Insecure User-Space Sidecars or Unvalidated SPIFFE Identity SelectorsCritical
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 authentication mode 'spiffe' on all ingress and egress rules carrying sensitive or cross-namespace traffic.

Engineers MUST ALWAYS enforce CiliumNetworkPolicy authentication mode 'spiffe' on all ingress and egress rules carrying sensitive or cross-namespace traffic.

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 mount SPIRE agent workload sockets or raw X.509 private keys directly into application containers when eBPF mesh mTLS is active.

Engineers MUST NOT mount SPIRE agent workload sockets or raw X.509 private keys directly into application containers when eBPF mesh mTLS is active.

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 Helm values MUST enable `authentication.mutual.spiffe.enabled=true` and pin trust domains explicitly to prevent foreign trust federation bypass.

Cilium Helm values MUST enable `authentication.mutual.spiffe.enabled=true` and pin trust domains explicitly to prevent foreign trust federation bypass.

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 validate SPIFFE IDs against canonical SAN patterns (e.g., `spiffe

Services MUST validate SPIFFE IDs against canonical SAN patterns (e.g., `spiffe://<trust-domain>/ns/<namespace>/sa/<serviceaccount>`) and reject wildcard trust bindings.

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 fall back to plaintext TCP transport when a SPIFFE handshake fails or an unverified certificate is encountered during eBPF policy enforcement.

Components NEVER fall back to plaintext TCP transport when a SPIFFE handshake fails or an unverified certificate is encountered during eBPF policy enforcement.

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 Kernel mTLS Decoupling with SPIFFE Pod Attestation Standard critical for AI coding assistants?

Enforces cryptographic mTLS handshake decoupling into node-level Cilium agents using kernel-space eBPF redirection while maintaining cryptographic zero-trust identity via SPIRE/SPIFFE attestation. Eliminates vulnerable user-space sidecar proxies and private key leakage by delegating authentication verification to the kernel-attested node infrastructure. 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-Attested mTLS via Insecure User-Space Sidecars or Unvalidated SPIFFE Identity Selectors) 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