Skip to content

gh-145599: Reject control characters in http.cookies.Morsel.update() and http.cookies.BaseCookie.js_output#145600

Merged
vstinner merged 7 commits intopython:mainfrom
StanFromIreland:cookies
Mar 16, 2026
Merged

gh-145599: Reject control characters in http.cookies.Morsel.update() and http.cookies.BaseCookie.js_output#145600
vstinner merged 7 commits intopython:mainfrom
StanFromIreland:cookies

Conversation

@StanFromIreland
Copy link
Member

@StanFromIreland StanFromIreland commented Mar 6, 2026

Copy link
Contributor

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

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

One small comment, otherwise LGTM. Thank you!

@StanFromIreland StanFromIreland changed the title gh-145599: Reject control characters in more places in http.cookies.Morsel gh-145599: Reject control characters in http.cookies.Morsel.update() and http.cookies.BaseCookie.js_output Mar 6, 2026
@StanFromIreland StanFromIreland requested a review from gpshead March 6, 2026 18:08
@vstinner vstinner added the type-security A security issue label Mar 13, 2026
Co-authored-by: Victor Stinner <vstinner@python.org>
@StanFromIreland StanFromIreland added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Mar 13, 2026
Reject control characters in :class:`http.cookies.Morsel`
:meth:`~http.cookies.Morsel.update` and
:meth:`~http.cookies.BaseCookie.js_output`.
This addresses :cve:`2026-3644`.
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure about the CVE number?

Copy link
Member Author

@StanFromIreland StanFromIreland Mar 16, 2026

Choose a reason for hiding this comment

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

This one has been reserved for it, see the sidebar of the GHSA.

StanFromIreland and others added 2 commits March 16, 2026 12:39
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the updates.

@vstinner vstinner merged commit 57e88c1 into python:main Mar 16, 2026
51 checks passed
@miss-islington-app
Copy link

Thanks @StanFromIreland for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11, 3.12, 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 16, 2026
…okies.Morsel.update()` (pythonGH-145600)

Reject control characters in `http.cookies.Morsel.update()` and `http.cookies.BaseCookie.js_output`.
(cherry picked from commit 57e88c1cf95e1481b94ae57abe1010469d47a6b4)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 16, 2026
…okies.Morsel.update()` (pythonGH-145600)

Reject control characters in `http.cookies.Morsel.update()` and `http.cookies.BaseCookie.js_output`.
(cherry picked from commit 57e88c1cf95e1481b94ae57abe1010469d47a6b4)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Mar 16, 2026

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 16, 2026
…okies.Morsel.update()` (pythonGH-145600)

Reject control characters in `http.cookies.Morsel.update()` and `http.cookies.BaseCookie.js_output`.
(cherry picked from commit 57e88c1)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Mar 16, 2026
@bedevere-app
Copy link

bedevere-app bot commented Mar 16, 2026

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

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Mar 16, 2026
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 16, 2026
…okies.Morsel.update()` (pythonGH-145600)

Reject control characters in `http.cookies.Morsel.update()` and `http.cookies.BaseCookie.js_output`.
(cherry picked from commit 57e88c1)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
@miss-islington-app
Copy link

Sorry, @StanFromIreland and @vstinner, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 57e88c1cf95e1481b94ae57abe1010469d47a6b4 3.10

@bedevere-app
Copy link

bedevere-app bot commented Mar 16, 2026

GH-146025 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 Mar 16, 2026
@bedevere-app
Copy link

bedevere-app bot commented Mar 16, 2026

GH-146026 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 Mar 16, 2026
vstinner added a commit to vstinner/cpython that referenced this pull request Mar 16, 2026
…okies.Morsel.update()` (python#145600)

Reject control characters in `http.cookies.Morsel.update()` and `http.cookies.BaseCookie.js_output`.

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
(cherry picked from commit 57e88c1)
@bedevere-app
Copy link

bedevere-app bot commented Mar 16, 2026

GH-146027 is a backport of this pull request to the 3.10 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.10 only security fixes label Mar 16, 2026
@vstinner
Copy link
Member

Merged, thanks for your fix @StanFromIreland.

Are you sure about the CVE number?

This one has been reserved for it, see the sidebar of the GHSA.

Are you talking about https://github.com/python/cpython/security/advisories ? I don't see CVE 2026-3644 there.

@StanFromIreland StanFromIreland deleted the cookies branch March 16, 2026 13:50
vstinner added a commit that referenced this pull request Mar 16, 2026
…ookies.Morsel.update()` (GH-145600) (#146024)

gh-145599, CVE 2026-3644: Reject control characters in `http.cookies.Morsel.update()` (GH-145600)

Reject control characters in `http.cookies.Morsel.update()` and `http.cookies.BaseCookie.js_output`.
(cherry picked from commit 57e88c1)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
vstinner added a commit that referenced this pull request Mar 16, 2026
…ookies.Morsel.update()` (GH-145600) (#146023)

gh-145599, CVE 2026-3644: Reject control characters in `http.cookies.Morsel.update()` (GH-145600)

Reject control characters in `http.cookies.Morsel.update()` and `http.cookies.BaseCookie.js_output`.
(cherry picked from commit 57e88c1)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Arch Linux Usan Function 3.13 (no tier) has failed when building commit d16ecc6.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1601/builds/687) and take a look at the build logs.
  4. Check if the failure is related to this commit (d16ecc6) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1601/builds/687

Failed tests:

  • test_urllib2net

Summary of the results of the build (if available):

==

Click to see traceback logs
Note: switching to 'd16ecc6c3626f0e2cc8f08c309c83934e8a979dd'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at d16ecc6c362 [3.13] gh-145599, CVE 2026-3644: Reject control characters in `http.cookies.Morsel.update()` (GH-145600) (#146024)
Switched to and reset branch '3.13'

make: *** [Makefile:2252: buildbottest] Error 2

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.

4 participants