/

CVE-2026-42544

Severity:

HIGH RISK

(7.5)

Improper Input Validation / Robustness Issue in Granian

CVE-2026-42544

Deferred

Vulnerability type

Category:

Improper Input Validation / Robustness Issue

CWE:

CWE-20, CWE-248, CWE-400

Impact:

Denial of Service (Worker Crash / Service Disruption)

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Granian's WebSocket handling path fails when processing Sec-WebSocket-Protocol headers containing non-ASCII bytes, causing the worker process to abort before the ASGI application is invoked.

An unauthenticated client can deliberately send malformed WebSocket upgrade requests to repeatedly crash workers, potentially degrading availability of Python applications served by Granian.

Affected context

The vulnerability appears in Granian HTTP server deployments (versions 1.2.0 through 2.7.4) that expose WebSocket endpoints or accept WebSocket upgrade requests.

It is triggered when the server constructs the WebSocket scope and encounters a Sec-WebSocket-Protocol header containing non-ASCII bytes.

The crash occurs inside Granian's internal WebSocket scope construction logic, prior to any ASGI application code running, so it can affect services regardless of how the application itself validates headers or protocols.

Exploit preconditions

  • Attack surface: Public-facing or internal HTTP interfaces served by Granian that accept WebSocket upgrade requests.
  • Required access: No authentication required; any network client capable of reaching the Granian listener can send malicious WebSocket upgrade requests.
  • Trigger point: A WebSocket handshake request whose Sec-WebSocket-Protocol header contains bytes outside the ASCII range, causing failure in the WebSocket scope construction path.
  • Why exploitation is possible: The server assumes the header is valid ASCII and does not robustly validate or sanitize it before using it in operations that cannot tolerate invalid byte sequences, leading to a controlled abort of the worker process (and thus a denial of service).

Why this happens

The core issue is improper input validation (CWE-20) on WebSocket-related HTTP headers, specifically the Sec-WebSocket-Protocol header.

Granian treats the header as if it always contains ASCII-compatible data and uses it during WebSocket scope construction without checking for non-ASCII bytes or handling decoding failures.

When non-ASCII bytes are present, the code path handling header normalization or conversion encounters unexpected data and aborts the worker, aligning with robustness issues such as CWE-248: Uncaught Exception and resource-related failures that can be classified under CWE-400 when repeatedly triggered.

Abstractly, this reflects a pattern where protocol-layer metadata is trusted to conform to specification encoding rules, and failure-handling logic does not gracefully degrade in the presence of malformed or adversarial input.

Potential impact

  • An attacker can cause repeated worker crashes, leading to partial or complete denial of service for applications using Granian.
  • Service responsiveness may degrade significantly under sustained malformed WebSocket traffic.
  • Operational monitoring and alerting systems may be flooded with crash logs and error signals, complicating incident response.
  • Depending on deployment topology (e.g., single-worker instances), the entire service may become unavailable until processes restart or the malicious traffic is mitigated.

General mitigation guidance

Effective mitigation focuses on strengthening input handling and isolation between untrusted network data and internal processing:

  • Enforce strict validation of WebSocket-related headers, particularly Sec-WebSocket-Protocol, ensuring they conform to ASCII and relevant protocol specifications before using them in decoding or scope construction.
  • Introduce defensive error-handling paths that treat malformed headers as protocol errors (e.g., rejecting the handshake) rather than allowing them to crash a worker.
  • Apply robust parsing utilities that explicitly handle invalid byte sequences, returning clear errors instead of propagating exceptions that terminate the process.
  • Consider architectural patterns that limit the blast radius of protocol parsing failures, such as supervising workers, employing process isolation, and using health checks with automatic restarts.
  • Use network-layer controls (reverse proxies, WAFs, or gateways) to pre-filter obviously malformed WebSocket upgrade requests and reduce direct exposure of backend servers to adversarial traffic.

How teams detect issues like this

Organizations can detect and monitor this class of vulnerability and its symptoms through multiple approaches:

  • Static analysis and code review: Look for code paths that assume HTTP header content is valid ASCII or UTF-8 without explicit checks, especially where conversion, decoding, or normalization is performed on header values.
  • Exception and panic monitoring: Instrument servers to capture and correlate worker crashes or panics with particular request patterns, such as malformed or unusual WebSocket headers.
  • Log analysis: Configure detailed logging for rejected or malformed WebSocket upgrade requests and observe whether specific headers consistently precede worker restarts.
  • Policy enforcement: Adopt coding guidelines requiring robust error handling around protocol parsing and enforce them with automated linters or review bots focused on parsing and boundary-validation routines.
  • Synthetic testing: Incorporate fuzzing or negative testing of WebSocket handshake flows (including invalid encodings and non-ASCII data) into QA pipelines to surface crashes before production deployment.

Sources

SourceLink
github.comgithub.com/emmett-framework/granian/security/advisories/GHSA-vrg7-482j-p6f6

Frequently asked

questions

The issue is broadly exploitable anywhere Granian is reachable over the network and accepts WebSocket upgrade requests. Any unauthenticated client can send specially crafted headers to attempt to crash workers, making internet-exposed instances particularly at risk.

No. Exploitation only requires the ability to establish a TCP connection to the Granian server and send an HTTP upgrade request for WebSocket with a Sec-WebSocket-Protocol header containing non-ASCII bytes. No credentials or prior access are necessary.

The safest pattern is to treat all client-controlled protocol fields as untrusted: validate header encodings and contents before using them, ensure conversions and decodes are wrapped in error handling that fails gracefully, and respond with protocol-compliant error codes instead of propagating exceptions to the process boundary.

Prevention strategies include adopting strict validation for all externally sourced data (particularly protocol metadata like headers), using well-tested parsing libraries, systematically handling decoding and parsing errors, integrating fuzz testing for protocol endpoints, and enforcing coding guidelines that prohibit unchecked assumptions about input encoding or structure.

Find out what's already
exploitable in your codebase.