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 — [CVE-2022-37454] Buffer overflow in the _sha3 module in python versions <= 3.10 · Issue #98517 · python/cpython

[CVE-2022-37454] Buffer overflow in the _sha3 module in python versions <= 3.10 #98517

New issue
Copy link
New issue
Copy link
Closed
Closed
[CVE-2022-37454] Buffer overflow in the _sha3 module in python versions <= 3.10#98517
Copy link
Assignees
ambvned-deilypablogsal
Labels
3.10 (EOL)end of lifeend of life3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-securityA security issueA security issue

Description

@botovq
botovq
opened on Oct 21, 2022
Issue body actions

CVE-2022-37454 affects Python versions prior to 3.11. The fix discussed in XKCP's advisory can be adapted to these versions. The discoverer's writeup contains code that might be turned into regression tests.

Python 3.11 and later switched to using tiny_sha3 in GH-32060, so they should not be affected.

Linked PRs

  • [3.10] gh-98517: Fix buffer overflows in _sha3 module #98519
  • [3.9] gh-98517: Fix buffer overflows in _sha3 module (GH-98519) #98526
  • [3.8] gh-98517: Fix buffer overflows in _sha3 module (GH-98519) #98527
  • [3.7] gh-98517: Fix buffer overflows in _sha3 module (GH-98519) #98528

Activity

  1. botovq
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Oct 21, 2022
  2. gpshead commented on Oct 21, 2022

    @gpshead
    gpshead
    on Oct 21, 2022
    Member
    More actions

    Scope: When Python is linked against OpenSSL 1.1.1 or later, which is true on many modern systems, the OpenSSL provided sha3 implementation will be used instead of the vulnerable bundled _sha3 XKCP module code.

    You can tell if your Python 3.10 or earlier is vulnerable by doing the following:

    A potentially vulnerable Python if unpatched looks like this:

    >>> import hashlib
    >>> hashlib.sha3_224
    <class '_sha3.sha3_224'>

    A non-vulnerable Python looks like this:

    >>> import hashlib
    >>> hashlib.sha3_224
    <built-in function openssl_sha3_224>

    Edit update: Python 3.8 and earlier did not delegate sha3 to OpenSSL regardless of version, so those are vulnerable.

  3. gpshead
    added
    type-securityA security issueA security issue
    3.10 (EOL)end of lifeend of life
    3.9 (EOL)end of lifeend of life
    3.8 (EOL)end of lifeend of life
    3.7 (EOL)end of lifeend of life
    on Oct 21, 2022
  4. gpshead
    added a commit that references this issue on Oct 21, 2022

    [3.10] gh-98517: Fix buffer overflows in _sha3 module (#98519)

    0e4e058
  5. miss-islington
    added 2 commits that reference this issue on Oct 21, 2022

    [3.10] pythongh-98517: Fix buffer overflows in _sha3 module (pythonGH…

    915bdf4

    [3.10] pythongh-98517: Fix buffer overflows in _sha3 module (pythonGH…

    ede8c1b
  6. gpshead
    assigned
    ambv
    ,
    ned-deily
    and
    pablogsal
    on Oct 21, 2022
  7. ned-deily
    added a commit that references this issue on Oct 22, 2022

    [3.7] gh-98517: Fix buffer overflows in _sha3 module (GH-98519) (GH-9…

    8088c90
  8. hroncok commented on Oct 25, 2022

    @hroncok
    hroncok
    on Oct 25, 2022
    Contributor
    More actions

    Scope: When Python is linked against OpenSSL 1.1.1 or later, which is true on many modern systems, the OpenSSL provided sha3 implementation will be used instead of the vulnerable bundled _sha3 XKCP module code.

    As far as I can see on Fedora, only Python 3.9+ reports <built-in function openssl_sha3_224>. Older Python versions, despite being linked against OpenSSL 1.1.1 or later are still vulnerable.

  9. mcepl commented on Oct 25, 2022

    @mcepl
    mcepl
    on Oct 25, 2022
    Contributor
    More actions

    Scope: When Python is linked against OpenSSL 1.1.1 or later, which is true on many modern systems, the OpenSSL provided sha3 implementation will be used instead of the vulnerable bundled _sha3 XKCP module code.

    You can tell if your Python 3.10 or earlier is vulnerable by doing the following:

    I don’t think it is correct (at least for the enterprise maintainers dealing with archaeological excavations; however, this is openSUSE/Tumbleweed):

    stitny~$ python3.6
    Python 3.6.15 (default, Sep 15 2021, 11:41:54) [GCC] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >> import hashlib
    >>> h = hashlib.sha3_224()
    >>> hashlib.sha3_224
    <class '_sha3.sha3_224'>
    >>> h.update(b"\x00" * 1)
    >>> h.update(b"\x00" * 4294967295)
    fish: Job 1, 'python3.6' terminated by signal SIGSEGV (Address boundary error)
    stitny~$ 

    and even

    stitny~$ python3.8
    Python 3.8.15 (default, Oct 19 2022, 07:18:07) [GCC] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import hashlib
    >>> hashlib.sha3_224
    <class '_sha3.sha3_224'>
    >>> h = hashlib.sha3_224()
    >>> h.update(b"\x00" * 1)
    >>> h.update(b"\x00" * 4294967295)
    fish: Job 1, 'python3.8' terminated by signal SIGSEGV (Address boundary error)
    stitny~$ 

    So, you are right, linking against the modern OpenSSL is the key.

  10. mcepl commented on Oct 25, 2022

    @mcepl
    mcepl
    on Oct 25, 2022
    Contributor
    More actions

    Scope: When Python is linked against OpenSSL 1.1.1 or later, which is true on many modern systems, the OpenSSL provided sha3 implementation will be used instead of the vulnerable bundled _sha3 XKCP module code.

    Hmm, it is not that simple: see my example with Python 3.6 on openSUSE. See also (the same goes for our Python 3.8):

    stitny~$ python3.6
    Python 3.6.15 (default, Sep 15 2021, 11:41:54) [GCC] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ssl
    >>> ssl.OPENSSL_VERSION
    'OpenSSL 1.1.1q  5 Jul 2022'
    >>> 
  11. msmeissn commented on Oct 25, 2022

    @msmeissn
    msmeissn
    on Oct 25, 2022
    More actions

    openssl sha3 delegation was added in commit d5b3f6b, which is 3.9 and later python I think.

    Reacted by Gregory P. Smith
  12. mcepl commented on Oct 25, 2022

    @mcepl
    mcepl
    on Oct 25, 2022
    Contributor
    More actions

    openssl sha3 delegation was added in commit d5b3f6b, which is 3.9 and later python I think.

    Hmm, that makes me wonder, @tiran, how hopeless do you think it would be to port that pull request to 3.8 and 3.6? Did the underlying code completely changed between the versions or is it more or less the same? I really don’t like bundled implementations of security algorithms.

  13. gpshead commented on Oct 26, 2022

    @gpshead
    gpshead
    on Oct 26, 2022
    Member
    More actions

    Our 3.7 and 3.8 branches will get the patch merged, see the PRs above. 3.6 is EOL but it is trivial to apply the change to older _sha3 supporting releases for distributors with a need to do so on their own.

  14. ambv
    added 2 commits that reference this issue on Oct 28, 2022

    [3.8] gh-98517: Fix buffer overflows in _sha3 module (GH-98519) (#98527)

    948c679

    [3.9] gh-98517: Fix buffer overflows in _sha3 module (GH-98519) (#98526)

    857efee
  15. bmwiedemann
    added a commit that references this issue on Oct 29, 2022

    Update python38 to version 3.8.15 / rev 29 via SR 1032060

    569d100
  16. vstinner
    changed the title [-]Buffer overflow in the _sha3 module in python versions <= 3.10[/-] [+][CVE-2022-37454] Buffer overflow in the _sha3 module in python versions <= 3.10[/+] on Nov 3, 2022
  17. vstinner commented on Nov 4, 2022

    @vstinner
    vstinner
    on Nov 4, 2022
    Member
    More actions

    I created https://python-security.readthedocs.io/vuln/sha3-buffer-overflow.html to track this vulnerability.

  18. gpshead commented on Nov 7, 2022

    @gpshead
    gpshead
    on Nov 7, 2022
    Member
    More actions

    Everything was merged. Closing. If you don't see this fix backported into your favorite OS distro that ships their own Python packages, reach out to that distro's security reporting process. Otherwise these will be part of the next planned regular patch releases of all impacted Python versions. https://peps.python.org/pep-0619/ for example. (there's a similar PEP for each version)

  19. gpshead
    closed this as completedon Nov 7, 2022
  20. arnout
    added 3 commits that reference this issue on Dec 4, 2022

    package/python3: fix CVE-2022-37454

    92d96e8

    package/python3: fix CVE-2022-37454

    404d6e2

    package/python3: fix CVE-2022-37454

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

Metadata

Metadata

Assignees

  • @ambv
    ambv
  • @ned-deily
    ned-deily
  • @pablogsal
    pablogsal

Labels

3.10 (EOL)end of lifeend of life3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-securityA security issueA security issue

Projects

No projects

    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.