fix: secure cookie handling for multi-level subdomains #422
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.
Problem
Session cookies with
Domain=.example.com; Secure
flag are not persisting when accessed from multi-level subdomains likedev.app.example.com
, despite working correctly on single-level subdomains likeapp.example.com
.Root Cause
Chrome's third-party storage partitioning features (
ThirdPartyStoragePartitioning
andPartitionedCookies
) interfere with the proper handling of secure domain cookies on multi-level subdomains. This causes Chrome to create non-secure, host-specific cookies instead of respecting the server's secure domain cookies.Evidence
SQLite cookie database analysis showed:
The host-specific non-secure cookie overrides the domain-wide secure cookie, preventing cookie transmission on HTTPS requests.
Solution
Disable
ThirdPartyStoragePartitioning
andPartitionedCookies
features via Chrome launch args to restore correct cookie handling behavior.Testing
Verified that this fix resolves the issue documented in #421 where:
dev.app.example.com
- cookies not sent (401 errors)dev.app.example.com
- cookies sent correctly (200 OK)Impact
Fixes #421