fix(cookie): reject Set-Cookie domains that are public suffixes#2091
Merged
karlseguin merged 1 commit intoApr 7, 2026
Merged
Conversation
parseDomain() rejects bare TLDs (e.g. Domain=.io) but accepts multi-level public suffixes like .co.uk, .com.au, .co.jp. Per RFC 6265bis §5.7.3.10, user agents should reject cookies whose domain attribute is a public suffix. Chrome, Firefox, and Safari all enforce this using the Public Suffix List. The PSL data is already imported (Cookie.zig:26) and used in findSecondLevelDomain(), but parseDomain() does not consult it. This causes behavior differences vs Chrome when automating .co.uk / .com.au / .co.jp sites via CDP — cookies that Chrome silently drops are accepted by Lightpanda, polluting the cookie jar across unrelated sites in the same session.
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Collaborator
|
Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
parseDomain()rejects bare TLDs (e.g.Domain=.io) but accepts multi-level public suffixes like.co.uk,.com.au,.co.jp.Per RFC 6265bis §5.7.3.10, user agents should reject cookies whose domain attribute is a public suffix. Chrome, Firefox, and Safari all enforce this using the Public Suffix List.
The PSL data is already imported (
Cookie.zig:26) and used infindSecondLevelDomain()(line 559), butparseDomain()does not consult it.What this fixes
When automating
.co.uk/.com.au/.co.jpsites via CDP, cookies that Chrome silently drops are accepted by Lightpanda. This causes cookie jar pollution across unrelated sites in the same session, and behavior differences vs Chrome.For example, if a site sets
Set-Cookie: x=1; Domain=.co.uk, Chrome rejects it, but Lightpanda accepts it and sends that cookie to every.co.uksite visited afterward.Change
Two lines added after the existing TLD check (line 274):
Tests added
Domain=gov.uk/.gov.uk/api.gov.uk→ rejected (using test-mode PSL entries)Domain=example.gov.ukfromexample.gov.ukandsub.example.gov.uk→ accepted (legitimate subdomain cookies still work)Related: #2088 (also improves
parseDomain, different issue — empty domain handling)