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

Cilium eBPF WireGuard Layer-7 Identity-Aware Ingress Handshake Boundary

Mandates kernel-space cryptographic verification via eBPF sockops and transparent WireGuard encapsulation before processing L7 application ingress payloads. Enforces continuous cryptographic SPIFFE/Cilium identity re-attestation across multi-cluster service mesh boundaries to eliminate TOCTOU packet spoofing and unauthenticated cross-cluster traversal.

Prohibited Anti-Pattern: Blind Layer-4 WireGuard Tunneling Without Kernel-Level eBPF Identity Attestation and L7 Policy Interception

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium eBPF WireGuard Layer-7 Identity-Aware Ingress Handshake Boundary - Mandates kernel-space cryptographic verification via eBPF sockops and transparent WireGuard encapsulation before processing L7 application ingress payloads. Enforces continuous cryptographic SPIFFE/Cilium identity re-attestation across multi-cluster service mesh boundaries to eliminate TOCTOU packet spoofing and unauthenticated cross-cluster traversal.
globs: k8s/**/*.yaml, deploy/**/*.yaml, infra/**/*.ts, charts/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-ebpf-wireguard-l7-handshake-boundary"
---

# Cilium eBPF WireGuard Layer-7 Identity-Aware Ingress Handshake Boundary

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Blind Layer-4 WireGuard Tunneling Without Kernel-Level eBPF Identity Attestation and L7 Policy Interception

## System Constraints
You are a Principal Engineer enforcing Cilium eBPF WireGuard Layer-7 Identity-Aware Ingress Handshake Boundary. Mandate invariants that bind kernel-space packet routing to authenticated SPIFFE/Cilium identities, ensuring no cross-cluster egress payload transitions into mesh fabrics without cryptographic verification.

## Strict Guidelines
- Engineers MUST ALWAYS enforce CiliumNetworkPolicies (CNP) or CiliumClusterwideNetworkPolicies (CCNP) that require cryptographically verified identity labels alongside WireGuard encryption (`encryption.type: wireguard`).
- Engineers MUST NOT rely on raw IP CIDR blocks or primitive Kubernetes Layer-4 NetworkPolicies for cross-cluster mesh boundaries.
- Services MUST mandate continuous identity re-attestation using SPIRE/SPIFFE x509 validation integrated with Cilium eBPF map checks at the ingress socket boundary.
- Components NEVER permit untracked or naked L7 ingress; all traffic MUST be intercepted by Envoy/eBPF via explicit Cilium `toPorts` L7 rules enforcing HTTP/gRPC protocol inspection.
- Code SHOULD define immutable Pulumi/CDK8s infrastructure definitions that reject pods failing eBPF socket-layer identity enforcement.

## Bad vs Good Implementations
### Cilium Identity-Aware WireGuard L7 Policy Definition

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Relies on vanilla Kubernetes L4 NetworkPolicy with primitive CIDR matching. Traffic is unencrypted, bypassing WireGuard transit guarantees and omitting eBPF socket-level identity attestation, permitting spoofed intra-cluster packet traversal.
```typescript
import * as k8s from '@pulumi/kubernetes';

// Flawed: Standard L4 NetworkPolicy relying on mutable IP primitives
// No WireGuard transit enforcement, no eBPF identity validation, no L7 parsing
export const insecureIngressPolicy = new k8s.networking.v1.NetworkPolicy('mesh-ingress', {
  metadata: { name: 'mesh-ingress' },
  spec: {
    podSelector: { matchLabels: { app: 'secure-vault' } },
    policyTypes: ['Ingress'],
    ingress: [{
      from: [
        { ipBlock: { cidr: '10.244.0.0/16' } } // Vulnerable to IP spoofing
      ],
      ports: [{ port: 8080, protocol: 'TCP' }]
    }]
  }
});
```

#### Production Standard (Correct)
> **Standard**: Enforces Cilium-native eBPF identity primitives across multi-cluster boundaries (`io.cilium.k8s.policy.cluster`), mandates cryptographic SPIFFE workload matching, binds packets to kernel WireGuard transport, and verifies Layer-7 HTTP paths and headers.
```typescript
import * as k8s from '@pulumi/kubernetes';

// Compliant: CiliumNetworkPolicy enforcing WireGuard, eBPF identity, and L7 inspection
export const secureCiliumIngress = new k8s.apiextensions.CustomResource('vault-l7-ingress', {
  apiVersion: 'cilium.io/v2',
  kind: 'CiliumNetworkPolicy',
  metadata: {
    name: 'vault-l7-identity-boundary',
    namespace: 'production'
  },
  spec: {
    description: 'Enforces WireGuard-encrypted, eBPF-attested cross-cluster L7 ingress',
    endpointSelector: {
      matchLabels: {
        'io.cilium.k8s.policy.serviceaccount': 'vault-service',
        'app.kubernetes.io/name': 'secure-vault'
      }
    },
    ingress: [{
      fromEndpoints: [{
        matchLabels: {
          'io.cilium.k8s.policy.cluster': 'edge-mesh-01',
          'k8s:io.spiffe.id/workload': 'gateway-egress'
        }
      }],
      toPorts: [{
        ports: [{ port: '8080', protocol: 'TCP' }],
        rules: {
          http: [
            {
              method: 'POST',
              path: '/api/v1/attest-handshake',
              headers: ['X-Mesh-Context-Identity: allowed']
            }
          ]
        }
      }]
    }]
  }
});
```

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 WireGuard Layer-7 Identity-Aware Ingress Handshake Boundary

Cilium eBPF WireGuard Layer-7 Identity-Aware Ingress Handshake Boundary defines an industrial-grade behavioral standard for devops engineering. Mandates kernel-space cryptographic verification via eBPF sockops and transparent WireGuard encapsulation before processing L7 application ingress payloads. Enforces continuous cryptographic SPIFFE/Cilium identity re-attestation across multi-cluster service mesh boundaries to eliminate TOCTOU packet spoofing and unauthenticated cross-cluster traversal. 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: Blind Layer-4 WireGuard Tunneling Without Kernel-Level eBPF Identity Attestation and L7 Policy Interception 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 DriftBlind Layer-4 WireGuard Tunneling Without Kernel-Level eBPF Identity Attestation and L7 Policy InterceptionCritical
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 CiliumNetworkPolicies (CNP) or CiliumClusterwideNetworkPolicies (CCNP) that require cryptographically verified identity labels alongside WireGuard encryption (`encryption.type

Engineers MUST ALWAYS enforce CiliumNetworkPolicies (CNP) or CiliumClusterwideNetworkPolicies (CCNP) that require cryptographically verified identity labels alongside WireGuard encryption (`encryption.type: wireguard`).

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 rely on raw IP CIDR blocks or primitive Kubernetes Layer-4 NetworkPolicies for cross-cluster mesh boundaries.

Engineers MUST NOT rely on raw IP CIDR blocks or primitive Kubernetes Layer-4 NetworkPolicies for cross-cluster mesh boundaries.

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

Services MUST mandate continuous identity re-attestation using SPIRE/SPIFFE x509 validation integrated with Cilium eBPF map checks at the ingress socket boundary.

Services MUST mandate continuous identity re-attestation using SPIRE/SPIFFE x509 validation integrated with Cilium eBPF map checks at the ingress socket boundary.

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

Components NEVER permit untracked or naked L7 ingress

Components NEVER permit untracked or naked L7 ingress; all traffic MUST be intercepted by Envoy/eBPF via explicit Cilium `toPorts` L7 rules enforcing HTTP/gRPC protocol inspection.

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

Code SHOULD define immutable Pulumi/CDK8s infrastructure definitions that reject pods failing eBPF socket-layer identity enforcement.

Code SHOULD define immutable Pulumi/CDK8s infrastructure definitions that reject pods failing eBPF socket-layer identity 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 WireGuard Layer-7 Identity-Aware Ingress Handshake Boundary critical for AI coding assistants?

Mandates kernel-space cryptographic verification via eBPF sockops and transparent WireGuard encapsulation before processing L7 application ingress payloads. Enforces continuous cryptographic SPIFFE/Cilium identity re-attestation across multi-cluster service mesh boundaries to eliminate TOCTOU packet spoofing and unauthenticated cross-cluster traversal. 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 (Blind Layer-4 WireGuard Tunneling Without Kernel-Level eBPF Identity Attestation and L7 Policy Interception) 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