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

Mandatory Hybrid ML-KEM-768/X25519 Key Encapsulation on Edge Ingress

Enforces a strict cryptographic invariant requiring all public edge ingress points and reverse proxies to mandate hybrid ML-KEM-768/X25519 (X25519MLKEM768) TLS 1.3 key exchange groups. This mitigates 'harvest-now-decrypt-later' (HNDL) quantum threats against high-value transactional flows by terminating legacy non-hybrid handshakes unconditionally on sensitive ingress pathways.

Prohibited Anti-Pattern: Permitting Pure Classical TLS Key Exchange (ECDHE/RSA) on High-Value Ingress

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Mandatory Hybrid ML-KEM-768/X25519 Key Encapsulation on Edge Ingress - Enforces a strict cryptographic invariant requiring all public edge ingress points and reverse proxies to mandate hybrid ML-KEM-768/X25519 (X25519MLKEM768) TLS 1.3 key exchange groups. This mitigates 'harvest-now-decrypt-later' (HNDL) quantum threats against high-value transactional flows by terminating legacy non-hybrid handshakes unconditionally on sensitive ingress pathways.
globs: infra/**/*.{tf,json,yaml,yml}, src/ingress/**/*.{ts,go,rs,py}, src/gateway/**/*.{ts,go,rs,py}, docker/nginx/**/*.{conf,template}, helm/**/*.{yaml,yml}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/pqc-hybrid-mlkem-x25519-ingress-invariant"
---

# Mandatory Hybrid ML-KEM-768/X25519 Key Encapsulation on Edge Ingress

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Permitting Pure Classical TLS Key Exchange (ECDHE/RSA) on High-Value Ingress

## System Constraints
You are a Principal Security Architect enforcing Post-Quantum Cryptography Hybrid ML-KEM/X25519 Ingress Negotiation Invariants. Mandate that all edge ingress terminating TLS 1.3 for transactional and sensitive APIs strictly negotiate hybrid post-quantum groups (X25519MLKEM768 or equivalent standardized IETF ML-KEM hybrids) and drop or segregate classical-only handshakes.

## Strict Guidelines
- Services MUST enforce TLS 1.3 exclusively on sensitive transactional API ingress endpoints, prohibiting TLS 1.2 or lower fallback.
- Engineers MUST configure TLS curves/groups to prioritize and enforce hybrid ML-KEM-768 with X25519 (e.g., 'X25519MLKEM768', 'x25519_mlkem768', or draft 'X25519Kyber768Draft00' during migration) ahead of pure classical groups.
- Components NEVER permit classical ECDHE/P-256 or pure X25519 negotiation without an active security exemption audit token and separate isolation zone.
- Ingress controllers MUST verify peer key encapsulation scheme via connection metadata hooks before forwarding requests with high-value payload headers.
- Edge gateway configurations MUST emit structured telemetry flags (`tls_pqc_negotiated: boolean`, `tls_named_group: string`) on every connection to verify 100% PQC adoption.

## Bad vs Good Implementations
### Edge Ingress Gateway TLS Policy (Node.js/Bun Runtime Gateway)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Configuring TLSv1.2 alongside classical ECDHE curves leaves recorded payloads vulnerable to future cryptanalysis under Shor's algorithm via store-now-decrypt-later tactics.
```typescript
import * as tls from 'node:tls';

// ANTI-PATTERN: Defaulting to classical elliptic curves susceptible to quantum HNDL attacks
export function createEdgeServer() {
  return tls.createServer({
    minVersion: 'TLSv1.2',
    // Relies on OpenSSL defaults or classical-only P-256 / pure X25519
    ecdhCurve: 'prime256v1:X25519',
    ciphers: 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384',
  });
}
```

#### Production Standard (Correct)
> **Standard**: Pinning to TLS 1.3 and mandating X25519MLKEM768 curves guarantees that intercepted handshakes remain secure against both classical adversaries and future quantum cryptanalytic attacks.
```typescript
import * as tls from 'node:tls';

// COMPLIANT: Enforcing TLS 1.3 and hybrid ML-KEM-768/X25519 post-quantum group invariant
const MANDATORY_PQC_GROUPS = 'X25519MLKEM768:x25519_kyber768';

export function createPQCEdgeServer(key: Buffer, cert: Buffer) {
  const server = tls.createServer({
    key,
    cert,
    minVersion: 'TLSv1.3',
    maxVersion: 'TLSv1.3',
    ecdhCurve: MANDATORY_PQC_GROUPS,
    honorCipherOrder: true
  });

  server.on('secureConnection', (socket: tls.TLSSocket) => {
    const negotiated = socket.getNegotiatedProtocol();
    const cipher = socket.getCipher();
    const ephemeralKey = socket.getEphemeralKeyInfo();

    const isHybridPQC = ephemeralKey && 
      (ephemeralKey.type === 'X25519MLKEM768' || ephemeralKey.name?.includes('MLKEM768'));

    if (!isHybridPQC) {
      socket.destroy(new Error('PQC_INVARIANT_VIOLATION: Non-hybrid key encapsulation rejected'));
    }
  });

  return server;
}
```

Recommended Agent Skills (askills.dev)

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

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Mandatory Hybrid ML-KEM-768/X25519 Key Encapsulation on Edge Ingress

Mandatory Hybrid ML-KEM-768/X25519 Key Encapsulation on Edge Ingress defines an industrial-grade behavioral standard for security engineering. Enforces a strict cryptographic invariant requiring all public edge ingress points and reverse proxies to mandate hybrid ML-KEM-768/X25519 (X25519MLKEM768) TLS 1.3 key exchange groups. This mitigates 'harvest-now-decrypt-later' (HNDL) quantum threats against high-value transactional flows by terminating legacy non-hybrid handshakes unconditionally on sensitive ingress pathways. 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 Pure Classical TLS Key Exchange (ECDHE/RSA) on High-Value Ingress 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 Pure Classical TLS Key Exchange (ECDHE/RSA) on High-Value IngressCritical
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 enforce TLS 1.3 exclusively on sensitive transactional API ingress endpoints, prohibiting TLS 1.2 or lower fallback.

Services MUST enforce TLS 1.3 exclusively on sensitive transactional API ingress endpoints, prohibiting TLS 1.2 or lower fallback.

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 configure TLS curves/groups to prioritize and enforce hybrid ML-KEM-768 with X25519 (e.g., 'X25519MLKEM768', 'x25519_mlkem768', or draft 'X25519Kyber768Draft00' during migration) ahead of pure classical groups.

Engineers MUST configure TLS curves/groups to prioritize and enforce hybrid ML-KEM-768 with X25519 (e.g., 'X25519MLKEM768', 'x25519_mlkem768', or draft 'X25519Kyber768Draft00' during migration) ahead of pure classical groups.

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

Components NEVER permit classical ECDHE/P-256 or pure X25519 negotiation without an active security exemption audit token and separate isolation zone.

Components NEVER permit classical ECDHE/P-256 or pure X25519 negotiation without an active security exemption audit token and separate isolation zone.

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 controllers MUST verify peer key encapsulation scheme via connection metadata hooks before forwarding requests with high-value payload headers.

Ingress controllers MUST verify peer key encapsulation scheme via connection metadata hooks before forwarding requests with high-value payload headers.

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 gateway configurations MUST emit structured telemetry flags (`tls_pqc_negotiated

Edge gateway configurations MUST emit structured telemetry flags (`tls_pqc_negotiated: boolean`, `tls_named_group: string`) on every connection to verify 100% PQC adoption.

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 Mandatory Hybrid ML-KEM-768/X25519 Key Encapsulation on Edge Ingress critical for AI coding assistants?

Enforces a strict cryptographic invariant requiring all public edge ingress points and reverse proxies to mandate hybrid ML-KEM-768/X25519 (X25519MLKEM768) TLS 1.3 key exchange groups. This mitigates 'harvest-now-decrypt-later' (HNDL) quantum threats against high-value transactional flows by terminating legacy non-hybrid handshakes unconditionally on sensitive ingress pathways. 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 Pure Classical TLS Key Exchange (ECDHE/RSA) on High-Value Ingress) 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

Mandatory