This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: spire-confidential-computing-attestation-invariant

Hardware-Rooted Platform Attestation Validation for SPIRE SVID Issuance

Enforces hardware-rooted cryptographic measurement validation (TPM 2.0 PCR quotes or AWS Nitro Enclave attestation documents) prior to issuing SPIFFE Verifiable Identity Documents (SVIDs). Prevents identity spoofing and lateral movement across multi-tenant cloud fabrics by ensuring workload identity issuance is cryptographically bound to verified platform firmware, boot sequences, and enclave enclave-held hashes.

Prohibited Anti-Pattern: Issuing SVIDs Based on Mutable Cloud Metadata or Unverified Node Selectors Without Hardware Attestation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Hardware-Rooted Platform Attestation Validation for SPIRE SVID Issuance - Enforces hardware-rooted cryptographic measurement validation (TPM 2.0 PCR quotes or AWS Nitro Enclave attestation documents) prior to issuing SPIFFE Verifiable Identity Documents (SVIDs). Prevents identity spoofing and lateral movement across multi-tenant cloud fabrics by ensuring workload identity issuance is cryptographically bound to verified platform firmware, boot sequences, and enclave enclave-held hashes.
globs: **/attestation/**/*.{go,rs,ts,py}, **/spire/**/*.{go,rs,ts,py}, **/nodeattestor/**/*.{go,rs,ts,py}, **/identity/**/*.{go,rs,ts,py}, **/config/spire/**/*.{yaml,conf,json}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/spire-confidential-computing-attestation-invariant"
---

# Hardware-Rooted Platform Attestation Validation for SPIRE SVID Issuance

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Issuing SVIDs Based on Mutable Cloud Metadata or Unverified Node Selectors Without Hardware Attestation

## System Constraints
You are a Principal Security Architect enforcing the SPIRE Confidential Computing TPM 2.0 / Nitro Attestation Invariant. You must guarantee that no SPIFFE SVID is issued without strict, non-bypassable cryptographic validation of platform hardware roots of trust (TPM 2.0 PCR quotes signed by an AK certified by an EK root, or AWS Nitro Enclave Attestation Documents signed by the AWS Nitro Root PKI). Reject any fallback to unverified hypervisor metadata, mutable cloud tags, or software-only assertions.

## Strict Guidelines
- Engineers MUST ALWAYS verify the full certificate chain of trust to a trusted hardware root (e.g., TPM Endorsement Key CA or AWS Nitro Attestation PKI) before parsing platform measurements.
- Engineers MUST ALWAYS cryptographically validate nonce freshness and signature validity on attestation quotes before inspecting PCR or PCR-equivalent hashes (e.g., PCR 0-7 for secure boot, PCR 8 for runtime integrity, or PCR0/PCR1/PCR2 for Nitro Enclaves).
- Engineers MUST NOT allow selector resolution or SVID signing when attestation payload measurements diverge from expected immutable platform baselines.
- Code MUST strictly reject requests with missing, replayed, or expired nonces to eliminate replay attacks across node reboots or compromised guest domains.
- Services MUST enforce cryptographic binding between the node public key submitted for identity minting and the public key attested inside the hardware quote (e.g., TPM AK quote extraData or Nitro Enclave user_data/public_key).
- Components NEVER issue wildcard or multi-tenant SVIDs based on soft host identity attributes like instance IDs, IP addresses, or environment tags.

## Bad vs Good Implementations
### Nitro Enclave Attestation Document Validation and Binding Verification

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The bad example parses an unverified JSON payload, relies on spoofable cloud instance IDs, fails to validate the cryptographic signature against the AWS Nitro root CA, ignores nonce validation (permitting replays), and skips matching expected PCR hashes before issuing an SVID.
```typescript
import { verifySignature } from './crypto';

interface AttestationRequest {
  instanceId: string;
  enclavePublicKey: string;
  attestationDocBase64: string;
}

// ANTI-PATTERN: Verifying instance metadata and skipping rigorous PKI chain and PCR comparison
export async function issueSVID(req: AttestationRequest): Promise<string> {
  const doc = JSON.parse(Buffer.from(req.attestationDocBase64, 'base64').toString('utf8'));
  
  // Insecure: Trusting self-reported instance metadata and unauthenticated payload
  if (!req.instanceId.startsWith('i-')) {
    throw new Error('Invalid instance');
  }

  // Insecure: No validation of Nitro PKI root, PCR0 hash match, or nonce freshness
  const isKeyPresent = doc.user_data && doc.user_data.includes(req.enclavePublicKey);
  if (!isKeyPresent) {
    throw new Error('Key mismatch');
  }

  return mintSVID({ spiffeId: `spiffe://example.org/node/${req.instanceId}` });
}

function mintSVID(payload: { spiffeId: string }): string {
  return 'x509-svid-token';
}
```

#### Production Standard (Correct)
> **Standard**: The good example validates the complete hardware root of trust: it verifies the COSE_Sign1 certificate chain against the trusted root PKI, guarantees nonce freshness to prevent replays, checks PCR0 against immutable expected baseline measurements, and cryptographically binds the SVID recipient public key to the hardware-attested user data.
```typescript
import { createVerify, X509Certificate } from 'node:crypto';
import * as cbor from 'cbor';

interface AttestationVerificationRequest {
  coseSign1Bytes: Buffer;
  expectedNonce: Buffer;
  expectedPCR0: Buffer;
  nodePublicKeyPem: string;
}

interface NitroPayload {
  module_id: string;
  timestamp: number;
  nonce: Buffer;
  pcrs: Record<number, Buffer>;
  certificate: Buffer;
  cabundle: Buffer[];
  public_key?: Buffer;
  user_data?: Buffer;
}

const AWS_NITRO_ROOT_CERT_PEM = process.env.AWS_NITRO_ROOT_CERT_PEM!;

export async function verifyEnclaveAndIssueSVID(req: AttestationVerificationRequest): Promise<string> {
  // 1. Parse COSE_Sign1 structure
  const [protectedHeaders, , payloadRaw, signature] = cbor.decodeFirstSync(req.coseSign1Bytes);
  const payload: NitroPayload = cbor.decodeFirstSync(payloadRaw);

  // 2. Validate Nonce freshness to eliminate replay attacks
  if (!req.expectedNonce.equals(payload.nonce)) {
    throw new Error('Attestation validation failed: Nonce mismatch or replay detected.');
  }

  // 3. Verify Hardware Root of Trust Chain (Nitro Root CA -> Intermediate CA -> Leaf)
  const leafCert = new X509Certificate(payload.certificate);
  const rootCert = new X509Certificate(AWS_NITRO_ROOT_CERT_PEM);
  if (!leafCert.verify(rootCert.publicKey)) {
    throw new Error('Attestation validation failed: Untrusted certificate chain.');
  }

  // 4. Validate Enclave Measurements (PCR0: Enclave Image Measurement)
  const measuredPCR0 = payload.pcrs[0];
  if (!measuredPCR0 || !measuredPCR0.equals(req.expectedPCR0)) {
    throw new Error('Attestation validation failed: Hardware PCR0 measurement tampered.');
  }

  // 5. Enforce Cryptographic Key Binding between Node Key and Hardware Document
  const expectedKeyDigest = Buffer.from(req.nodePublicKeyPem, 'utf8');
  if (!payload.user_data || !payload.user_data.equals(expectedKeyDigest)) {
    throw new Error('Attestation validation failed: Node identity key is not bound to attestation.');
  }

  return mintSVID({ spiffeId: `spiffe://example.org/enclave/${payload.module_id}` });
}

function mintSVID(claims: { spiffeId: string }): string {
  return `verified-svid-for-${claims.spiffeId}`;
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Hardware-Rooted Platform Attestation Validation for SPIRE SVID Issuance

Hardware-Rooted Platform Attestation Validation for SPIRE SVID Issuance defines an industrial-grade behavioral standard for security engineering. Enforces hardware-rooted cryptographic measurement validation (TPM 2.0 PCR quotes or AWS Nitro Enclave attestation documents) prior to issuing SPIFFE Verifiable Identity Documents (SVIDs). Prevents identity spoofing and lateral movement across multi-tenant cloud fabrics by ensuring workload identity issuance is cryptographically bound to verified platform firmware, boot sequences, and enclave enclave-held hashes. 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: Issuing SVIDs Based on Mutable Cloud Metadata or Unverified Node Selectors Without Hardware Attestation 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 DriftIssuing SVIDs Based on Mutable Cloud Metadata or Unverified Node Selectors Without Hardware AttestationCritical
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 verify the full certificate chain of trust to a trusted hardware root (e.g., TPM Endorsement Key CA or AWS Nitro Attestation PKI) before parsing platform measurements.

Engineers MUST ALWAYS verify the full certificate chain of trust to a trusted hardware root (e.g., TPM Endorsement Key CA or AWS Nitro Attestation PKI) before parsing platform measurements.

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 ALWAYS cryptographically validate nonce freshness and signature validity on attestation quotes before inspecting PCR or PCR-equivalent hashes (e.g., PCR 0-7 for secure boot, PCR 8 for runtime integrity, or PCR0/PCR1/PCR2 for Nitro Enclaves).

Engineers MUST ALWAYS cryptographically validate nonce freshness and signature validity on attestation quotes before inspecting PCR or PCR-equivalent hashes (e.g., PCR 0-7 for secure boot, PCR 8 for runtime integrity, or PCR0/PCR1/PCR2 for Nitro Enclaves).

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 allow selector resolution or SVID signing when attestation payload measurements diverge from expected immutable platform baselines.

Engineers MUST NOT allow selector resolution or SVID signing when attestation payload measurements diverge from expected immutable platform baselines.

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 strictly reject requests with missing, replayed, or expired nonces to eliminate replay attacks across node reboots or compromised guest domains.

Code MUST strictly reject requests with missing, replayed, or expired nonces to eliminate replay attacks across node reboots or compromised guest domains.

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

Services MUST enforce cryptographic binding between the node public key submitted for identity minting and the public key attested inside the hardware quote (e.g., TPM AK quote extraData or Nitro Enclave user_data/public_key).

Services MUST enforce cryptographic binding between the node public key submitted for identity minting and the public key attested inside the hardware quote (e.g., TPM AK quote extraData or Nitro Enclave user_data/public_key).

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.
6

Components NEVER issue wildcard or multi-tenant SVIDs based on soft host identity attributes like instance IDs, IP addresses, or environment tags.

Components NEVER issue wildcard or multi-tenant SVIDs based on soft host identity attributes like instance IDs, IP addresses, or environment tags.

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 Hardware-Rooted Platform Attestation Validation for SPIRE SVID Issuance critical for AI coding assistants?

Enforces hardware-rooted cryptographic measurement validation (TPM 2.0 PCR quotes or AWS Nitro Enclave attestation documents) prior to issuing SPIFFE Verifiable Identity Documents (SVIDs). Prevents identity spoofing and lateral movement across multi-tenant cloud fabrics by ensuring workload identity issuance is cryptographically bound to verified platform firmware, boot sequences, and enclave enclave-held hashes. 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 (Issuing SVIDs Based on Mutable Cloud Metadata or Unverified Node Selectors Without Hardware Attestation) 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

Hardware-Rooted