Skip to content

fix(headers): anchor SameSite value regex#11615

Open
jokull wants to merge 2 commits into
remix-run:mainfrom
jokull:fix-samesite-regex-anchor
Open

fix(headers): anchor SameSite value regex#11615
jokull wants to merge 2 commits into
remix-run:mainfrom
jokull:fix-samesite-regex-anchor

Conversation

@jokull

@jokull jokull commented Jul 17, 2026

Copy link
Copy Markdown

SetCookie matches the SameSite attribute value with /strict|lax|none/i — a substring test — and then capitalizes whatever it got, so any value containing one of those words is accepted and re-serialized:

new SetCookie('id=a; SameSite=nonesense').sameSite // "Nonesense"
new SetCookie('id=a; SameSite=strictly').sameSite  // "Strictly"

Both values violate the declared 'Strict' | 'Lax' | 'None' type and round-trip verbatim (id=a; SameSite=Nonesense).

  • Anchors the regex to /^(strict|lax|none)$/i so invalid values fall through to undefined, consistent with how malformed Expires and Max-Age are handled
  • Case-insensitive matching is preserved (SameSite=lax, SameSite=STRICT still normalize)
  • Adds a regression test and a patch change file

🤖 Generated with Claude Code

jokull and others added 2 commits July 16, 2026 23:17
The SameSite check used /strict|lax|none/i as a substring test, so any
value containing one of those words was accepted and capitalized:

  new SetCookie('id=a; SameSite=nonesense').sameSite // "Nonesense"
  new SetCookie('id=a; SameSite=strictly').sameSite  // "Strictly"

Both violate the declared 'Strict' | 'Lax' | 'None' type and
re-serialize verbatim. Anchoring the regex makes invalid values fall
through to undefined, matching how other malformed attributes are
handled.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant