This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
backendcritical PriorityID: axum-hyper-v1-rapid-reset-mitigation-standard

Axum & Hyper v1 Deterministic HTTP/2 Rapid Reset Invariant

Enforces strict HTTP/2 and HTTP/3 stream lifecycle budgets on Axum and Hyper v1 services to eliminate CVE-2023-44487 Rapid Reset attacks. Requires deterministic per-connection reset quotas, bounded stream concurrency, and explicit connection shutdown when reset frequency thresholds are breached.

Prohibited Anti-Pattern: Default Axum/Hyper Server Configuration Permitting Unbounded RST_STREAM Cancellation Floods

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Axum & Hyper v1 Deterministic HTTP/2 Rapid Reset Invariant - Enforces strict HTTP/2 and HTTP/3 stream lifecycle budgets on Axum and Hyper v1 services to eliminate CVE-2023-44487 Rapid Reset attacks. Requires deterministic per-connection reset quotas, bounded stream concurrency, and explicit connection shutdown when reset frequency thresholds are breached.
globs: src/**/*.rs, crates/**/*.rs
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/axum-hyper-v1-rapid-reset-mitigation-standard"
---

# Axum & Hyper v1 Deterministic HTTP/2 Rapid Reset Invariant

> **Severity**: CRITICAL | **Category**: backend
> **Anti-Pattern Warning**: Default Axum/Hyper Server Configuration Permitting Unbounded RST_STREAM Cancellation Floods

## System Constraints
You are a Principal Rust Systems Architect enforcing deterministic HTTP/2 and HTTP/3 Rapid Reset (CVE-2023-44487) guardrails in Axum and Hyper v1. Mandate explicit connection-level stream quotas, bounded pending resets, and backpressure layers on all ingress services.

## Strict Guidelines
- Engineers MUST ALWAYS configure Hyper v1's HTTP/2 builder with explicit `max_concurrent_streams` (defaulting to <= 100) and `max_pending_accept_reset_streams` to cap RST_STREAM buffers.
- Engineers MUST NOT rely on unconfigured `axum::serve` on edge-facing or untrusted network boundaries without wrapping the listener in deterministic connection and rate budgets.
- Code SHOULD enforce connection-level keep-alive timeouts (`keep_alive_timeout`, `keep_alive_interval`) to evict non-responsive or malicious peers stalling event loops.
- Services MUST isolate ingress task spawning with Tokio join handles and supervisor tracking to prevent unbounded task allocations during cancellation floods.
- Components NEVER accept unbounded HTTP/2 frame sizes; `max_frame_size` and `initial_connection_window_size` MUST be strictly bounded.

## Bad vs Good Implementations
### Hyper v1 / Axum Manual Server Driver with Rapid Reset Mitigation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using unconfigured `axum::serve` accepts default HTTP/2 parameters. Malicious clients can send rapid streams accompanied by immediate RST_STREAM frames, consuming executor thread cycles without exceeding standard concurrency caps.
```rust
use axum::{routing::get, Router};
use tokio::net::TcpListener;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let app = Router::new().route("/health", get(|| async { "ok" }));
    let listener = TcpListener::bind("0.0.0.0:8080").await?;

    // CRITICAL FLAW: axum::serve uses default auto-engine without configuring
    // max_concurrent_streams or max_pending_accept_reset_streams, leaving the server
    // vulnerable to HTTP/2 Rapid Reset CPU exhaustion.
    axum::serve(listener, app).await?;
    Ok(())
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly binds Hyper v1's HTTP/2 configuration using `max_pending_accept_reset_streams(20)` and `max_concurrent_streams(100)`, deterministically bounding client-induced RST_STREAM queues and mitigating Rapid Reset attacks.
```rust
use axum::{routing::get, Router};
use hyper_util::rt::{TokioExecutor, TokioIo};
use hyper_util::server::conn::auto::Builder as AutoConnBuilder;
use std::{sync::Arc, time::Duration};
use tokio::net::TcpListener;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let app = Router::new().route("/health", get(|| async { "ok" }));
    let listener = TcpListener::bind("0.0.0.0:8080").await?;

    // PRODUCTION INVARIANT: Configure Hyper v1 Auto Builder with hard HTTP/2 budgets
    let mut auto_builder = AutoConnBuilder::new(TokioExecutor::new());
    auto_builder
        .http2()
        .max_concurrent_streams(100)
        .max_pending_accept_reset_streams(20)
        .initial_stream_window_size(65_535)
        .initial_connection_window_size(1_048_576)
        .keep_alive_interval(Duration::from_secs(30))
        .keep_alive_timeout(Duration::from_secs(10));

    let auto_builder = Arc::new(auto_builder);

    loop {
        let (stream, remote_addr) = listener.accept().await?;
        let io = TokioIo::new(stream);
        let builder = Arc::clone(&auto_builder);
        let app_service = app.clone();

        tokio::spawn(async move {
            let hyper_service = hyper_util::service::TowerToHyperService::new(app_service);
            if let Err(err) = builder.serve_connection_with_upgrades(io, hyper_service).await {
                tracing::debug!(peer = %remote_addr, "Connection terminated: {err}");
            }
        });
    }
}
```

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: Axum & Hyper v1 Deterministic HTTP/2 Rapid Reset Invariant

Axum & Hyper v1 Deterministic HTTP/2 Rapid Reset Invariant defines an industrial-grade behavioral standard for backend engineering. Enforces strict HTTP/2 and HTTP/3 stream lifecycle budgets on Axum and Hyper v1 services to eliminate CVE-2023-44487 Rapid Reset attacks. Requires deterministic per-connection reset quotas, bounded stream concurrency, and explicit connection shutdown when reset frequency thresholds are breached. 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: Default Axum/Hyper Server Configuration Permitting Unbounded RST_STREAM Cancellation Floods 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 DriftDefault Axum/Hyper Server Configuration Permitting Unbounded RST_STREAM Cancellation FloodsCritical
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 configure Hyper v1's HTTP/2 builder with explicit `max_concurrent_streams` (defaulting to <= 100) and `max_pending_accept_reset_streams` to cap RST_STREAM buffers.

Engineers MUST ALWAYS configure Hyper v1's HTTP/2 builder with explicit `max_concurrent_streams` (defaulting to <= 100) and `max_pending_accept_reset_streams` to cap RST_STREAM buffers.

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 rely on unconfigured `axum

Engineers MUST NOT rely on unconfigured `axum::serve` on edge-facing or untrusted network boundaries without wrapping the listener in deterministic connection and rate budgets.

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 SHOULD enforce connection-level keep-alive timeouts (`keep_alive_timeout`, `keep_alive_interval`) to evict non-responsive or malicious peers stalling event loops.

Code SHOULD enforce connection-level keep-alive timeouts (`keep_alive_timeout`, `keep_alive_interval`) to evict non-responsive or malicious peers stalling event loops.

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 isolate ingress task spawning with Tokio join handles and supervisor tracking to prevent unbounded task allocations during cancellation floods.

Services MUST isolate ingress task spawning with Tokio join handles and supervisor tracking to prevent unbounded task allocations during cancellation floods.

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 unbounded HTTP/2 frame sizes

Components NEVER accept unbounded HTTP/2 frame sizes; `max_frame_size` and `initial_connection_window_size` MUST be strictly bounded.

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 Axum & Hyper v1 Deterministic HTTP/2 Rapid Reset Invariant critical for AI coding assistants?

Enforces strict HTTP/2 and HTTP/3 stream lifecycle budgets on Axum and Hyper v1 services to eliminate CVE-2023-44487 Rapid Reset attacks. Requires deterministic per-connection reset quotas, bounded stream concurrency, and explicit connection shutdown when reset frequency thresholds are breached. 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 (Default Axum/Hyper Server Configuration Permitting Unbounded RST_STREAM Cancellation Floods) 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

Axum