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.
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.
How to Fix
Mitigation and Workarounds
---
Vulnerable Functions
Functions linked to known vulnerabilities.
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
