This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: atls-hardware-enclave-dynamic-verification-standard

Attested TLS (aTLS) Enclave Cryptographic Binding & Dynamic Verification Standard

Enforces strict cryptographic binding between TLS ephemeral session keys and hardware enclave attestation reports (AMD SEV-SNP, Intel SGX/TDX, AWS Nitro) within the TLS handshake. Guarantees zero-trust sovereign compute integrity by verifying hardware roots of trust, platform measurements, and public key binding before application data transit.

Prohibited Anti-Pattern: Decoupling Hardware Attestation from the TLS Handshake Allowing Man-in-the-Middle and Replay Attacks

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Attested TLS (aTLS) Enclave Cryptographic Binding & Dynamic Verification Standard - Enforces strict cryptographic binding between TLS ephemeral session keys and hardware enclave attestation reports (AMD SEV-SNP, Intel SGX/TDX, AWS Nitro) within the TLS handshake. Guarantees zero-trust sovereign compute integrity by verifying hardware roots of trust, platform measurements, and public key binding before application data transit.
globs: src/**/*.{ts,tsx}, lib/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/atls-hardware-enclave-dynamic-verification-standard"
---

# Attested TLS (aTLS) Enclave Cryptographic Binding & Dynamic Verification Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Decoupling Hardware Attestation from the TLS Handshake Allowing Man-in-the-Middle and Replay Attacks

## System Constraints
You are a Principal Security Architect enforcing Attested TLS (aTLS) Dynamic Verification standards. You must mandate that every sovereign compute peer validates cryptographic hardware quotes directly embedded in custom X.509 certificate extensions during the TLS handshake. Enforce unyielding verification of hardware root-of-trust certificates, strict measurement register matching (e.g., MRENCLAVE, launch digests), and cryptographic binding of the peer's public key to the attestation quote report data.

## Strict Guidelines
- Engineers MUST ALWAYS cryptographically bind the leaf TLS certificate's SubjectPublicKeyInfo (SPKI) hash directly into the hardware enclave quote's report_data or user_data field.
- Engineers MUST NOT perform attestation checks post-handshake at the application/HTTP layer, as this leaves sessions vulnerable to MITM interception and TLS termination proxies.
- Code MUST validate the complete platform attestation collateral chain directly against hardware manufacturer Root Certificates (e.g., AMD KDS, Intel PCS Root CA).
- Services MUST reject TLS handshakes immediately if enclave measurements (e.g., MRENCLAVE, MRSIGNER, TDX MRTD, or SEV-SNP policy) do not strictly match the authorized release whitelist.
- Components NEVER accept hardware quotes with expired collateral, revoked TCB status, debug flags enabled in production, or mismatched freshness nonces.

## Bad vs Good Implementations
### Dynamic aTLS Handshake Verification via X.509 Attestation Extension

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Deferring attestation verification to the application layer after a non-validating TLS handshake breaks cryptographic channel binding. An attacker can terminate the TLS connection and relay a legitimate attestation quote from a genuine enclave without running inside one.
```typescript
import * as tls from 'tls';

// ANTI-PATTERN: Standard mTLS without quote-to-public-key binding.
// Attestation is dangerously deferred to post-handshake application logic.
export async function connectToEnclave(host: string, port: number): Promise<tls.TLSSocket> {
  return new Promise((resolve, reject) => {
    const socket = tls.connect({
      host,
      port,
      rejectUnauthorized: false, // Insecurely bypassing TLS verification to check quote later
    }, () => {
      // Flaw: Attestation token requested over established TLS channel.
      // A malicious reverse proxy can MITM this channel and relay a cached quote.
      resolve(socket);
    });
    socket.on('error', reject);
  });
}
```

#### Production Standard (Correct)
> **Standard**: Validates the hardware attestation quote during the TLS handshake via `checkServerIdentity`. The leaf certificate's public key is directly verified to match the quote's embedded `report_data`, guaranteeing zero-trust channel binding and rendering MITM or quote relay attacks cryptographically impossible.
```typescript
import * as tls from 'tls';
import * as crypto from 'crypto';
import { verifyEnclaveQuote, ATLS_EXTENSION_OID } from '@attestation/core';

const EXPECTED_MEASUREMENT = '9b4f2c8d1e...'; // Whitelisted enclave measurement digest

export async function connectToEnclave(host: string, port: number): Promise<tls.TLSSocket> {
  return new Promise((resolve, reject) => {
    const socket = tls.connect({
      host,
      port,
      rejectUnauthorized: true,
      checkServerIdentity: (hostname, cert) => {
        // 1. Extract raw aTLS custom X.509 extension containing hardware quote & collateral
        const rawQuoteExtension = cert.raw;
        const attestationQuote = cert.extensions?.find(ext => ext.oid === ATLS_EXTENSION_OID)?.value;
        if (!attestationQuote) {
          return new Error('Peer rejected: Missing aTLS hardware attestation extension.');
        }

        // 2. Hash leaf certificate SubjectPublicKeyInfo (SPKI) for report_data binding
        const peerPubKeyHash = crypto.createHash('sha256').update(cert.pubkey).digest();

        // 3. Cryptographically verify quote against Hardware Root CA & assert report_data binding
        const verificationResult = verifyEnclaveQuote({
          quoteBytes: attestationQuote,
          expectedReportData: peerPubKeyHash,
          enforceProductionSecurity: true,
        });

        if (!verificationResult.isValid) {
          return new Error(`Attestation verification failed: ${verificationResult.failureReason}`);
        }

        // 4. Assert strict measurement equality against immutable release policy
        if (verificationResult.measurement !== EXPECTED_MEASUREMENT) {
          return new Error(`Mismatched enclave measurement: ${verificationResult.measurement}`);
        }

        return undefined; // Verification succeeded; allow TLS handshake to finalize
      },
    }, () => resolve(socket));
    
    socket.on('error', reject);
  });
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Attested TLS (aTLS) Enclave Cryptographic Binding & Dynamic Verification Standard

Attested TLS (aTLS) Enclave Cryptographic Binding & Dynamic Verification Standard defines an industrial-grade behavioral standard for security engineering. Enforces strict cryptographic binding between TLS ephemeral session keys and hardware enclave attestation reports (AMD SEV-SNP, Intel SGX/TDX, AWS Nitro) within the TLS handshake. Guarantees zero-trust sovereign compute integrity by verifying hardware roots of trust, platform measurements, and public key binding before application data transit. 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: Decoupling Hardware Attestation from the TLS Handshake Allowing Man-in-the-Middle and Replay Attacks 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 DriftDecoupling Hardware Attestation from the TLS Handshake Allowing Man-in-the-Middle and Replay AttacksCritical
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 cryptographically bind the leaf TLS certificate's SubjectPublicKeyInfo (SPKI) hash directly into the hardware enclave quote's report_data or user_data field.

Engineers MUST ALWAYS cryptographically bind the leaf TLS certificate's SubjectPublicKeyInfo (SPKI) hash directly into the hardware enclave quote's report_data or user_data field.

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 perform attestation checks post-handshake at the application/HTTP layer, as this leaves sessions vulnerable to MITM interception and TLS termination proxies.

Engineers MUST NOT perform attestation checks post-handshake at the application/HTTP layer, as this leaves sessions vulnerable to MITM interception and TLS termination proxies.

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 MUST validate the complete platform attestation collateral chain directly against hardware manufacturer Root Certificates (e.g., AMD KDS, Intel PCS Root CA).

Code MUST validate the complete platform attestation collateral chain directly against hardware manufacturer Root Certificates (e.g., AMD KDS, Intel PCS Root CA).

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 reject TLS handshakes immediately if enclave measurements (e.g., MRENCLAVE, MRSIGNER, TDX MRTD, or SEV-SNP policy) do not strictly match the authorized release whitelist.

Services MUST reject TLS handshakes immediately if enclave measurements (e.g., MRENCLAVE, MRSIGNER, TDX MRTD, or SEV-SNP policy) do not strictly match the authorized release whitelist.

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 hardware quotes with expired collateral, revoked TCB status, debug flags enabled in production, or mismatched freshness nonces.

Components NEVER accept hardware quotes with expired collateral, revoked TCB status, debug flags enabled in production, or mismatched freshness nonces.

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 Attested TLS (aTLS) Enclave Cryptographic Binding & Dynamic Verification Standard critical for AI coding assistants?

Enforces strict cryptographic binding between TLS ephemeral session keys and hardware enclave attestation reports (AMD SEV-SNP, Intel SGX/TDX, AWS Nitro) within the TLS handshake. Guarantees zero-trust sovereign compute integrity by verifying hardware roots of trust, platform measurements, and public key binding before application data transit. 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 (Decoupling Hardware Attestation from the TLS Handshake Allowing Man-in-the-Middle and Replay Attacks) 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

Attested