This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: spiffe-spire-ephemeral-workload-attestation-standard-spiffe-spire-eph-630

SPIFFE/SPIRE Ephemeral Workload Identity Attestation Standard

Enforces zero static credentials by mandating cryptographically attested ephemeral X.509 SVID issuance and live rotation via local SPIRE Agent Unix Domain Sockets. Prohibits persistent cryptographic keys, static cloud IAM service account credentials, and unrotated in-memory X.509 certificates across service meshes and microservice fabrics.

Prohibited Anti-Pattern: Baking Static Cloud IAM Credentials or Caching Unrotated X.509 Certificates Across Service Boundaries

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: SPIFFE/SPIRE Ephemeral Workload Identity Attestation Standard - Enforces zero static credentials by mandating cryptographically attested ephemeral X.509 SVID issuance and live rotation via local SPIRE Agent Unix Domain Sockets. Prohibits persistent cryptographic keys, static cloud IAM service account credentials, and unrotated in-memory X.509 certificates across service meshes and microservice fabrics.
globs: src/**/*.{ts,tsx,js,jsx}, src/security/**/*.{ts,js}, src/infra/**/*.{ts,js}, src/network/**/*.{ts,js}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/spiffe-spire-ephemeral-workload-attestation-standard-spiffe-spire-eph-630"
---

# SPIFFE/SPIRE Ephemeral Workload Identity Attestation Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Baking Static Cloud IAM Credentials or Caching Unrotated X.509 Certificates Across Service Boundaries

## System Constraints
You are a Principal Security Architect enforcing the SPIFFE/SPIRE Ephemeral Workload Identity Attestation Standard. Eliminate all static credentials, API keys, long-lived tokens, and static TLS certificate files in favor of dynamic kernel-level workload attestation. Require every microservice to bind strictly to the local SPIRE Agent Unix Domain Socket (/run/spire/sockets/agent.sock) for X.509 SVID streaming and automated rotation prior to cert expiration.

## Strict Guidelines
- Services MUST acquire all cryptographic identity materials (X.509 SVIDs and trust bundles) exclusively through the local SPIFFE Workload API over a Linux kernel Unix Domain Socket (UDS).
- Engineers MUST NOT persist private keys, public certificates, or SVIDs to persistent disk volumes, temporary filesystems, or environment variables.
- Services MUST implement dynamic certificate re-attestation hooks that hot-reload active mTLS server and client contexts without process restarts whenever the SPIRE Agent pushes rotated SVIDs.
- Code MUST validate incoming peer SPIFFE IDs against a strict trust domain and expected workload URI format (e.g., spiffe://domain.internal/ns/{namespace}/sa/{serviceaccount}) rather than generic Subject Alternative Names or CN strings.
- Components NEVER fall back to static API keys, ambient cloud metadata service tokens (e.g., IMDSv2 IAM credentials), or hardcoded bearer tokens when the SPIFFE Workload API is unreachable; fail closed with an explicit attestation error.

## Bad vs Good Implementations
### mTLS Server Configuration: Static PEM Files vs Dynamic SPIFFE Workload API Streaming

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Loads static certificates from the local disk at startup. If credentials are leaked, they cannot be readily invalidated, and expiring certificates require a disruptive service redeploy or manual file rotation. Fails to verify the caller's attested SPIFFE identity.
```typescript
import * as https from 'https';
import * as fs from 'fs';

// ANTI-PATTERN: Static, long-lived certificates loaded from disk with no rotation mechanism
const serverOptions: https.ServerOptions = {
  key: fs.readFileSync('/etc/ssl/certs/service-private-key.pem'),
  cert: fs.readFileSync('/etc/ssl/certs/service-cert.pem'),
  ca: fs.readFileSync('/etc/ssl/certs/ca-bundle.pem'),
  requestCert: true,
  rejectUnauthorized: true
};

export const server = https.createServer(serverOptions, (req, res) => {
  res.writeHead(200);
  res.end('Authenticated via static cert');
});
```

#### Production Standard (Correct)
> **Standard**: Obtains ephemeral X.509 SVIDs directly from the SPIRE agent through kernel-authenticated UDS. Dynamically provisions TLS secure contexts on each handshake, ensuring automatic certificate rotation every 60 minutes with zero downtime and strict SPIFFE ID SAN validation.
```typescript
import * as tls from 'tls';
import * as net from 'net';
import { WorkloadApiClient, X509Source } from '@spiffe/spiffe-ts';

const SPIRE_SOCKET_PATH = 'unix:///run/spire/sockets/agent.sock';
const EXPECTED_CLIENT_SPIFFE_ID = 'spiffe://cluster.local/ns/prod/sa/payment-client';

export async function createSpiffeServer(): Promise<tls.Server> {
  // Connect to the local SPIRE agent over kernel-attested UDS
  const x509Source = await WorkloadApiClient.createX509Source({
    spiffeSocketPath: SPIRE_SOCKET_PATH
  });

  const server = tls.createServer({
    // Dynamic SNICallback / dynamic context fetching ensures 60m cert rotations are applied seamlessly
    SNICallback: (_servername, cb) => {
      try {
        const svid = x509Source.getDefaultX509Svid();
        const bundle = x509Source.getX509Bundle();
        const context = tls.createSecureContext({
          cert: svid.certChainPem,
          key: svid.privateKeyPem,
          ca: bundle.bundlePem
        });
        cb(null, context);
      } catch (err) {
        cb(err as Error);
      }
    },
    requestCert: true,
    rejectUnauthorized: true
  }, (socket: tls.TLSSocket) => {
    const peerCert = socket.getPeerCertificate(true);
    const sanUri = peerCert.subjectaltname
      ?.split(',')
      .map((s) => s.trim())
      .find((s) => s.startsWith('URI:spiffe://'))
      ?.replace('URI:', '');

    if (sanUri !== EXPECTED_CLIENT_SPIFFE_ID) {
      socket.destroy(new Error(`Unauthorized SPIFFE ID: ${sanUri}`));
      return;
    }
  });

  return server;
}
```

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: SPIFFE/SPIRE Ephemeral Workload Identity Attestation Standard

SPIFFE/SPIRE Ephemeral Workload Identity Attestation Standard defines an industrial-grade behavioral standard for security engineering. Enforces zero static credentials by mandating cryptographically attested ephemeral X.509 SVID issuance and live rotation via local SPIRE Agent Unix Domain Sockets. Prohibits persistent cryptographic keys, static cloud IAM service account credentials, and unrotated in-memory X.509 certificates across service meshes and microservice fabrics. 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: Baking Static Cloud IAM Credentials or Caching Unrotated X.509 Certificates Across Service Boundaries 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 DriftBaking Static Cloud IAM Credentials or Caching Unrotated X.509 Certificates Across Service BoundariesCritical
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

Services MUST acquire all cryptographic identity materials (X.509 SVIDs and trust bundles) exclusively through the local SPIFFE Workload API over a Linux kernel Unix Domain Socket (UDS).

Services MUST acquire all cryptographic identity materials (X.509 SVIDs and trust bundles) exclusively through the local SPIFFE Workload API over a Linux kernel Unix Domain Socket (UDS).

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 persist private keys, public certificates, or SVIDs to persistent disk volumes, temporary filesystems, or environment variables.

Engineers MUST NOT persist private keys, public certificates, or SVIDs to persistent disk volumes, temporary filesystems, or environment variables.

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 implement dynamic certificate re-attestation hooks that hot-reload active mTLS server and client contexts without process restarts whenever the SPIRE Agent pushes rotated SVIDs.

Services MUST implement dynamic certificate re-attestation hooks that hot-reload active mTLS server and client contexts without process restarts whenever the SPIRE Agent pushes rotated SVIDs.

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

Code MUST validate incoming peer SPIFFE IDs against a strict trust domain and expected workload URI format (e.g., spiffe

Code MUST validate incoming peer SPIFFE IDs against a strict trust domain and expected workload URI format (e.g., spiffe://domain.internal/ns/{namespace}/sa/{serviceaccount}) rather than generic Subject Alternative Names or CN strings.

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 static API keys, ambient cloud metadata service tokens (e.g., IMDSv2 IAM credentials), or hardcoded bearer tokens when the SPIFFE Workload API is unreachable

Components NEVER fall back to static API keys, ambient cloud metadata service tokens (e.g., IMDSv2 IAM credentials), or hardcoded bearer tokens when the SPIFFE Workload API is unreachable; fail closed with an explicit attestation error.

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 Ephemeral Workload Identity Attestation Standard critical for AI coding assistants?

Enforces zero static credentials by mandating cryptographically attested ephemeral X.509 SVID issuance and live rotation via local SPIRE Agent Unix Domain Sockets. Prohibits persistent cryptographic keys, static cloud IAM service account credentials, and unrotated in-memory X.509 certificates across service meshes and microservice fabrics. 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 (Baking Static Cloud IAM Credentials or Caching Unrotated X.509 Certificates Across Service Boundaries) 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