Skip to content

gh-161569: Check cookie policy before deleting expired cookies in http.cookiejar - #161570

Merged
Eclips4 merged 1 commit into
python:mainfrom
Eclips4:gh-161569-cookiejar-expired-cookie-policy
Nov 7, 2026
Merged

Eclips4 merged 1 commit into
python:mainfrom
Eclips4:gh-161569-cookiejar-expired-cookie-policy

Conversation

@Eclips4

@Eclips4 Eclips4 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

…in http.cookiejar

An expired Set-Cookie header was allowed to delete a stored cookie using
the Domain and Path attributes taken verbatim from the header, before
CookiePolicy.set_ok() was consulted. A response from one host could
therefore delete cookies belonging to any other domain in a shared jar.

The policy is now consulted before an expired cookie may delete an
existing one, as required by RFC 6265 section 5.3.

Co-authored-by: Victor Stinner <vstinner@python.org>

@vstinner vstinner left a comment

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.

LGTM

@Eclips4 Eclips4 added the type-security A security issue label Nov 7, 2026
@Eclips4
Eclips4 merged commit 8eb3d2c into python:main Nov 7, 2026
71 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @Eclips4 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12, 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Nov 7, 2026

Copy link
Copy Markdown

GH-161579 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 7, 2026
@bedevere-app

bedevere-app Bot commented Nov 7, 2026

Copy link
Copy Markdown

GH-161580 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 7, 2026
@bedevere-app

bedevere-app Bot commented Nov 7, 2026

Copy link
Copy Markdown

GH-161581 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Nov 7, 2026
@bedevere-app

bedevere-app Bot commented Nov 7, 2026

Copy link
Copy Markdown

GH-161582 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Nov 7, 2026
@bedevere-app

bedevere-app Bot commented Nov 7, 2026

Copy link
Copy Markdown

GH-161583 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.11 only security fixes label Nov 7, 2026
@Eclips4
Eclips4 deleted the gh-161569-cookiejar-expired-cookie-policy branch November 7, 2026 19:53
Eclips4 added a commit that referenced this pull request Nov 7, 2026
… in `http.cookiejar` (GH-161570) (#161579)

gh-161569: Check cookie policy before deleting expired cookies in `http.cookiejar` (GH-161570)

gh-161569: Check cookie policy before deleting expired cookies in http.cookiejar

An expired Set-Cookie header was allowed to delete a stored cookie using
the Domain and Path attributes taken verbatim from the header, before
CookiePolicy.set_ok() was consulted. A response from one host could
therefore delete cookies belonging to any other domain in a shared jar.

The policy is now consulted before an expired cookie may delete an
existing one, as required by RFC 6265 section 5.3.
(cherry picked from commit 8eb3d2c)

Co-authored-by: Kirill Podoprigora <kirill.bast@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Eclips4 added a commit that referenced this pull request Nov 7, 2026
… in `http.cookiejar` (GH-161570) (#161580)

gh-161569: Check cookie policy before deleting expired cookies in `http.cookiejar` (GH-161570)

gh-161569: Check cookie policy before deleting expired cookies in http.cookiejar

An expired Set-Cookie header was allowed to delete a stored cookie using
the Domain and Path attributes taken verbatim from the header, before
CookiePolicy.set_ok() was consulted. A response from one host could
therefore delete cookies belonging to any other domain in a shared jar.

The policy is now consulted before an expired cookie may delete an
existing one, as required by RFC 6265 section 5.3.
(cherry picked from commit 8eb3d2c)

Co-authored-by: Kirill Podoprigora <kirill.bast@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-security A security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants