This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: hybrid-pq-tls13-clienthello-fragmentation-guardrail

Hybrid Post-Quantum TLS 1.3 (ML-KEM-768) ClientHello Fragmentation Guardrail

Enforces strict ClientHello payload budgeting and key-share negotiation policies when deploying hybrid post-quantum algorithms like X25519MLKEM768. Prevents catastrophic middlebox packet drops and latency penalties caused by multi-segment IP/TCP fragmentation when the TLS 1.3 ClientHello exceeds standard MTU boundaries (~1460 byte MSS). Mandates single key-share advertisement, extension payload minimization, and automated fallback monitoring without downgrading cryptographic guarantees.

Prohibited Anti-Pattern: Multi-Group KeyShare Bloat Exceeding Standard MTU Causing Middlebox Blackholing

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Hybrid Post-Quantum TLS 1.3 (ML-KEM-768) ClientHello Fragmentation Guardrail - Enforces strict ClientHello payload budgeting and key-share negotiation policies when deploying hybrid post-quantum algorithms like X25519MLKEM768. Prevents catastrophic middlebox packet drops and latency penalties caused by multi-segment IP/TCP fragmentation when the TLS 1.3 ClientHello exceeds standard MTU boundaries (~1460 byte MSS). Mandates single key-share advertisement, extension payload minimization, and automated fallback monitoring without downgrading cryptographic guarantees.
globs: src/**/tls/**/*.{ts,js,go,rs,py}, src/**/network/**/*.{ts,js,go,rs,py}, src/**/client/**/*.{ts,js,go,rs,py}, infra/**/envoy*.{yaml,json}, infra/**/nginx*.conf
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/hybrid-pq-tls13-clienthello-fragmentation-guardrail"
---

# Hybrid Post-Quantum TLS 1.3 (ML-KEM-768) ClientHello Fragmentation Guardrail

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Multi-Group KeyShare Bloat Exceeding Standard MTU Causing Middlebox Blackholing

## System Constraints
You are a Principal Security and Network Architect enforcing strict invariants on Hybrid Post-Quantum TLS 1.3 handshakes (specifically ML-KEM-768/X25519MLKEM768). ML-KEM-768 public keys add 1,184 bytes to the handshake. Combined with standard TLS extensions (ALPN, SNI, supported versions, signature algorithms), unmanaged ClientHellos easily cross the ~1440-1460 byte TCP MSS threshold. This leads to multi-packet fragmentation, triggering silent drops by legacy enterprise middleboxes and stateful firewalls. You must enforce single key-share advertisement, eliminate extension bloat, budget total ClientHello size below standard MTU limits, and reject dual-share speculative handshakes.

## Strict Guidelines
- Engineers MUST ALWAYS restrict TLS 1.3 key_share extensions to a single preferred hybrid group (e.g., X25519MLKEM768) rather than speculatively advertising both classical and hybrid key shares simultaneously.
- Engineers MUST NOT allow total ClientHello byte length to exceed 1400 bytes unless explicitly running on verified jumbo-frame internal datacenter backbones.
- Code MUST rely on HelloRetryRequest (HRR) for servers that do not support the hybrid group instead of pre-populating multiple public keys in the initial ClientHello.
- Services MUST prune obsolete TLS extensions (e.g., excessive padding, redundant signature algorithms, oversized ticket buffers) when hybrid post-quantum groups are enabled.
- Components NEVER fall back to unencrypted or unauthenticated non-PQ TLS without metric emission, audit logging, and circuit-breaker telemetry for suspected middlebox interference.

## Bad vs Good Implementations
### TLS 1.3 Client Configuration with Hybrid ML-KEM-768

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Configuring multiple redundant curves alongside ML-KEM-768 and attaching large session resumption blobs causes the ClientHello to exceed typical MTU limits (~1460 byte TCP MSS). Middleboxes drop the subsequent TCP fragments, resulting in connection timeouts.
```typescript
import tls from 'node:tls';

// ANTI-PATTERN: Speculatively advertising multiple key shares and bloated extensions
// triggers IP/TCP fragmentation (>1500 bytes MTU), causing middlebox blackholing.
export function createBadTlsConnection(hostname: string) {
  return tls.connect({
    host: hostname,
    port: 443,
    minVersion: 'TLSv1.3',
    maxVersion: 'TLSv1.3',
    // Node/OpenSSL 3.x default might pack both X25519 and SecP256r1 alongside ML-KEM
    // if groups are misconfigured, causing massive ClientHello expansion.
    ecdhCurve: 'X25519MLKEM768:P-256:X25519',
    // Bloated session ticket and excessive signature schemes
    session: Buffer.alloc(1024),
    ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256',
  });
}
```

#### Production Standard (Correct)
> **Standard**: Specifying a single hybrid curve ('X25519MLKEM768') ensures only one public key is included in the initial key_share extension. Pruning extraneous ciphers and avoiding stale ticket injection keeps the ClientHello under 1380 bytes, safely fitting inside a single MSS frame.
```typescript
import tls from 'node:tls';

const MAX_CLIENT_HELLO_SAFE_BYTES = 1380;

export interface SecureTlsClientOptions {
  host: string;
  port?: number;
  enablePqHybrid?: boolean;
}

// PRODUCTION FIX: Enforce single preferred hybrid key-share, eliminate extension bloat,
// and rely on HelloRetryRequest (HRR) for classical-only upstream negotiation.
export function createSecurePqTlsConnection(options: SecureTlsClientOptions): tls.TLSSocket {
  const { host, port = 443, enablePqHybrid = true } = options;

  // Prioritize single hybrid group (X25519MLKEM768). Under TLS 1.3,
  // if the server does not support this group, it will issue a HelloRetryRequest (HRR)
  // rather than failing, avoiding speculative multi-key-share bloat.
  const ecdhCurve = enablePqHybrid ? 'X25519MLKEM768' : 'X25519';

  const socket = tls.connect({
    host,
    port,
    minVersion: 'TLSv1.3',
    maxVersion: 'TLSv1.3',
    ecdhCurve,
    // Restrict to essential modern cipher suites to minimize ClientHello footprint
    ciphers: 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384',
    // Do not attach oversized stale tickets that inflate initial packet
    session: undefined,
    servername: host,
    // Ensure ALPN is concise
    ALPNProtocols: ['h2', 'http/1.1']
  });

  socket.on('secureConnect', () => {
    const negotiatedGroup = (socket as unknown as { getNegotiatedGroup?: () => string }).getNegotiatedGroup?.();
    if (enablePqHybrid && negotiatedGroup && !negotiatedGroup.includes('MLKEM')) {
      // Emit telemetry when middlebox or server forced classical HRR fallback
      process.emitWarning(`[TLS-PQ-GUARD] Classical fallback occurred. Negotiated: ${negotiatedGroup}`);
    }
  });

  return socket;
}
```

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: Hybrid Post-Quantum TLS 1.3 (ML-KEM-768) ClientHello Fragmentation Guardrail

Hybrid Post-Quantum TLS 1.3 (ML-KEM-768) ClientHello Fragmentation Guardrail defines an industrial-grade behavioral standard for security engineering. Enforces strict ClientHello payload budgeting and key-share negotiation policies when deploying hybrid post-quantum algorithms like X25519MLKEM768. Prevents catastrophic middlebox packet drops and latency penalties caused by multi-segment IP/TCP fragmentation when the TLS 1.3 ClientHello exceeds standard MTU boundaries (~1460 byte MSS). Mandates single key-share advertisement, extension payload minimization, and automated fallback monitoring without downgrading cryptographic guarantees. 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: Multi-Group KeyShare Bloat Exceeding Standard MTU Causing Middlebox Blackholing 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 DriftMulti-Group KeyShare Bloat Exceeding Standard MTU Causing Middlebox BlackholingCritical
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 restrict TLS 1.3 key_share extensions to a single preferred hybrid group (e.g., X25519MLKEM768) rather than speculatively advertising both classical and hybrid key shares simultaneously.

Engineers MUST ALWAYS restrict TLS 1.3 key_share extensions to a single preferred hybrid group (e.g., X25519MLKEM768) rather than speculatively advertising both classical and hybrid key shares simultaneously.

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 allow total ClientHello byte length to exceed 1400 bytes unless explicitly running on verified jumbo-frame internal datacenter backbones.

Engineers MUST NOT allow total ClientHello byte length to exceed 1400 bytes unless explicitly running on verified jumbo-frame internal datacenter backbones.

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 rely on HelloRetryRequest (HRR) for servers that do not support the hybrid group instead of pre-populating multiple public keys in the initial ClientHello.

Code MUST rely on HelloRetryRequest (HRR) for servers that do not support the hybrid group instead of pre-populating multiple public keys in the initial ClientHello.

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 prune obsolete TLS extensions (e.g., excessive padding, redundant signature algorithms, oversized ticket buffers) when hybrid post-quantum groups are enabled.

Services MUST prune obsolete TLS extensions (e.g., excessive padding, redundant signature algorithms, oversized ticket buffers) when hybrid post-quantum groups are enabled.

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 fall back to unencrypted or unauthenticated non-PQ TLS without metric emission, audit logging, and circuit-breaker telemetry for suspected middlebox interference.

Components NEVER fall back to unencrypted or unauthenticated non-PQ TLS without metric emission, audit logging, and circuit-breaker telemetry for suspected middlebox interference.

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 Hybrid Post-Quantum TLS 1.3 (ML-KEM-768) ClientHello Fragmentation Guardrail critical for AI coding assistants?

Enforces strict ClientHello payload budgeting and key-share negotiation policies when deploying hybrid post-quantum algorithms like X25519MLKEM768. Prevents catastrophic middlebox packet drops and latency penalties caused by multi-segment IP/TCP fragmentation when the TLS 1.3 ClientHello exceeds standard MTU boundaries (~1460 byte MSS). Mandates single key-share advertisement, extension payload minimization, and automated fallback monitoring without downgrading cryptographic guarantees. 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 (Multi-Group KeyShare Bloat Exceeding Standard MTU Causing Middlebox Blackholing) 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

Hybrid