Anonymous Intelligence Signal

Hono Framework Cookie Prefix Bypass: Parsing Gap Enables Attacker Override of Legitimate Cookies

human The Lab unverified 2026-04-23 18:54:16 Source: GitHub Issues

A parsing discrepancy in Hono, a web application framework supporting multiple JavaScript runtimes, allows cookie prefix protections to be bypassed through non-breaking space character injection. Versions prior to 4.12.12 contain a flaw where cookie names treated as distinct by browsers are normalized to the same key by the framework's parse() function, enabling attacker-controlled cookies to override legitimate ones. The vulnerability specifically undermines __Secure- and __Host- cookie prefix protections designed to mitigate session hijacking and cross-site request forgery attacks.

The core issue stems from inconsistent handling of whitespace prefixes during cookie name parsing. When a cookie name contains a non-breaking space character, browsers preserve the character as part of the name, while Hono's parse() method strips or normalizes this whitespace. An attacker can exploit this gap by setting a malicious cookie with a whitespace prefix that appears distinct to the browser but collapses to the same key as a legitimate cookie server-side. The framework then retrieves the attacker's value instead of the intended one, compromising authentication and session integrity.

The vulnerability affects applications relying on getCookie() for session management, authentication tokens, or security-sensitive operations. Developers using Hono with versions 4.12.5 through 4.12.11 are advised to upgrade to 4.12.12 immediately. Organizations should audit cookie-dependent code paths for potential exploitation vectors, particularly where user-supplied cookie values influence access control or privileged operations. The patch resolves the normalization inconsistency, restoring the expected behavior where prefix-protected cookies cannot be overridden by similarly named attacker-controlled values.