Skip to content

do not let an insecure origin set or overwrite secure cookies - #953

Open
Hsnmohd wants to merge 1 commit into
apache:masterfrom
Hsnmohd:insecure-origin-secure-cookies
Open

Hsnmohd wants to merge 1 commit into
apache:masterfrom
Hsnmohd:insecure-origin-secure-cookies

Conversation

@Hsnmohd

@Hsnmohd Hsnmohd commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

an http:// response can plant or replace secure cookies: BasicSecureHandler enforces Secure only in match, never in validate, and ResponseProcessCookies adds the cookie even when it overwrites a Secure one with the same name, domain and path. a network attacker answering one cleartext request to a host the client also uses over https gets session fixation on the secure origin; reproduced with HttpClients against a local http server, after https://localhost set SESSION=victim; Secure, one http response with Set-Cookie: SESSION=attacker made the next https request send Cookie: SESSION=attacker. reject Secure cookies from an insecure origin in BasicSecureHandler.validate and drop an insecure cookie that would overlay a secure one in ResponseProcessCookies, per RFC 6265bis 5.7 (the "leave secure cookies alone" rule browsers enforce). regression tests in TestBasicCookieAttribHandlers and TestResponseProcessCookies.

* holds a secure cookie with the same name whose domain domain-matches the new cookie's
* domain (or vice versa) and whose path is path-matched by the new cookie's path.
*/
private static boolean overlaysSecureCookie(final Cookie cookie, final CookieStore cookieStore) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hsnmohd We usually do not implement RFC requirements piecemeal, especially if they are still in draft. Does RFC 6265 have this requirement?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. RFC 6265 lets an insecure origin both set a Secure cookie and replace one (5.3 step 11 matches on name, domain and path only), and it calls that out as a known limitation in 4.1.2.5 and 8.6 (Weak Integrity). Both checks here only exist in 6265bis. #869 already has the same two checks as part of the broader 6265bis work, so this one overlaps it; fine to close it in favor of that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. RFC 6265 lets an insecure origin both set a Secure cookie and replace one (5.3 step 11 matches on name, domain and path only), and it calls that out as a known limitation in 4.1.2.5 and 8.6 (Weak Integrity). Both checks here only exist in 6265bis. #869 already has the same two checks as part of the broader 6265bis work, so this one overlaps it; fine to close it in favor of that.

@Hsnmohd Yes, please close this PR in favor of #869.

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.

2 participants