This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: spiffe-spire-ebpf-cgroupv2-attestation-standard

SPIFFE/SPIRE eBPF-Based Cgroupv2 Workload Identity Attestation Standard

Enforces cryptographically unfakeable pod mTLS identity minting at the kernel socket layer via SPIRE Agent eBPF tracing and cgroupv2 hierarchy verification. Eliminates vulnerable mounted Kubernetes Projected ServiceAccountTokens and mitigates SO_PEERCRED PID-recycling TOCTOU race conditions.

Prohibited Anti-Pattern: Relying on Mounted ServiceAccount Tokens or PID-Based Socket Attestation Prone to TOCTOU Spoofing

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: SPIFFE/SPIRE eBPF-Based Cgroupv2 Workload Identity Attestation Standard - Enforces cryptographically unfakeable pod mTLS identity minting at the kernel socket layer via SPIRE Agent eBPF tracing and cgroupv2 hierarchy verification. Eliminates vulnerable mounted Kubernetes Projected ServiceAccountTokens and mitigates SO_PEERCRED PID-recycling TOCTOU race conditions.
globs: deploy/**/*.{ts,js,yaml,yml}, infra/**/*.{ts,js,yaml,yml}, k8s/**/*.{yaml,yml}, **/spire-agent*.{yaml,yml,conf}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/spiffe-spire-ebpf-cgroupv2-attestation-standard"
---

# SPIFFE/SPIRE eBPF-Based Cgroupv2 Workload Identity Attestation Standard

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Relying on Mounted ServiceAccount Tokens or PID-Based Socket Attestation Prone to TOCTOU Spoofing

## System Constraints
You are a Principal Platform Security Architect enforcing the SPIFFE/SPIRE eBPF-Based Cgroupv2 Workload Identity Attestation Standard. You must mandate zero-trust identity issuance by tying SPIFFE SVID minting directly to kernel socket cookies and cgroupv2 controllers, prohibiting static credentials, long-lived bearer tokens, and automounted service account tokens.

## Strict Guidelines
- Engineers MUST ALWAYS set 'automountServiceAccountToken: false' across all tenant Pod manifests to eliminate secret exfiltration risks.
- Engineers MUST configure SPIRE Agent workload attestation via eBPF socket tracing coupled with cgroupv2 controller path verification rather than naive SO_PEERCRED PID resolution.
- Engineers MUST NOT mount projected service account tokens or cloud IAM bearer tokens into application containers to establish mTLS or service-to-service identity.
- Services MUST communicate with the SPIFFE Workload API strictly through the attested kernel-verified socket, validating X.509 SVIDs in-memory without persistent disk writes.
- Platform configs MUST mount '/sys/fs/cgroup' as read-only with host cgroup namespaces enabled for the SPIRE Agent DaemonSet to ensure accurate kernel inode attestation.

## Bad vs Good Implementations
### SPIRE Agent & Pod Identity Definition (Pulumi/TypeScript)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Enabling automountServiceAccountToken exposes static Kubernetes tokens to compromise. Utilizing an unverified hostPath socket without kernel-level cgroupv2/eBPF binding makes the SPIRE Agent rely on PID-based SO_PEERCRED inspection, which is susceptible to PID reuse and TOCTOU container impersonation.
```typescript
import * as k8s from "@pulumi/kubernetes";

// ANTI-PATTERN: Relying on default projected service account tokens
// and unverified PID-based Unix Domain Socket attestation
export const insecureApp = new k8s.core.v1.Pod("payment-service", {
  metadata: { name: "payment-service" },
  spec: {
    // Vulnerable: automatically mounts k8s API tokens susceptible to theft
    automountServiceAccountToken: true,
    containers: [{
      name: "service",
      image: "payment-api:v1.2.0",
      volumeMounts: [{
        name: "spiffe-uds",
        mountPath: "/run/spire/sockets", // Shared UDS vulnerable to PID race conditions
      }],
    }],
    volumes: [{
      name: "spiffe-uds",
      hostPath: { path: "/tmp/spire-agent/public" },
    }],
  },
});
```

#### Production Standard (Correct)
> **Standard**: Disables automountServiceAccountToken to prevent token credential theft, mounts the SPIFFE Workload API via SPIFFE CSI driver, and enforces container isolation allowing the SPIRE Agent's eBPF probe to resolve the cgroupv2 inode directly to the container's cryptographically unfakeable identity.
```typescript
import * as k8s from "@pulumi/kubernetes";

// PRODUCTION INVARIANT: Disabling token automount and enforcing
// eBPF cgroupv2 kernel attestation via SPIRE Workload API
export const secureApp = new k8s.core.v1.Pod("payment-service", {
  metadata: {
    name: "payment-service",
    labels: {
      "app.kubernetes.io/name": "payment-service",
      "identity.spiffe.io/workload": "payment-processor",
    },
  },
  spec: {
    // Invariant: Invalidate token theft by completely disabling projected tokens
    automountServiceAccountToken: false,
    hostUsers: false,
    containers: [{
      name: "service",
      image: "payment-api:v1.2.0",
      securityContext: {
        allowPrivilegeEscalation: false,
        readOnlyRootFilesystem: true,
        capabilities: { drop: ["ALL"] },
      },
      volumeMounts: [{
        name: "spire-agent-socket",
        mountPath: "/spiffe-workload-api",
        readOnly: true,
      }],
      env: [{
        name: "SPIFFE_ENDPOINT_SOCKET",
        value: "unix:///spiffe-workload-api/agent.sock",
      }],
    }],
    volumes: [{
      name: "spire-agent-socket",
      csi: {
        driver: "csi.spiffe.io",
        readOnly: true,
      },
    }],
  },
});
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: SPIFFE/SPIRE eBPF-Based Cgroupv2 Workload Identity Attestation Standard

SPIFFE/SPIRE eBPF-Based Cgroupv2 Workload Identity Attestation Standard defines an industrial-grade behavioral standard for devops engineering. Enforces cryptographically unfakeable pod mTLS identity minting at the kernel socket layer via SPIRE Agent eBPF tracing and cgroupv2 hierarchy verification. Eliminates vulnerable mounted Kubernetes Projected ServiceAccountTokens and mitigates SO_PEERCRED PID-recycling TOCTOU race conditions. 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 Mounted ServiceAccount Tokens or PID-Based Socket Attestation Prone to TOCTOU Spoofing 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 Mounted ServiceAccount Tokens or PID-Based Socket Attestation Prone to TOCTOU SpoofingCritical
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 'automountServiceAccountToken

Engineers MUST ALWAYS set 'automountServiceAccountToken: false' across all tenant Pod manifests to eliminate secret exfiltration risks.

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 configure SPIRE Agent workload attestation via eBPF socket tracing coupled with cgroupv2 controller path verification rather than naive SO_PEERCRED PID resolution.

Engineers MUST configure SPIRE Agent workload attestation via eBPF socket tracing coupled with cgroupv2 controller path verification rather than naive SO_PEERCRED PID resolution.

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

Engineers MUST NOT mount projected service account tokens or cloud IAM bearer tokens into application containers to establish mTLS or service-to-service identity.

Engineers MUST NOT mount projected service account tokens or cloud IAM bearer tokens into application containers to establish mTLS or service-to-service identity.

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 communicate with the SPIFFE Workload API strictly through the attested kernel-verified socket, validating X.509 SVIDs in-memory without persistent disk writes.

Services MUST communicate with the SPIFFE Workload API strictly through the attested kernel-verified socket, validating X.509 SVIDs in-memory without persistent disk writes.

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

Platform configs MUST mount '/sys/fs/cgroup' as read-only with host cgroup namespaces enabled for the SPIRE Agent DaemonSet to ensure accurate kernel inode attestation.

Platform configs MUST mount '/sys/fs/cgroup' as read-only with host cgroup namespaces enabled for the SPIRE Agent DaemonSet to ensure accurate kernel inode attestation.

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 SPIFFE/SPIRE eBPF-Based Cgroupv2 Workload Identity Attestation Standard critical for AI coding assistants?

Enforces cryptographically unfakeable pod mTLS identity minting at the kernel socket layer via SPIRE Agent eBPF tracing and cgroupv2 hierarchy verification. Eliminates vulnerable mounted Kubernetes Projected ServiceAccountTokens and mitigates SO_PEERCRED PID-recycling TOCTOU race conditions. 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 Mounted ServiceAccount Tokens or PID-Based Socket Attestation Prone to TOCTOU Spoofing) 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

SPIFFE/SPIRE