GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update bundled setuptools provided by ensurepip in current 3.8.x through 3.11.x to include fix for CVE-2022-40897? · Issue #102202 · python/cpython

Update bundled setuptools provided by ensurepip in current 3.8.x through 3.11.x to include fix for CVE-2022-40897? #102202

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Update bundled setuptools provided by ensurepip in current 3.8.x through 3.11.x to include fix for CVE-2022-40897?#102202
Copy link
Labels
3.10 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of liferelease-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-ensurepiptype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-securityA security issueA security issue

Description

@LianwMS
LianwMS
opened on Feb 24, 2023
Issue body actions

Just found the image are impacted. Any fix plan?
GHSA-r9hx-vwmv-q579

Linked PRs

  • gh-102202: Update bundled setuptools to 67.4.0 #102208

Activity

Next
  1. LianwMS
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Feb 24, 2023
  2. hugovk
    added
    type-securityA security issueA security issue
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Feb 24, 2023
  3. hugovk commented on Feb 24, 2023

    @hugovk
    hugovk
    on Feb 24, 2023
    Member
    More actions

    CVE-2022-40897 is a ReDoS in setuptools, fixed in setuptools 65.5.1 (released Nov 4, 2022):

    • https://setuptools.pypa.io/en/latest/history.html#v65-5-1

    The 3.9 branch has setuptools-58.1.0-py3-none-any.whl (Sep 22, 2021):

    • https://github.com/python/cpython/tree/3.9/Lib/ensurepip/_bundled

    The main branch has setuptools-65.5.0-py3-none-any.whl (Oct 14, 2022):

    • https://github.com/python/cpython/tree/main/Lib/ensurepip/_bundled

    Before updating, Python 3.7-3.9 are security-fix only (https://devguide.python.org/versions/), let's first check with release managers @ambv and @ned-deily.

    A quick check shows the CI passes for 3.9: https://github.com/hugovk/cpython/actions/runs/4260373632

  4. hugovk
    added
    topic-ensurepip
    on Feb 24, 2023
  5. hugovk
    added a commit that references this issue on Feb 24, 2023

    pythongh-102202: Update bundled setuptools to 67.4.0

    27b76e6
  6. ned-deily
    added a commit that references this issue on Feb 26, 2023

    pythongh-102202: Update bundled setuptools to 67.4.0

    5a69282
  7. ned-deily commented on Feb 26, 2023

    @ned-deily
    ned-deily
    on Feb 26, 2023
    Member
    More actions

    Regarding backporting to 3.7, see my comment on the PR. In short, I don't want to backport this to 3.7 as the benefits are minimal and the risks are high.

    Reacted by Hugo van Kemenade
  8. LianwMS commented on Feb 27, 2023

    @LianwMS
    LianwMS
    on Feb 27, 2023
    Author
    More actions

    @hugovk @ned-deily So, the security should be fixed in 3.10-3.12. Correct?

  9. ned-deily commented on Feb 27, 2023

    @ned-deily
    ned-deily
    on Feb 27, 2023
    Member
    More actions

    So, the security should be fixed in 3.10-3.12. Correct?

    Ultimately, it's up to the release managers for those releases but I expect they will be updated soon.

    However, your original question seems to be about an Alpine docker image with python3.9. If so, you should check with the maintainer of that image. It should be a trivial matter to update the image with the new version of setuptools. Or you can just update it yourself when running the image by using some variant of:

    python3.9 -m pip install --upgrade pip
    python3.9 -m pip install --upgrade setuptools
    
    

    A CPython update to ensurepip by itself isn't going to make a difference to the Docker image.

    Reacted by Mohammad Mesbah
  10. hugovk commented on Apr 27, 2023

    @hugovk
    hugovk
    on Apr 27, 2023
    Member
    More actions

    Also not needed for 3.12, setuptools was removed in #101039.

  11. ned-deily commented on Dec 7, 2023

    @ned-deily
    ned-deily
    on Dec 7, 2023
    Member
    More actions

    To follow up on this, the current status is that we are still shipping various older versions of setuptools with ensurepip in Python 3.11 and 3.10 (65.5.0), 3.9 (58.1.0), and 3.8 (56.0.0). (We no longer include setuptools with ensurepip as of 3.12.) It should be up to the affected release managers to decide what action, if any, should be taken and then update and close this issue. Are there other potentially relevant security fixes in setuptools?

    cc: @pablogsal @ambv @sethmlarson

  12. ned-deily
    changed the title [-][3.9] Any plan about fixing CVE-2022-40897 in python 3.9-alpine[/-] [+]Update bundled setuptools provided by ensurepip in current 3.8.x through 3.11.x to include fix for CVE-2022-40897?[/+] on Dec 7, 2023
  13. sethmlarson commented on Dec 7, 2023

    @sethmlarson
    sethmlarson
    on Dec 7, 2023
    Contributor
    More actions

    @ned-deily Beyond CVE-2022-40897 there aren't any additional vulnerabilities in setuptools. I don't think it's particularly bundersome to ask users to upgrade pip when using ensurepip to bootstrap, pip itself will start issuing warnings about being out of date as well.

    In fact, could we make ensurepip automatically attempt to upgrade the installed pip during bootstrapping (ie set --upgrade to True by default?)? cc @pradyunsg

  14. ned-deily commented on Dec 7, 2023

    @ned-deily
    ned-deily
    on Dec 7, 2023
    Member
    More actions

    In fact, could we make ensurepip automatically attempt to upgrade the installed pip during bootstrapping (ie set --upgrade to True by default?)? cc @pradyunsg

    We could but that approach was rejected in the original PEP proposing ensurepip. That could be revisited.

  15. 3 remaining items

  16. ned-deily
    added
    3.8 (EOL)end of lifeend of life
    on Jan 23, 2024
  17. ezio-melotti
    added this to Release and Deferred blockers 🚫on Jan 23, 2024
  18. github-project-automation
    moved this to Todo in Release and Deferred blockers 🚫on Jan 23, 2024
  19. ned-deily commented on Jan 23, 2024

    @ned-deily
    ned-deily
    on Jan 23, 2024
    Member
    More actions

    Mark as release blocker for 3.8, 3.9, and 3.10 decisions.

  20. bhupendra-vaishnav commented on Jan 24, 2024

    @bhupendra-vaishnav
    bhupendra-vaishnav
    on Jan 24, 2024
    More actions

    @ned-deily Is there any tentative release date for the vulnerability fix? This issue came to us from our customer as high-priority issue.

  21. samruddhikhandale commented on Feb 2, 2024

    @samruddhikhandale
    samruddhikhandale
    on Feb 2, 2024
    More actions

    Looking for some updates on this vulnerability patching, thanks!

  22. encukou commented on Feb 6, 2024

    @encukou
    encukou
    on Feb 6, 2024
    Member
    More actions

    So, a DoS can be caused by a package that's considered for download and installation (which can run arbitrary code), or by the site that serves such packages?
    I don't see how this can be exploited without the attacker being able to do much more damage; a fix will mainly silence automated checkers.

    @sethmlarson, you have more info; let me know (possibly privately) if we need to fix this somehow.

    Unfortunately, setuptools had breaking changes since 58.1 (and 65.5).
    Back in my old job, I'd do a surgical patch to fix the regex only. Not sure if that's appropriate for CPython, but if we're distributing a library that's no longer supported upstream, it probably should be.

  23. sethmlarson commented on Feb 6, 2024

    @sethmlarson
    sethmlarson
    on Feb 6, 2024
    Contributor
    More actions

    @encukou I agree that there isn't much benefit to patching that CVE and it's only likely to cause breakages.

    @samruddhikhandale @bhupendra-vaishnav As far as finding a solution to your issue, it seems that scanners are alerting regardless of whether that file is completely inert and useless in the image. Maybe a way forward is to ensure pip and setuptools are bootstrapped to versions that you're happy with (ie python -m pip install --disable-version-check pip==... --hash=...; python -m pip install setuptools==... --hash=...) and then the Lib/ensurepip/_bundled/... directory can be deleted entirely?

  24. samruddhikhandale commented on Feb 6, 2024

    @samruddhikhandale
    samruddhikhandale
    on Feb 6, 2024
    More actions

    Lib/ensurepip/_bundled/... directory can be deleted entirely?

    We tried deleting the directory, but then pip fails to work 😓 Hence, we are not able to patch it on our end.

    Maybe a way forward is to ensure pip and setuptools are bootstrapped to versions that you're happy with

    Yep, we already have that logic added, thanks!

  25. pradyunsg commented on Feb 6, 2024

    @pradyunsg
    pradyunsg
    on Feb 6, 2024
    Member
    More actions

    the Lib/ensurepip/_bundled/... directory can be deleted entirely?

    IIUC, this will break ensurepip, which breaks venv since venv relies on ensurepip to install a copy of pip (and setuptools) in the environment.

    Reacted by Samruddhi Khandale
  26. encukou commented on Feb 9, 2024

    @encukou
    encukou
    on Feb 9, 2024
    Member
    More actions

    Note that you can run venv with --no-pip, and then install pip separately.
    If you redistribute Python, you could try to replace the wheels and adjust the version numbers in Lib/ensurepip/__init__.py. (And test that the incompatibilities in the new versions don't affect you, of course.)

    I agree that there isn't much benefit to patching that CVE and it's only likely to cause breakages.

    With that, let's close. It's not a notable security vulnerability in Python. Telling that to your security scanner is, in this case, up to you.

    @ambv @pablogsal, please tell me if I'm out of line and I should have left this decision to you.

    Reacted by Pradyun Gedam and Łukasz Langa
  27. encukou
    closed this as not plannedon Feb 9, 2024
  28. github-project-automation
    moved this from Todo to Done in Release and Deferred blockers 🚫on Feb 9, 2024
  29. zware
    marked Update bundled setuptools to address CVE-2024-6345, CVE-2022-40897 in cpython 3.9, 3.10 & 3.11 #131864 as a duplicate of this issue on Apr 1, 2025
  30. laptchik commented on Apr 8, 2025

    @laptchik
    laptchik
    on Apr 8, 2025
    More actions

    @encukou @ambv @pablogsal what about vulnerability https://nvd.nist.gov/vuln/detail/CVE-2024-6345 which was mentioned #131864 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of liferelease-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-ensurepiptype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-securityA security issueA security issue

    Projects

    • Release and Deferred blockers 🚫
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.