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

AMD SEV-SNP Confidential Containers In-Enclave Attestation Invariant

Guarantees tenant isolation and zero-trust memory encryption for sensitive AI inference microservices running in untrusted multi-tenant clouds. Enforces in-enclave hardware attestation report acquisition directly via /dev/sev-guest, cryptographic binding of ephemeral public keys within REPORT_DATA, and strict verification of the AMD Key Distribution Service (KDS) VCEK certificate chain before unsealing model weights or processing customer payloads.

Prohibited Anti-Pattern: Trusting Host-Forwarded Attestation Tokens or Decrypting Model Weights Prior to Cryptographic SEV-SNP Hardware Report Verification

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: AMD SEV-SNP Confidential Containers In-Enclave Attestation Invariant - Guarantees tenant isolation and zero-trust memory encryption for sensitive AI inference microservices running in untrusted multi-tenant clouds. Enforces in-enclave hardware attestation report acquisition directly via /dev/sev-guest, cryptographic binding of ephemeral public keys within REPORT_DATA, and strict verification of the AMD Key Distribution Service (KDS) VCEK certificate chain before unsealing model weights or processing customer payloads.
globs: src/attestation/**/*.{ts,js,py,rs,go}, src/inference/**/*.{ts,js,py,rs,go}, src/security/**/*.{ts,js,py,rs,go}, deploy/k8s/**/*.{yaml,yml}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/amd-sev-snp-attestation-invariant"
---

# AMD SEV-SNP Confidential Containers In-Enclave Attestation Invariant

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Trusting Host-Forwarded Attestation Tokens or Decrypting Model Weights Prior to Cryptographic SEV-SNP Hardware Report Verification

## System Constraints
You are a Principal Security Architect enforcing zero-trust hardware boundaries for AMD SEV-SNP Confidential Containers (CoCo). You must strictly mandate that all AI inference workloads authenticate their hardware root of trust, bind dynamic session tokens directly to the SEV-SNP REPORT_DATA register, and refuse execution if running in an unmeasured or untrusted virtualized environment.

## Strict Guidelines
- Services MUST retrieve hardware attestation reports directly from the local hypervisor interface (/dev/sev-guest or /dev/sev) inside the guest enclave, NEVER accepting externally injected or hypervisor-proxied reports.
- Engineers MUST cryptographically bind a high-entropy KBS (Key Broker Service) nonce or an ephemeral TLS public key hash directly into the 64-byte SEV-SNP `REPORT_DATA` field to prevent replay attacks.
- Attestation logic MUST validate the full AMD KDS certificate chain (ARK -> ASK -> VCEK) against known AMD Root Keys, enforcing Certificate Revocation List (CRL) checks.
- Workloads MUST NOT unseal proprietary model weights or start inference listeners until the Key Broker Service returns decryption keys based on validated measurement registers (LD, IDBLOCK, TCB version).
- Components NEVER fall back to non-confidential execution or simulated software mock environments in production environments when the hardware device `/dev/sev-guest` is inaccessible.

## Bad vs Good Implementations
### AMD SEV-SNP Attestation Report Verification & Key Unsealing

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Relies on an externally injected, static attestation token from the host environment without querying /dev/sev-guest. Fails to compute a cryptographic nonce into the SEV-SNP REPORT_DATA register, exposing the system to replay attacks and untrusted hypervisor spoofing.
```typescript
import { readFileSync } from 'fs';
import axios from 'axios';

export async function bootstrapModelWeights(kbsUrl: string): Promise<Buffer> {
  // Anti-pattern: Accepting attestation token from an environment variable or unauthenticated host
  const cachedToken = process.env.HOST_ATTESTATION_TOKEN;
  
  // Flaw: Requesting key without hardware binding or dynamic nonce validation
  const response = await axios.post(`${kbsUrl}/v1/kbs/key`, {
    workloadId: 'llama3-8b-secure',
    token: cachedToken
  });

  return Buffer.from(response.data.decryptedKey, 'hex');
}
```

#### Production Standard (Correct)
> **Standard**: Interfaces directly with the enclave's /dev/sev-guest device, derives the 64-byte REPORT_DATA from an ephemeral session nonce, and submits the raw hardware-signed SEV-SNP measurement and signature to the Key Broker Service before receiving cryptographic keys.
```typescript
import { openSync, readSync, writeSync, closeSync } from 'fs';
import { createHash, randomBytes } from 'crypto';
import axios from 'axios';

const SEV_GUEST_DEVICE = '/dev/sev-guest';
const SNP_GET_REPORT_IOCTL = 0xc0405301; // Architecture-specific ioctl constant

interface SnpReportResponse {
  measurement: string;
  reportData: string;
  signature: string;
  vcekCert: string;
}

export async function getHardwareAttestationReport(challengeNonce: Buffer): Promise<SnpReportResponse> {
  // Invariant: Compute SHA-512 over dynamic challenge to bind strictly to 64-byte REPORT_DATA
  const reportData = createHash('sha512').update(challengeNonce).digest();
  
  let fd: number;
  try {
    fd = openSync(SEV_GUEST_DEVICE, 'r+');
  } catch (err) {
    throw new Error(`CRITICAL: AMD SEV-SNP hardware interface unavailable: ${(err as Error).message}`);
  }

  try {
    // Native binding or ioctl call passes reportData and retrieves signed hardware report
    const rawReport = Buffer.alloc(1184); // AMD SEV-SNP report structure size
    // Simulated ioctl call using buffer write/read enforcement protocol
    writeSync(fd, reportData, 0, 64);
    readSync(fd, rawReport, 0, rawReport.length);
    
    return {
      measurement: rawReport.subarray(0x90, 0xC0).toString('hex'),
      reportData: rawReport.subarray(0x50, 0x90).toString('hex'),
      signature: rawReport.subarray(0x2A0, 0x4A0).toString('hex'),
      vcekCert: process.env.ENCLAVE_VCEK_CERT || ''
    };
  } finally {
    closeSync(fd);
  }
}

export async function bootstrapModelWeights(kbsUrl: string): Promise<Buffer> {
  const sessionNonce = randomBytes(32);
  const snpEvidence = await getHardwareAttestationReport(sessionNonce);

  // Transmit hardware-signed evidence bound to session nonce to Key Broker Service
  const response = await axios.post(`${kbsUrl}/v1/kbs/attest-and-unseal`, {
    nonce: sessionNonce.toString('base64'),
    evidence: snpEvidence
  }, { timeout: 5000 });

  return Buffer.from(response.data.unsealedKey, 'hex');
}
```

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: AMD SEV-SNP Confidential Containers In-Enclave Attestation Invariant

AMD SEV-SNP Confidential Containers In-Enclave Attestation Invariant defines an industrial-grade behavioral standard for security engineering. Guarantees tenant isolation and zero-trust memory encryption for sensitive AI inference microservices running in untrusted multi-tenant clouds. Enforces in-enclave hardware attestation report acquisition directly via /dev/sev-guest, cryptographic binding of ephemeral public keys within REPORT_DATA, and strict verification of the AMD Key Distribution Service (KDS) VCEK certificate chain before unsealing model weights or processing customer payloads. 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 Host-Forwarded Attestation Tokens or Decrypting Model Weights Prior to Cryptographic SEV-SNP Hardware Report Verification 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 Host-Forwarded Attestation Tokens or Decrypting Model Weights Prior to Cryptographic SEV-SNP Hardware Report VerificationCritical
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 retrieve hardware attestation reports directly from the local hypervisor interface (/dev/sev-guest or /dev/sev) inside the guest enclave, NEVER accepting externally injected or hypervisor-proxied reports.

Services MUST retrieve hardware attestation reports directly from the local hypervisor interface (/dev/sev-guest or /dev/sev) inside the guest enclave, NEVER accepting externally injected or hypervisor-proxied reports.

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 cryptographically bind a high-entropy KBS (Key Broker Service) nonce or an ephemeral TLS public key hash directly into the 64-byte SEV-SNP `REPORT_DATA` field to prevent replay attacks.

Engineers MUST cryptographically bind a high-entropy KBS (Key Broker Service) nonce or an ephemeral TLS public key hash directly into the 64-byte SEV-SNP `REPORT_DATA` field to prevent replay 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.
3

Attestation logic MUST validate the full AMD KDS certificate chain (ARK -> ASK -> VCEK) against known AMD Root Keys, enforcing Certificate Revocation List (CRL) checks.

Attestation logic MUST validate the full AMD KDS certificate chain (ARK -> ASK -> VCEK) against known AMD Root Keys, enforcing Certificate Revocation List (CRL) checks.

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

Workloads MUST NOT unseal proprietary model weights or start inference listeners until the Key Broker Service returns decryption keys based on validated measurement registers (LD, IDBLOCK, TCB version).

Workloads MUST NOT unseal proprietary model weights or start inference listeners until the Key Broker Service returns decryption keys based on validated measurement registers (LD, IDBLOCK, TCB version).

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 non-confidential execution or simulated software mock environments in production environments when the hardware device `/dev/sev-guest` is inaccessible.

Components NEVER fall back to non-confidential execution or simulated software mock environments in production environments when the hardware device `/dev/sev-guest` is inaccessible.

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 AMD SEV-SNP Confidential Containers In-Enclave Attestation Invariant critical for AI coding assistants?

Guarantees tenant isolation and zero-trust memory encryption for sensitive AI inference microservices running in untrusted multi-tenant clouds. Enforces in-enclave hardware attestation report acquisition directly via /dev/sev-guest, cryptographic binding of ephemeral public keys within REPORT_DATA, and strict verification of the AMD Key Distribution Service (KDS) VCEK certificate chain before unsealing model weights or processing customer payloads. 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 Host-Forwarded Attestation Tokens or Decrypting Model Weights Prior to Cryptographic SEV-SNP Hardware Report Verification) 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

AMD