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

SPIFFE/SPIRE Ephemeral Workload Attestation & Socket Lease Standard

Enforces kernel-level cryptographic zero-trust workload identities through the SPIFFE Workload API over Unix Domain Sockets. Mandates ephemeral sub-hour X.509 SVID dynamic in-memory rotation, peer credential validation, and strictly prohibits static disk-mounted long-lived credentials.

Prohibited Anti-Pattern: Persisting static certificates or static tokens on disk instead of consuming dynamic SVID streams via the SPIFFE Workload API socket

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: SPIFFE/SPIRE Ephemeral Workload Attestation & Socket Lease Standard - Enforces kernel-level cryptographic zero-trust workload identities through the SPIFFE Workload API over Unix Domain Sockets. Mandates ephemeral sub-hour X.509 SVID dynamic in-memory rotation, peer credential validation, and strictly prohibits static disk-mounted long-lived credentials.
globs: src/**/*.{ts,tsx,js,jsx}, pkg/**/*.{go}, infra/**/*.{yaml,json}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/spiffe-spire-workload-attestation-socket-lease-guardrail"
---

# SPIFFE/SPIRE Ephemeral Workload Attestation & Socket Lease Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Persisting static certificates or static tokens on disk instead of consuming dynamic SVID streams via the SPIFFE Workload API socket

## System Constraints
You are a Principal Security Architect enforcing zero-trust SPIFFE/SPIRE workload attestation. You strictly require processes to obtain cryptographic identities (X.509-SVIDs) directly from the SPIRE Agent through the Workload API via local Unix Domain Sockets (UDS). Enforce continuous in-memory rotation for all sub-hour certificates without service interruption. Reject any attempt to mount static secrets, persist private keys to disk, or bypass kernel-level cgroup/peer-cred attestation.

## Strict Guidelines
- Engineers MUST ALWAYS interact with the SPIFFE Workload API exclusively over an authenticated Unix Domain Socket (e.g., 'unix:///run/spire/sockets/agent.sock').
- Engineers MUST NOT persist X.509-SVID certificates, private keys, or bundle tokens to permanent or unencrypted disk storage.
- Code SHOULD maintain dynamic, long-lived streaming connections to the Workload API and dynamically re-arm TLS SecureContexts upon receiving rotated X.509-SVIDs.
- Services MUST enforce sub-hour SVID expiration (15 to 60 minutes) and verify peer SPIFFE IDs against a strict zero-trust identity policy.
- Components NEVER accept insecure TLS configurations (e.g., 'rejectUnauthorized: false' or 'InsecureSkipVerify: true') when terminating or initiating mTLS connections.

## Bad vs Good Implementations
### Dynamic SPIFFE X.509-SVID In-Memory Context vs. Static Disk Cert Mounting

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Reading static certificates from disk creates high-privilege persistent attack surfaces and fails to rotate certificates dynamically as they expire under sub-hour zero-trust TTL policies.
```typescript
import fs from 'node:fs';
import https from 'node:https';

// ANTI-PATTERN: Reading static, long-lived credentials from persistent disk or static secrets.
// Fails to handle automated sub-hour SVID rotation, leaks private keys to disk, and bypasses kernel attestation.
const serverOptions: https.ServerOptions = {
  key: fs.readFileSync('/etc/ssl/certs/service-key.pem'),
  cert: fs.readFileSync('/etc/ssl/certs/service-cert.pem'),
  ca: fs.readFileSync('/etc/ssl/certs/ca-bundle.pem'),
  requestCert: true,
  rejectUnauthorized: true
};

https.createServer(serverOptions, (req, res) => {
  res.writeHead(200);
  res.end('Authenticated via static certs');
}).listen(8443);
```

#### Production Standard (Correct)
> **Standard**: Connects directly to the SPIRE Agent's Unix Domain Socket, receives ephemeral X.509-SVIDs in memory, dynamically updates the TLS SecureContext via SNICallback upon SVID renewal, and strictly validates the peer's SPIFFE ID SAN.
```typescript
import tls from 'node:tls';
import https from 'node:https';
import { WorkloadApiClient } from '@spiffe/spiffe-node';

// PRODUCTION INVARIANT: Stream ephemeral SVIDs via Workload API over Unix Domain Socket with dynamic SecureContext updates.
async function createZeroTrustServer() {
  const client = new WorkloadApiClient({
    socketPath: process.env.SPIFFE_ENDPOINT_SOCKET ?? '/run/spire/sockets/agent.sock'
  });

  let currentContext: tls.SecureContext;

  // Stream X.509 SVIDs with automated sub-hour rotations without service interruption
  await client.watchX509Context((x509Context) => {
    const defaultSvid = x509Context.getDefaultSvid();
    const trustBundle = x509Context.getBundleForTrustDomain(defaultSvid.spiffeId.trustDomain);

    currentContext = tls.createSecureContext({
      cert: defaultSvid.certificates.join('\n'),
      key: defaultSvid.privateKey,
      ca: trustBundle.certificates.join('\n')
    });
  });

  const server = https.createServer({
    requestCert: true,
    rejectUnauthorized: true,
    SNICallback: (servername, cb) => cb(null, currentContext),
    // Extract and validate peer SPIFFE ID
    checkServerIdentity: (host, cert) => {
      const peerSpiffeId = cert.subjectaltname?.match(/URI:(spiffe:\/\/[^,\s]+)/)?.[1];
      const expectedTrustDomain = 'spiffe://production.corp.internal/ns/backend/sa/client-workload';
      if (!peerSpiffeId || peerSpiffeId !== expectedTrustDomain) {
        return new Error(`Unauthorized peer SPIFFE ID: ${peerSpiffeId}`);
      }
      return undefined;
    }
  });

  server.listen(8443);
}
```

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 Attestation & Socket Lease Standard

SPIFFE/SPIRE Ephemeral Workload Attestation & Socket Lease Standard defines an industrial-grade behavioral standard for security engineering. Enforces kernel-level cryptographic zero-trust workload identities through the SPIFFE Workload API over Unix Domain Sockets. Mandates ephemeral sub-hour X.509 SVID dynamic in-memory rotation, peer credential validation, and strictly prohibits static disk-mounted long-lived credentials. 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: Persisting static certificates or static tokens on disk instead of consuming dynamic SVID streams via the SPIFFE Workload API socket 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 DriftPersisting static certificates or static tokens on disk instead of consuming dynamic SVID streams via the SPIFFE Workload API socketCritical
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 interact with the SPIFFE Workload API exclusively over an authenticated Unix Domain Socket (e.g., 'unix

Engineers MUST ALWAYS interact with the SPIFFE Workload API exclusively over an authenticated Unix Domain Socket (e.g., 'unix:///run/spire/sockets/agent.sock').

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 X.509-SVID certificates, private keys, or bundle tokens to permanent or unencrypted disk storage.

Engineers MUST NOT persist X.509-SVID certificates, private keys, or bundle tokens to permanent or unencrypted disk storage.

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

Code SHOULD maintain dynamic, long-lived streaming connections to the Workload API and dynamically re-arm TLS SecureContexts upon receiving rotated X.509-SVIDs.

Code SHOULD maintain dynamic, long-lived streaming connections to the Workload API and dynamically re-arm TLS SecureContexts upon receiving rotated X.509-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

Services MUST enforce sub-hour SVID expiration (15 to 60 minutes) and verify peer SPIFFE IDs against a strict zero-trust identity policy.

Services MUST enforce sub-hour SVID expiration (15 to 60 minutes) and verify peer SPIFFE IDs against a strict zero-trust identity 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.
5

Components NEVER accept insecure TLS configurations (e.g., 'rejectUnauthorized

Components NEVER accept insecure TLS configurations (e.g., 'rejectUnauthorized: false' or 'InsecureSkipVerify: true') when terminating or initiating mTLS connections.

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 Attestation & Socket Lease Standard critical for AI coding assistants?

Enforces kernel-level cryptographic zero-trust workload identities through the SPIFFE Workload API over Unix Domain Sockets. Mandates ephemeral sub-hour X.509 SVID dynamic in-memory rotation, peer credential validation, and strictly prohibits static disk-mounted long-lived credentials. 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 (Persisting static certificates or static tokens on disk instead of consuming dynamic SVID streams via the SPIFFE Workload API socket) 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