This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: post-quantum-ml-kem-768-tls-enforcement

Post-Quantum ML-KEM-768 TLS 1.3 Handshake Enforcement Invariant

Enforces hybrid post-quantum key encapsulation mechanisms (X25519MLKEM768 or SecP256r1MLKEM768) exclusively over TLS 1.3 on all edge reverse proxies and ingress controllers. Eliminates classical-only key exchange fallback pathways to guarantee immunity against harvest-now-decrypt-later (HNDL) cryptographic attacks across internal and external microservice meshes.

Prohibited Anti-Pattern: Permitting Classical-Only TLS Key Exchange Groups (e.g., ECDHE X25519/secp256r1) Without Quantum-Resistant Hybrid Encapsulation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Post-Quantum ML-KEM-768 TLS 1.3 Handshake Enforcement Invariant - Enforces hybrid post-quantum key encapsulation mechanisms (X25519MLKEM768 or SecP256r1MLKEM768) exclusively over TLS 1.3 on all edge reverse proxies and ingress controllers. Eliminates classical-only key exchange fallback pathways to guarantee immunity against harvest-now-decrypt-later (HNDL) cryptographic attacks across internal and external microservice meshes.
globs: infra/**/*.ts, src/gateway/**/*.ts, src/infrastructure/**/*.ts, k8s/**/*.yaml, nginx/**/*.conf, envoy/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/post-quantum-ml-kem-768-tls-enforcement"
---

# Post-Quantum ML-KEM-768 TLS 1.3 Handshake Enforcement Invariant

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Permitting Classical-Only TLS Key Exchange Groups (e.g., ECDHE X25519/secp256r1) Without Quantum-Resistant Hybrid Encapsulation

## System Constraints
You are a Principal Security Architect enforcing Post-Quantum Cryptography (PQC) standards. You must mandate ML-KEM-768 hybrid key exchanges across all TLS 1.3 termination configurations, edge ingress definitions, and intra-service communication channels. Reject any configuration or client negotiation that allows classical-only key exchange fallback, ensuring protection against harvest-now-decrypt-later adversaries.

## Strict Guidelines
- Edge ingress configurations MUST restrict TLS protocols strictly to TLS 1.3 (`TLSv1.3`), explicitly disabling TLS 1.2 and earlier.
- Engineers MUST specify hybrid post-quantum curves with `X25519MLKEM768` (0x11ec / 0x6399) or `SecP256r1MLKEM768` as the primary and mandatory supported key exchange groups in proxy definitions (Envoy, NGINX, Node.js HTTPS servers, Cloudflare Workers).
- Services MUST NEVER configure fallback to classical-only key exchange groups (such as raw `X25519`, `P-256`, or `P-384`) in environments handling sensitive data subject to long-term confidentiality mandates.
- Proxy telemetry and security logging MUST capture negotiated TLS key exchange groups and alert on any handshake completion that lacks an ML-KEM hybrid exchange.
- Engineers MUST ensure upstream clusters and client connection pools enable ALPN and enforce strict hybrid PQC key exchange groups matching the edge gateway policy.

## Bad vs Good Implementations
### Edge Gateway TLS Configuration in Infrastructure-as-Code (Node.js/AWS CDK & Envoy)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The configuration allows TLSv1.2 and restricts key exchange curves to classical elliptic curves (prime256v1, X25519). Adversaries harvesting this traffic can decrypt captured sessions once cryptanalytically relevant quantum computers (CRQCs) become operational.
```typescript
import * as tls from 'node:tls';

// Anti-pattern: Relies on default OpenSSL/Node cipher suites and classical-only ECDHE
export const createSecureGatewayListener = () => {
  return tls.createServer({
    minVersion: 'TLSv1.2',
    maxVersion: 'TLSv1.3',
    // Vulnerable to HNDL: Uses classical X25519 or P-256 without post-quantum encapsulation
    ecdhCurve: 'prime256v1:X25519',
    ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256'
  });
};
```

#### Production Standard (Correct)
> **Standard**: Forces TLS 1.3 and explicitly requires X25519MLKEM768 or SecP256r1MLKEM768 hybrid key exchanges. Classical-only handshakes fail immediately at the edge proxy, neutralizing harvest-now-decrypt-later attacks.
```typescript
import * as tls from 'node:tls';

// Invariant: Enforce TLS 1.3 and hybrid ML-KEM-768 post-quantum key exchange exclusively
export const createSecureGatewayListener = () => {
  return tls.createServer({
    minVersion: 'TLSv1.3',
    maxVersion: 'TLSv1.3',
    // Strictly enforce hybrid post-quantum groups (X25519MLKEM768 or SecP256r1MLKEM768)
    ecdhCurve: 'X25519MLKEM768:SecP256r1MLKEM768',
    ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256',
    honorCipherOrder: true
  });
};
```

Recommended Agent Skills (askills.dev)

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

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Post-Quantum ML-KEM-768 TLS 1.3 Handshake Enforcement Invariant

Post-Quantum ML-KEM-768 TLS 1.3 Handshake Enforcement Invariant defines an industrial-grade behavioral standard for security engineering. Enforces hybrid post-quantum key encapsulation mechanisms (X25519MLKEM768 or SecP256r1MLKEM768) exclusively over TLS 1.3 on all edge reverse proxies and ingress controllers. Eliminates classical-only key exchange fallback pathways to guarantee immunity against harvest-now-decrypt-later (HNDL) cryptographic attacks across internal and external microservice meshes. 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: Permitting Classical-Only TLS Key Exchange Groups (e.g., ECDHE X25519/secp256r1) Without Quantum-Resistant Hybrid Encapsulation 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 DriftPermitting Classical-Only TLS Key Exchange Groups (e.g., ECDHE X25519/secp256r1) Without Quantum-Resistant Hybrid EncapsulationCritical
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

Edge ingress configurations MUST restrict TLS protocols strictly to TLS 1.3 (`TLSv1.3`), explicitly disabling TLS 1.2 and earlier.

Edge ingress configurations MUST restrict TLS protocols strictly to TLS 1.3 (`TLSv1.3`), explicitly disabling TLS 1.2 and earlier.

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 specify hybrid post-quantum curves with `X25519MLKEM768` (0x11ec / 0x6399) or `SecP256r1MLKEM768` as the primary and mandatory supported key exchange groups in proxy definitions (Envoy, NGINX, Node.js HTTPS servers, Cloudflare Workers).

Engineers MUST specify hybrid post-quantum curves with `X25519MLKEM768` (0x11ec / 0x6399) or `SecP256r1MLKEM768` as the primary and mandatory supported key exchange groups in proxy definitions (Envoy, NGINX, Node.js HTTPS servers, Cloudflare Workers).

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 NEVER configure fallback to classical-only key exchange groups (such as raw `X25519`, `P-256`, or `P-384`) in environments handling sensitive data subject to long-term confidentiality mandates.

Services MUST NEVER configure fallback to classical-only key exchange groups (such as raw `X25519`, `P-256`, or `P-384`) in environments handling sensitive data subject to long-term confidentiality mandates.

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

Proxy telemetry and security logging MUST capture negotiated TLS key exchange groups and alert on any handshake completion that lacks an ML-KEM hybrid exchange.

Proxy telemetry and security logging MUST capture negotiated TLS key exchange groups and alert on any handshake completion that lacks an ML-KEM hybrid exchange.

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

Engineers MUST ensure upstream clusters and client connection pools enable ALPN and enforce strict hybrid PQC key exchange groups matching the edge gateway policy.

Engineers MUST ensure upstream clusters and client connection pools enable ALPN and enforce strict hybrid PQC key exchange groups matching the edge gateway policy.

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 Post-Quantum ML-KEM-768 TLS 1.3 Handshake Enforcement Invariant critical for AI coding assistants?

Enforces hybrid post-quantum key encapsulation mechanisms (X25519MLKEM768 or SecP256r1MLKEM768) exclusively over TLS 1.3 on all edge reverse proxies and ingress controllers. Eliminates classical-only key exchange fallback pathways to guarantee immunity against harvest-now-decrypt-later (HNDL) cryptographic attacks across internal and external microservice meshes. 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 (Permitting Classical-Only TLS Key Exchange Groups (e.g., ECDHE X25519/secp256r1) Without Quantum-Resistant Hybrid Encapsulation) 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

Post-Quantum