PyPI: granian

CVE-2026-42544

Safety vulnerability ID: SFTY-20260506-16484

Safety legacy ID: pyup.io-96411

Affected versions of the granian package are vulnerable to Denial of Service due to an unhandled panic when constructing the WebSocket scope from a request whose Sec-WebSocket-Protocol header contains non-ASCII bytes. The flaw resides in the WebSocket scope construction path in src/asgi/utils.rs, where HeaderValue::to_str() returns an error for non-visible-ASCII bytes and the subsequent .unwrap() panics, which under the release build setting panic = "abort" terminates the worker process before the ASGI application is invoked. An unauthenticated remote attacker can send a single crafted WebSocket upgrade request with a malformed subprotocol header to abort one worker, and by repeating the request across workers can take the entire service offline.

Created at: Jul 5, 2026Updated at: Jul 5, 2026

Overview

Granian vulnerable to unauthenticated DoS via WebSocket subprotocol header panic

Advisory

Affected versions of the granian package are vulnerable to Denial of Service due to an unhandled panic when constructing the WebSocket scope from a request whose Sec-WebSocket-Protocol header contains non-ASCII bytes. The flaw resides in the WebSocket scope construction path in src/asgi/utils.rs, where HeaderValue::to_str() returns an error for non-visible-ASCII bytes and the subsequent .unwrap() panics, which under the release build setting panic = "abort" terminates the worker process before the ASGI application is invoked. An unauthenticated remote attacker can send a single crafted WebSocket upgrade request with a malformed subprotocol header to abort one worker, and by repeating the request across workers can take the entire service offline.

Affected Package

Affecting granian package, versions>=1.2.0,<2.7.4

Also affects

---

How to Fix

Upgradegranianto2.7.4or higher.

Mitigation and Workarounds

---

Vulnerable Functions

Functions linked to known vulnerabilities.

Vulnerable function data is available for Enterprise customers

Book a call with us to see Safety in action.

Safety

Verified by Safety

Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.

Learn more