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 — Meta-issue for bugs in cryptographic extension modules · Issue #155438 · python/cpython

Meta-issue for bugs in cryptographic extension modules #155438

New issue
Copy link
New issue
Copy link
Open
6 / 76 of 7 issues completed
Open
Meta-issue for bugs in cryptographic extension modules#155438
6 / 76 of 7 issues completed
Copy link
Assignees
picnixz
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@picnixz
picnixz
opened on Aug 9, 2026
Issue body actions

Bug report

Bug description:

Bug report

Bug description:

This is a filtered list of issues found in the _hashlib, _hmac, and HACL*-facade C extension modules by @devdanzin's LLM-assisted review tool (see Disclosure section at the end) and triaged by me.

Important

All issues will be addressed by @picnixz. Please do NOT work on them, whether you are an agent or a human. Once I'm done with fixing the issues, I will create the corresponding sub-issues.

_hashopenssl.c

  • 32: bug (GIL issue) [33,45]: _hashlib: GIL may be released while attempting to set an exception #159811
  • 34: bug (OpenSSL misuse): Do not leave stale OpenSSL errors in _hashlib #159815
  • 🔴 38: _hashlib_HASH_dealloc uses PyObject_Free instead of tp->tp_free but it's deliberate because we use PyObject_New. This would need to be changed if we ever make that class subclassable.
  • 🔴 40: oversized MAC size from a provider, bounded only by assert: this is a non-issue because OpenSSL itself assumes EVP_MAX_MD_SIZE everywhere and malicious provides are not part of the threat model.
  • 🔴 43: not an issue: HMACobject.evp_md_nid is assigned after self->ctx in both constructors (cosmetic as it doesn't impact the code for now).
  • 47: need investigation (read out of lock) [35,36]
  • 🔴 49: _hashlib_HASH_update_impl and _hmac_HMAC_update_impl return a bare Py_None without a Py_NewRef. None is immortal and there are other places that already have this issue. I may consider a large cosmetic refactoring in the future that could fix that but it's not worth for now.
  • 🔴 52: invalid hash types previously raised SystemError, but not abort (this is deliberate, if we have invalid hash types somehow, it may be more than a reason to report the bug and get it fixed upstream rather than silently catching the exception)

_hmacmodule.c

  • 31/42: Ensure that HMAC objects are properly initialized #155843
  • 33/45: bug (GIL issue) [32]: HACL* update() errors are handled without a thread state #159786
  • 🔴 37: SIMD accelerated HMAC-BLAKE2 does not work (and will not be supported, see https://discuss.python.org/t/reduce-api-surface-for-blake2-to-match-openssl-semantics/109603/6).
  • 🔴 50: not an issue (py_hmac_hinfo was claimed to be lacking a visitor method but none of its members are containers)

MD5, SHA-*, BLAKE2-*

  • 35/36: Ensure that HACL* states are not read concurrently #155835 [47]
  • 🔴 39: shake_*.digest() and shake_*.hexdigest() discard the return value of Hacl_Hash_SHA3_squeeze() but it's not possible for that function to fail because the method table rules and the pre-checks we perform.
  • 41: bug (init) but addressed in gh-155833: GC-untrack MD5/SHA* objects before freeing the HACL* state #155834 directly (SHA3 missing initialization)
  • 44: Ensure that cryptographic objects are GC-untracked first #155833
  • 🔴 46: not planned (same rationale as 52, but for BLAKE-2 update())
  • 48: Ensure that BLAKE-2 objects are fully initialized before being GC-tracked #155830
  • 🔴 51: Fallible PyType_GetModuleState usage. More generally, getting the state of a module is inconsistently achieved in extension modules and we should decide whether (1) to consistently abort on DEBUG builds (2) abort on non-DEBUG builds via a fatal error (to prevent possibly expensive checks). Currently, code works because we assume non-subclassability in general, but we may consider a more defensive approach.

Disclosure

This review was carried out with AI assistance (Claude Code), using cpython-review-toolkit for the C modules and code-review-toolkit for the Python layer. Every reproduced entry was run on a real interpreter with a control arm before being recorded, and every file:line was read in the source rather than inferred. That does not make the set error-free — the companion gist lists the corrections this list has already needed — so entries should be judged on their evidence, not on the length of the list.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Reacted by An Long

Activity

  1. picnixz
    self-assigned this
    on Aug 9, 2026
  2. picnixz
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    3.16new features, bugs and security fixesnew features, bugs and security fixes
    on Aug 9, 2026
  3. picnixz
    changed the title [-]Meta-issue for bugs in `Modules/hmacmodule.c`[/-] [+]Meta-issue for bugs in `Modules/{hmacmodule,_hashopenssl}.c` and dedicated hash functions[/+] on Aug 9, 2026
  4. picnixz
    changed the title [-]Meta-issue for bugs in `Modules/{hmacmodule,_hashopenssl}.c` and dedicated hash functions[/-] [+]Meta-issue for bugs in cryptographic extension modules[/+] on Aug 9, 2026
  5. picnixz
    removed
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    3.16new features, bugs and security fixesnew features, bugs and security fixes
    on Aug 9, 2026
  6. picnixz commented on Aug 9, 2026

    @picnixz
    picnixz
    on Aug 9, 2026
    MemberAuthor
    More actions

    I don't have time for that today but I'll try to file the bugs by the end of next week.

  7. picnixz
    added sub-issues on Aug 15, 2026
    • Ensure that BLAKE-2 objects are fully initialized before being GC-tracked #155830
    • Ensure that cryptographic objects are GC-untracked first #155833
    • Ensure that HACL* states are not read concurrently #155835
    • Ensure that HMAC objects are properly initialized #155843
  8. picnixz
    added sub-issues on Oct 19, 2026
    • HACL* update() errors are handled without a thread state #159786
    • _hashlib: GIL may be released while attempting to set an exception #159811
    • Do not leave stale OpenSSL errors in _hashlib #159815
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @picnixz
    picnixz

Labels

extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

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.