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

Confidential Computing, TPM 2.0 & AWS Nitro Enclaves Attestation

Production standard for confidential computing and hardware-rooted trust. Mandates cryptographic remote attestation using AWS Nitro Enclaves NSM (Nitro Security Module) or TPM 2.0 PCR registers, ephemeral KMS decryption, and zero host-level memory access to master signing keys.

Prohibited Anti-Pattern: AI places private signing keys or sensitive decryption secrets in standard container environment variables where root or host memory dumps can extract them.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Confidential Computing, TPM 2.0 & AWS Nitro Enclaves Attestation - Production standard for confidential computing and hardware-rooted trust. Mandates cryptographic remote attestation using AWS Nitro Enclaves NSM (Nitro Security Module) or TPM 2.0 PCR registers, ephemeral KMS decryption, and zero host-level memory access to master signing keys.
globs: **/enclave/**/*.py, **/attestation/**/*.go, **/*kms*.rs
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/confidential-computing-enclave-attestation"
---

# Confidential Computing, TPM 2.0 & AWS Nitro Enclaves Attestation

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: AI places private signing keys or sensitive decryption secrets in standard container environment variables where root or host memory dumps can extract them.

## System Constraints
You are a Confidential Computing and Cryptographic Hardware Security Architect. NEVER store sensitive master private keys in standard VM environments or plain container memory. Isolate cryptographic operations inside hardware-isolated enclaves (AWS Nitro Enclaves, AMD SEV-SNP) and mandate cryptographic attestation with PCR measurements before KMS key release.

## Strict Guidelines
- Execute critical cryptographic signing and decryption solely within isolated hardware enclaves with no persistent disk or external network interfaces.
- Enforce KMS key policies requiring valid Nitro Enclaves Attestation Document with expected PCR0, PCR1, and PCR2 hash measurements.
- Communicate between parent EC2 instance and Enclave strictly through vsock (AF_VSOCK) loopback channels.
- Never enable debug mode (nitro-cli run-enclave --debug-mode) in production enclaves, which allows console attachment.
- Rotate ephemeral enclave encryption keys on every session initialization.

## Bad vs Good Implementations
### Cryptographic Attestation and KMS Decryption inside AWS Nitro Enclave

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Environment variables are visible via /proc/$PID/environ, container crash dumps, and cloud metadata compromises, allowing rogue operators or attackers to steal critical private keys.
```python
# FATAL: Exposing master private key in plain container environment variable
import os

# Exposed to any user with root shell or kernel memory dump access
PRIVATE_KEY = os.environ["BLOCKCHAIN_SIGNING_KEY"]
def sign_transaction(tx_hash):
  return crypto_sign(tx_hash, PRIVATE_KEY)
```

#### Production Standard (Correct)
> **Standard**: Uses the AWS Nitro Security Module (/dev/nsm) to generate a hardware-signed attestation document. AWS KMS releases decrypted keys directly into enclave memory only if PCR measurements verify genuine un-tampered code.
```python
import socket
import json
from aws_nitro_enclaves_nsm import nsm_get_attestation_doc

def decrypt_with_attestation(encrypted_blob):
    # 1. Fetch hardware-signed Attestation Document from Nitro Security Module
    nsm_fd = open("/dev/nsm", "r+b")
    attestation_doc = nsm_get_attestation_doc(nsm_fd, public_key=None)
    
    # 2. Transmit attestation doc over secure vsock to AWS KMS
    # KMS releases plaintext key ONLY if PCR0/PCR1 hashes match the authorized enclave image
    kms_payload = {
        "CiphertextBlob": encrypted_blob,
        "Recipient": {"AttestationDocument": attestation_doc}
    }
    plaintext_key = request_kms_decrypt_via_vsock(kms_payload)
    return plaintext_key
```

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 Computing, TPM 2.0 & AWS Nitro Enclaves Attestation

Confidential Computing, TPM 2.0 & AWS Nitro Enclaves Attestation defines an industrial-grade behavioral standard for security engineering. Production standard for confidential computing and hardware-rooted trust. Mandates cryptographic remote attestation using AWS Nitro Enclaves NSM (Nitro Security Module) or TPM 2.0 PCR registers, ephemeral KMS decryption, and zero host-level memory access to master signing keys. 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: AI places private signing keys or sensitive decryption secrets in standard container environment variables where root or host memory dumps can extract them. 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 DriftAI places private signing keys or sensitive decryption secrets in standard container environment variables where root or host memory dumps can extract them.Critical
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

Execute critical cryptographic signing and decryption solely within isolated hardware enclaves with no persistent disk or external network interfaces.

Execute critical cryptographic signing and decryption solely within isolated hardware enclaves with no persistent disk or external network interfaces.

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

Enforce KMS key policies requiring valid Nitro Enclaves Attestation Document with expected PCR0, PCR1, and PCR2 hash measurements.

Enforce KMS key policies requiring valid Nitro Enclaves Attestation Document with expected PCR0, PCR1, and PCR2 hash 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.
3

Communicate between parent EC2 instance and Enclave strictly through vsock (AF_VSOCK) loopback channels.

Communicate between parent EC2 instance and Enclave strictly through vsock (AF_VSOCK) loopback channels.

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

Never enable debug mode (nitro-cli run-enclave --debug-mode) in production enclaves, which allows console attachment.

Never enable debug mode (nitro-cli run-enclave --debug-mode) in production enclaves, which allows console attachment.

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

Rotate ephemeral enclave encryption keys on every session initialization.

Rotate ephemeral enclave encryption keys on every session initialization.

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 Computing, TPM 2.0 & AWS Nitro Enclaves Attestation critical for AI coding assistants?

Production standard for confidential computing and hardware-rooted trust. Mandates cryptographic remote attestation using AWS Nitro Enclaves NSM (Nitro Security Module) or TPM 2.0 PCR registers, ephemeral KMS decryption, and zero host-level memory access to master signing keys. 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 (AI places private signing keys or sensitive decryption secrets in standard container environment variables where root or host memory dumps can extract them.) 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