You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[fresh] Form CSRF reader throws on a malformed Cookie header #2632
readCsrfToken throws when the request carries a Cookie header that @std/http cannot parse. The page then answers 500 instead of treating the request as having no token. Forms that disabled CSRF are affected too.
getCookies throws SyntaxError for headers such as Cookie: =x, Cookie: a=1;=x, and an empty Cookie header.
Call sites:
packages/fresh/src/application/builders/define-page/builder/form-support.ts:68 (POST). It runs before the csrf === false check on line 69, so forms that opt out also throw.
Send POST to any definePage form route with the header Cookie: =x.
Expected behavior
An unparsable Cookie header counts as "no token": a POST with CSRF enabled is rejected as a CSRF failure, a POST with csrf: false proceeds, and a GET renders with a fresh token.
Acceptance
readCsrfToken returns undefined for an unparsable Cookie header, proven by a unit test that fails on current main.
A POST with a malformed Cookie header gets the CSRF rejection response, not a 500.
A form with csrf: false accepts a POST with a malformed Cookie header.
A GET with a malformed Cookie header renders and sets a fresh token.
Activity