This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: post-quantum-hybrid-mlkem-tls-ingress-standard

Post-Quantum Hybrid ML-KEM TLS 1.3 Edge Termination Guardrail

Enforces mandatory hybrid post-quantum key exchange (X25519MLKEM768 / X25519Kyber768) and strict TLS 1.3 termination at enterprise ingress boundaries. Preempts 'Harvest Now, Decrypt Later' (HNDL) adversarial decryption attacks while guaranteeing fallback resilience and zero-overhead handshake latency.

Prohibited Anti-Pattern: Permitting Classical-Only TLS 1.2/1.3 Handshakes on Public Edge Ingress Exposing Inbound Payloads to Retroactive Cryptanalysis

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Post-Quantum Hybrid ML-KEM TLS 1.3 Edge Termination Guardrail - Enforces mandatory hybrid post-quantum key exchange (X25519MLKEM768 / X25519Kyber768) and strict TLS 1.3 termination at enterprise ingress boundaries. Preempts 'Harvest Now, Decrypt Later' (HNDL) adversarial decryption attacks while guaranteeing fallback resilience and zero-overhead handshake latency.
globs: infra/**/*.ts, src/infra/**/*.{ts,tsx}, src/edge/**/*.{ts,tsx}, src/ingress/**/*.{ts,tsx}, src/tls/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/post-quantum-hybrid-mlkem-tls-ingress-standard"
---

# Post-Quantum Hybrid ML-KEM TLS 1.3 Edge Termination Guardrail

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Permitting Classical-Only TLS 1.2/1.3 Handshakes on Public Edge Ingress Exposing Inbound Payloads to Retroactive Cryptanalysis

## System Constraints
You are a Principal Security Architect and Cryptographic Engineering Specialist enforcing post-quantum resilience at the network perimeter. Your mandate is to eliminate 'Harvest Now, Decrypt Later' (HNDL) vulnerabilities by strictly requiring hybrid classical/post-quantum key encapsulation mechanisms (ML-KEM / Kyber hybrid with X25519) and non-negotiable TLS 1.3 invariants across all edge ingress listeners, reverse proxies, and termination points.

## Strict Guidelines
- Edge listeners MUST terminate TLS using protocol version TLSv1.3 exclusively; earlier protocol versions (TLS 1.0, 1.1, 1.2) MUST be rejected with fatal protocol_version alerts.
- Key exchange ECDH curve configurations MUST prioritize hybrid post-quantum groups ('X25519MLKEM768' / 'X25519Kyber768Draft00') as primary supported groups ahead of classical standalone curves ('X25519', 'P-256').
- Engineers MUST NOT allow RSA key exchange, static Diffie-Hellman, or non-PFS cipher suites under any deployment profile.
- Ingress proxies MUST enforce strict session ticket encryption key (STEK) rotation schedules (< 24 hours) to bound the forward-secrecy compromise window.
- Edge listeners SHOULD expose structured telemetry counters denoting negotiated NamedGroup identifiers to trace client ML-KEM adoption and catch active downgrade attacks.
- Services MUST enable zero-round-trip (0-RTT) anti-replay defenses or completely disable early data to safeguard against quantum replay attacks on state-modifying requests.

## Bad vs Good Implementations
### Edge Ingress TLS 1.3 Configuration with ML-KEM-768 Hybrid Invariant

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Configuring TLSv1.2 as minimum version and restricting curves to classical NIST curves ('prime256v1:secp384r1') allows adversaries to capture current encrypted sessions and decrypt them retroactively using Shor's algorithm on future Cryptanalytically Relevant Quantum Computers (CRQCs).
```typescript
import * as tls from 'node:tls';
import * as fs from 'node:fs';

// ANTI-PATTERN: Classical-only curve negotiation vulnerable to HNDL
// Allows deprecated TLS 1.2 and lacks post-quantum key encapsulation.
export function createEdgeTerminationProxy(): tls.Server {
  return tls.createServer({
    cert: fs.readFileSync('/etc/ssl/edge.crt'),
    key: fs.readFileSync('/etc/ssl/edge.key'),
    // VULNERABLE: Permits legacy TLS versions and classical-only ECDH curves
    minVersion: 'TLSv1.2',
    maxVersion: 'TLSv1.3',
    ecdhCurve: 'prime256v1:secp384r1',
    ciphers: 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384',
    honorCipherOrder: true
  });
}
```

#### Production Standard (Correct)
> **Standard**: Mandates TLS 1.3 with X25519MLKEM768 (NIST FIPS 203) as the premier ECDH group, providing quantum-resistant confidentiality against HNDL attacks while maintaining standard elliptic curve fallback for legacy clients without performance degradation.
```typescript
import * as tls from 'node:tls';
import * as fs from 'node:fs';

// SECURE: Hybrid ML-KEM-768 + X25519 TLS 1.3 Termination Invariant
// Conforms to NIST FIPS 203 / IETF draft-ietf-tls-hybrid-design
export function createEdgeTerminationProxy(): tls.Server {
  const secureContextOptions: tls.TlsOptions = {
    cert: fs.readFileSync('/etc/ssl/edge.crt'),
    key: fs.readFileSync('/etc/ssl/edge.key'),
    // Invariant: Non-negotiable TLS 1.3 floor
    minVersion: 'TLSv1.3',
    maxVersion: 'TLSv1.3',
    // Invariant: Prioritize hybrid PQ groups (X25519MLKEM768) followed by classical fallback
    ecdhCurve: 'X25519MLKEM768:X25519Kyber768Draft00:X25519:P-256',
    // Invariant: Authenticated Encryption with Associated Data (AEAD) cipher suites for TLS 1.3
    ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256',
    honorCipherOrder: true,
    // Guard against 0-RTT replay exposure
    enableTrace: false
  };

  const server = tls.createServer(secureContextOptions);

  server.on('secureConnection', (socket: tls.TLSSocket) => {
    const negotiatedGroup = (socket as unknown as { getNegotiatedGroup?: () => string }).getNegotiatedGroup?.();
    if (!negotiatedGroup?.includes('MLKEM') && !negotiatedGroup?.includes('Kyber')) {
      // Telemetry log for tracking transition to PQ
      console.warn(`[PQ-MONITOR] Ingress client fallback to classical key exchange: ${negotiatedGroup ?? 'unknown'}`);
    }
  });

  return server;
}
```

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: Post-Quantum Hybrid ML-KEM TLS 1.3 Edge Termination Guardrail

Post-Quantum Hybrid ML-KEM TLS 1.3 Edge Termination Guardrail defines an industrial-grade behavioral standard for security engineering. Enforces mandatory hybrid post-quantum key exchange (X25519MLKEM768 / X25519Kyber768) and strict TLS 1.3 termination at enterprise ingress boundaries. Preempts 'Harvest Now, Decrypt Later' (HNDL) adversarial decryption attacks while guaranteeing fallback resilience and zero-overhead handshake latency. 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 1.2/1.3 Handshakes on Public Edge Ingress Exposing Inbound Payloads to Retroactive Cryptanalysis 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 1.2/1.3 Handshakes on Public Edge Ingress Exposing Inbound Payloads to Retroactive CryptanalysisCritical
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 listeners MUST terminate TLS using protocol version TLSv1.3 exclusively

Edge listeners MUST terminate TLS using protocol version TLSv1.3 exclusively; earlier protocol versions (TLS 1.0, 1.1, 1.2) MUST be rejected with fatal protocol_version alerts.

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

Key exchange ECDH curve configurations MUST prioritize hybrid post-quantum groups ('X25519MLKEM768' / 'X25519Kyber768Draft00') as primary supported groups ahead of classical standalone curves ('X25519', 'P-256').

Key exchange ECDH curve configurations MUST prioritize hybrid post-quantum groups ('X25519MLKEM768' / 'X25519Kyber768Draft00') as primary supported groups ahead of classical standalone curves ('X25519', 'P-256').

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

Engineers MUST NOT allow RSA key exchange, static Diffie-Hellman, or non-PFS cipher suites under any deployment profile.

Engineers MUST NOT allow RSA key exchange, static Diffie-Hellman, or non-PFS cipher suites under any deployment profile.

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

Ingress proxies MUST enforce strict session ticket encryption key (STEK) rotation schedules (< 24 hours) to bound the forward-secrecy compromise window.

Ingress proxies MUST enforce strict session ticket encryption key (STEK) rotation schedules (< 24 hours) to bound the forward-secrecy compromise window.

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

Edge listeners SHOULD expose structured telemetry counters denoting negotiated NamedGroup identifiers to trace client ML-KEM adoption and catch active downgrade attacks.

Edge listeners SHOULD expose structured telemetry counters denoting negotiated NamedGroup identifiers to trace client ML-KEM adoption and catch active downgrade 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.
6

Services MUST enable zero-round-trip (0-RTT) anti-replay defenses or completely disable early data to safeguard against quantum replay attacks on state-modifying requests.

Services MUST enable zero-round-trip (0-RTT) anti-replay defenses or completely disable early data to safeguard against quantum replay attacks on state-modifying requests.

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 Hybrid ML-KEM TLS 1.3 Edge Termination Guardrail critical for AI coding assistants?

Enforces mandatory hybrid post-quantum key exchange (X25519MLKEM768 / X25519Kyber768) and strict TLS 1.3 termination at enterprise ingress boundaries. Preempts 'Harvest Now, Decrypt Later' (HNDL) adversarial decryption attacks while guaranteeing fallback resilience and zero-overhead handshake latency. 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 1.2/1.3 Handshakes on Public Edge Ingress Exposing Inbound Payloads to Retroactive Cryptanalysis) 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