Skip to content

gh-160300: Reject cookies with a negative version in http.cookiejar - #160301

Merged
gpshead merged 2 commits into
python:mainfrom
gpshead:scanfix-cookiejar-ta36i7v7
Oct 25, 2026
Merged

gpshead merged 2 commits into
python:mainfrom
gpshead:scanfix-cookiejar-ta36i7v7

Conversation

@gpshead

@gpshead gpshead commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

DefaultCookiePolicy only applied its domain checks to cookies with version 0 or a positive version, so a cookie with a negative Version attribute was accepted for, and returned to, a domain unrelated to the server that set it. Negative versions are now treated as invalid: the Set-Cookie header is ignored when parsed, like a non-numeric version already is, and set_ok_version() and return_ok_version() return false, which also covers cookies added with set_cookie() or loaded from a file saved earlier.

ANT-2026-TA36I7V7

@gpshead gpshead added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 22, 2026
@gpshead gpshead self-assigned this Oct 22, 2026
@gpshead
gpshead requested a review from JelleZijlstra October 22, 2026 18:46
@gpshead
gpshead marked this pull request as ready for review October 22, 2026 18:46
@gpshead gpshead added the sprint label Oct 23, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Sprint Oct 23, 2026
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Sprint Oct 23, 2026
@gpshead gpshead removed this from Sprint Oct 25, 2026
@gpshead gpshead removed the sprint label Oct 25, 2026
…ejar

DefaultCookiePolicy only applied its domain checks to cookies with
version 0 or a positive version.

ANT-2026-TA36I7V7
Match the domains used by test_negative_version.
@gpshead
gpshead force-pushed the scanfix-cookiejar-ta36i7v7 branch from f561420 to 4b129a7 Compare October 25, 2026 06:25
@gpshead
gpshead enabled auto-merge (squash) October 25, 2026 06:36
@gpshead
gpshead merged commit d59d968 into python:main Oct 25, 2026
53 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @gpshead 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 Oct 25, 2026

Copy link
Copy Markdown

GH-160645 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 Oct 25, 2026
@bedevere-app

bedevere-app Bot commented Oct 25, 2026

Copy link
Copy Markdown

GH-160646 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 Oct 25, 2026
@bedevere-app

bedevere-app Bot commented Oct 25, 2026

Copy link
Copy Markdown

GH-160647 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 Oct 25, 2026
@bedevere-app

bedevere-app Bot commented Oct 25, 2026

Copy link
Copy Markdown

GH-160648 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 Oct 25, 2026
@bedevere-app

bedevere-app Bot commented Oct 25, 2026

Copy link
Copy Markdown

GH-160649 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 Oct 25, 2026
gpshead added a commit that referenced this pull request Oct 25, 2026
…iejar (GH-160301) (#160645)

gh-160300: Reject cookies with a negative version in http.cookiejar (GH-160301)

DefaultCookiePolicy only applied its domain checks to cookies with
version 0 or a positive version.

ANT-2026-TA36I7V7
(cherry picked from commit d59d968)

Co-authored-by: Gregory P. Smith <[email protected]>
gpshead added a commit that referenced this pull request Oct 25, 2026
…iejar (GH-160301) (#160646)

gh-160300: Reject cookies with a negative version in http.cookiejar (GH-160301)

DefaultCookiePolicy only applied its domain checks to cookies with
version 0 or a positive version.

ANT-2026-TA36I7V7
(cherry picked from commit d59d968)

Co-authored-by: Gregory P. Smith <[email protected]>

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.

@gpshead can we please try to include the CVE number in the entry in the future, for people downstream?

Yhg1s pushed a commit that referenced this pull request Oct 25, 2026
…iejar (GH-160301) (#160647)

gh-160300: Reject cookies with a negative version in http.cookiejar (GH-160301)

DefaultCookiePolicy only applied its domain checks to cookies with
version 0 or a positive version.

ANT-2026-TA36I7V7
(cherry picked from commit d59d968)

Co-authored-by: Gregory P. Smith <[email protected]>
Yhg1s pushed a commit that referenced this pull request Oct 25, 2026
…iejar (GH-160301) (#160648)

gh-160300: Reject cookies with a negative version in http.cookiejar (GH-160301)

DefaultCookiePolicy only applied its domain checks to cookies with
version 0 or a positive version.

ANT-2026-TA36I7V7
(cherry picked from commit d59d968)

Co-authored-by: Gregory P. Smith <[email protected]>
pablogsal pushed a commit that referenced this pull request Oct 25, 2026
…iejar (GH-160301) (#160649)

gh-160300: Reject cookies with a negative version in http.cookiejar (GH-160301)

DefaultCookiePolicy only applied its domain checks to cookies with
version 0 or a positive version.

ANT-2026-TA36I7V7
(cherry picked from commit d59d968)

Co-authored-by: Gregory P. Smith <[email protected]>
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.

3 participants