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

Confidential Enclave Hardware Attestation and Measurement Verification Gate

Cryptographically validates AMD SEV-SNP or Intel TDX hardware attestation evidence against vendor roots of trust and immutable workload launch measurements prior to provisioning production secrets. Mandates strict freshness nonce verification and ephemeral key-binding (ReportData) to prevent replay attacks and rogue pod impersonation.

Prohibited Anti-Pattern: Trusting In-Memory Enclave Identity Without Cryptographic Measurement Validation and Freshness Nonces

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Confidential Enclave Hardware Attestation and Measurement Verification Gate - Cryptographically validates AMD SEV-SNP or Intel TDX hardware attestation evidence against vendor roots of trust and immutable workload launch measurements prior to provisioning production secrets. Mandates strict freshness nonce verification and ephemeral key-binding (ReportData) to prevent replay attacks and rogue pod impersonation.
globs: src/security/**/*.{ts,js,go,rs}, src/attestation/**/*.{ts,js,go,rs}, src/kms/**/*.{ts,js,go,rs}, src/middleware/**/*.{ts,js}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/confidential-computing-attestation-gate-production-standard"
---

# Confidential Enclave Hardware Attestation and Measurement Verification Gate

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Trusting In-Memory Enclave Identity Without Cryptographic Measurement Validation and Freshness Nonces

## System Constraints
You are a Principal Engineer enforcing Confidential Computing (AMD SEV-SNP / Intel TDX) Pod Attestation Gate standards. Mandate cryptographic validation of enclave quotes, vendor certificate chains (Intel PCS / AMD KDS), launch measurements (MRTD/RTMR or LD/Policy), and ephemeral key-binding before releasing mTLS keys or decryption seeds.

## Strict Guidelines
- Engineers MUST ALWAYS bind the enclave's ephemeral public key or session material into the quote's report data (e.g., SHA-512 over public key and nonce) to prevent quote-forwarding attacks.
- Engineers MUST ALWAYS enforce strict server-side nonce generation and validation with short TTLs (< 30 seconds) to prevent replay of valid attestation evidence.
- Services MUST verify the full hardware root-of-trust certificate chain against official vendor CRLs/endpoints (Intel PCS or AMD KDS) and reject expired, revoked, or untrusted TCBs.
- Services MUST match hardware launch measurements (Intel TDX MRTD/RTMR0-3 or AMD SEV-SNP launch digest/ID) strictly against an immutable, cryptographically signed baseline manifest.
- Components NEVER fall back to bypass mode, insecure defaults, or mock hardware reports in production or staging environments.
- Engineers MUST NOT cache verification decisions across pod lifecycle restarts or grant secrets via static container volume mounts without in-enclave attestation.

## Bad vs Good Implementations
### Attestation Verification Gate for Workload Secret Provisioning

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The code omits verification of the hardware vendor certificate chain (Intel/AMD), performs no freshness nonce validation (allowing replay attacks), fails to check launch measurements against approved baselines, and does not verify that the ephemeral public key is bound to the enclave's hardware ReportData.
```typescript
import { Request, Response } from 'express';
import { kmsClient } from './kms';

interface AttestationRequest {
  podId: string;
  quoteBase64: string;
  ephemeralPubKey: string;
}

export async function handleProvisionSecrets(req: Request, res: Response) {
  const { podId, quoteBase64, ephemeralPubKey } = req.body as AttestationRequest;

  // CRITICAL SECURITY FLAW: Accepts quote without verifying vendor root-of-trust,
  // fails to validate freshness nonce (replay vulnerability), and does not match
  // launch measurements against authorized baseline policies.
  const rawQuote = Buffer.from(quoteBase64, 'base64');
  if (rawQuote.length === 0) {
    return res.status(400).json({ error: 'Missing quote' });
  }

  // Insecure: Direct secret release based only on podId
  const mtlsPrivateKey = await kmsClient.getSecret(`mtls-key-${podId}`);
  return res.json({ mtlsPrivateKey });
}
```

#### Production Standard (Correct)
> **Standard**: The code enforces single-use server nonce consumption, validates that the enclave quote binds the ephemeral public key via ReportData, verifies the hardware vendor cryptographic signature, performs constant-time measurement verification against approved baseline hashes, and securely seals the secret payload to the verified enclave key.
```typescript
import { Request, Response } from 'express';
import crypto from 'node:crypto';
import { verifyHardwareQuote, getExpectedMeasurementPolicy, consumeActiveNonce } from './attestation-verifier';
import { kmsClient } from './kms';

interface SecureAttestationPayload {
  podId: string;
  nonceId: string;
  quoteBytesBase64: string;
  ephemeralClientPublicKeyDer: string;
}

export async function handleProvisionSecrets(req: Request, res: Response) {
  const { podId, nonceId, quoteBytesBase64, ephemeralClientPublicKeyDer } = req.body as SecureAttestationPayload;

  // 1. Consume and validate freshness nonce (strictly single-use, preventing replay)
  const expectedNonce = await consumeActiveNonce(nonceId);
  if (!expectedNonce) {
    return res.status(401).json({ error: 'Invalid, expired, or replayed nonce challenge' });
  }

  const quoteBuffer = Buffer.from(quoteBytesBase64, 'base64');
  const clientPubKeyBuffer = Buffer.from(ephemeralClientPublicKeyDer, 'base64');

  // 2. Derive expected REPORT_DATA: SHA-512(ephemeralPublicKey || nonce)
  const expectedReportData = crypto.createHash('sha512')
    .update(clientPubKeyBuffer)
    .update(expectedNonce)
    .digest();

  // 3. Cryptographically verify hardware quote against manufacturer Root-of-Trust (AMD KDS / Intel PCS)
  const verificationResult = await verifyHardwareQuote(quoteBuffer, {
    expectedReportData,
    allowedEnclaveTypes: ['AMD_SEV_SNP', 'INTEL_TDX']
  });

  if (!verificationResult.isValid || !verificationResult.report) {
    return res.status(403).json({ error: 'Hardware attestation cryptographic verification failed' });
  }

  // 4. Strict measurement verification against authorized signed workload policy
  const baselinePolicy = await getExpectedMeasurementPolicy(podId);
  const measurementMatches = crypto.timingSafeEqual(
    Buffer.from(verificationResult.report.launchMeasurement, 'hex'),
    Buffer.from(baselinePolicy.expectedMeasurement, 'hex')
  );

  if (!measurementMatches || verificationResult.report.tcbStatus !== 'UpToDate') {
    return res.status(403).json({ error: 'Enclave launch measurements or TCB status do not meet baseline' });
  }

  // 5. Encrypt secret to enclave's attested ephemeral public key before transmission
  const mtlsPrivateKey = await kmsClient.getSecret(`mtls-key-${podId}`);
  const encryptedSecretPackage = crypto.publicEncrypt(
    {
      key: clientPubKeyBuffer,
      padding: crypto.constants.RSA_PKCS1_OAEP_PADDING,
      oaepHash: 'sha256'
    },
    Buffer.from(mtlsPrivateKey, 'utf-8')
  );

  return res.json({ encryptedPayload: encryptedSecretPackage.toString('base64') });
}
```

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: Confidential Enclave Hardware Attestation and Measurement Verification Gate

Confidential Enclave Hardware Attestation and Measurement Verification Gate defines an industrial-grade behavioral standard for security engineering. Cryptographically validates AMD SEV-SNP or Intel TDX hardware attestation evidence against vendor roots of trust and immutable workload launch measurements prior to provisioning production secrets. Mandates strict freshness nonce verification and ephemeral key-binding (ReportData) to prevent replay attacks and rogue pod impersonation. 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: Trusting In-Memory Enclave Identity Without Cryptographic Measurement Validation and Freshness Nonces 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 DriftTrusting In-Memory Enclave Identity Without Cryptographic Measurement Validation and Freshness NoncesCritical
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 bind the enclave's ephemeral public key or session material into the quote's report data (e.g., SHA-512 over public key and nonce) to prevent quote-forwarding attacks.

Engineers MUST ALWAYS bind the enclave's ephemeral public key or session material into the quote's report data (e.g., SHA-512 over public key and nonce) to prevent quote-forwarding attacks.

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 enforce strict server-side nonce generation and validation with short TTLs (< 30 seconds) to prevent replay of valid attestation evidence.

Engineers MUST ALWAYS enforce strict server-side nonce generation and validation with short TTLs (< 30 seconds) to prevent replay of valid attestation evidence.

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 verify the full hardware root-of-trust certificate chain against official vendor CRLs/endpoints (Intel PCS or AMD KDS) and reject expired, revoked, or untrusted TCBs.

Services MUST verify the full hardware root-of-trust certificate chain against official vendor CRLs/endpoints (Intel PCS or AMD KDS) and reject expired, revoked, or untrusted TCBs.

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 match hardware launch measurements (Intel TDX MRTD/RTMR0-3 or AMD SEV-SNP launch digest/ID) strictly against an immutable, cryptographically signed baseline manifest.

Services MUST match hardware launch measurements (Intel TDX MRTD/RTMR0-3 or AMD SEV-SNP launch digest/ID) strictly against an immutable, cryptographically signed baseline manifest.

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 bypass mode, insecure defaults, or mock hardware reports in production or staging environments.

Components NEVER fall back to bypass mode, insecure defaults, or mock hardware reports in production or staging environments.

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

Engineers MUST NOT cache verification decisions across pod lifecycle restarts or grant secrets via static container volume mounts without in-enclave attestation.

Engineers MUST NOT cache verification decisions across pod lifecycle restarts or grant secrets via static container volume mounts without in-enclave 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 Confidential Enclave Hardware Attestation and Measurement Verification Gate critical for AI coding assistants?

Cryptographically validates AMD SEV-SNP or Intel TDX hardware attestation evidence against vendor roots of trust and immutable workload launch measurements prior to provisioning production secrets. Mandates strict freshness nonce verification and ephemeral key-binding (ReportData) to prevent replay attacks and rogue pod impersonation. 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 (Trusting In-Memory Enclave Identity Without Cryptographic Measurement Validation and Freshness Nonces) 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

Confidential