The vulnerability exists in the parse function within src/utils/cookie.ts of the Hono.js framework. The core of the issue is the use of JavaScript's String.prototype.trim() method on cookie names. This method removes a wide range of whitespace characters, including the non-breaking space (U+00A0). Browsers, however, adhere to a stricter standard (RFC 6265bis) and only trim standard spaces (0x20) and horizontal tabs (0x09) from cookie names.
This discrepancy allows an attacker to create a cookie with a name prefixed with a non-breaking space (e.g., "\u00a0__Host-session"). The browser would treat this as a distinct cookie from "__Host-session". However, when the hono application processes the cookie string using the parse function, the trim() method would strip the U+00A0 prefix, causing the malicious cookie to be identified as "__Host-session". This would lead to the malicious cookie's value overriding the legitimate one, bypassing cookie prefix protections (__Host- and __Secure-) and potentially leading to session fixation or hijacking.
The patch addresses this by replacing trim() with a new, stricter trimCookieWhitespace function that only removes spaces and tabs, aligning the server-side parsing behavior with that of browsers. The parseSigned function was also affected as it likely relies on parse for initial cookie processing.