Fix ZonePathContextRewritingFilter rewriting __Host- cookie paths - #4048
Merged
Conversation
Contributor
Author
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes zone-path cookie rewriting for __Host--prefixed cookies in ZonePathContextRewritingFilter, aligning behavior with RFC 6265bis by ensuring these cookies keep Path=/ and aren’t rejected by browsers (avoiding downstream CSRF token mismatches).
Changes:
- Skip cookie path rewriting for
__Host-cookies when addingCookieobjects to the response. - Skip
Set-Cookieheader path rewriting for__Host-cookie names. - Add regression tests covering both
addCookie(...)andaddHeader("Set-Cookie", ...)cases for__Host-cookies.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
server/src/main/java/org/cloudfoundry/identity/uaa/zone/ZonePathContextRewritingFilter.java |
Excludes __Host- cookies from path rewriting for both Cookie objects and Set-Cookie headers. |
server/src/test/java/org/cloudfoundry/identity/uaa/zone/ZonePathContextRewritingFilterTests.java |
Adds regression tests to ensure __Host- cookie paths remain / under zone-path requests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
RFC 6265bis requires `__Host-` prefixed cookies to unconditionally have `Path=/`. The `ZonePathContextRewritingFilter` was incorrectly mutating the path of these cookies to the zone context path (e.g. `/auth`), causing browsers to reject them and resulting in CSRF token mismatch errors. This change updates the filter to exclude `__Host-` prefixed cookies from path rewriting, ensuring they retain their required `Path=/` attribute. Co-authored-by: Cursor <cursoragent@cursor.com>
joemahady-comm
force-pushed
the
TNZ-134079
branch
from
August 24, 2026 09:48
e93a290 to
0797d42
Compare
Contributor
Author
duanemay
approved these changes
Aug 24, 2026
strehle
approved these changes
Aug 24, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


RFC 6265bis requires
__Host-prefixed cookies to unconditionally havePath=/. TheZonePathContextRewritingFilterwas incorrectly mutating the path of these cookies to the zone context path (e.g./auth), causing browsers to reject them and resulting in CSRF token mismatch errors.This change updates the filter to exclude
__Host-prefixed cookies from path rewriting, ensuring they retain their requiredPath=/attribute.