python / python/cpython

hashlib.algorithms_available doesn't account for backends loaded dynamically at runtime

Open
#92,874 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-SSL type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Bug report

If additional OpenSSL backends are loaded at runtime (this happens e.g. when importing PyOpenSSL), the hashlib.algorithms_available doesn't get updated for the newly available hashes.

Trivial reproducer:

>>> import ctypes, hashlib
>>> ctypes.CDLL("libssl.so").OSSL_PROVIDER_load(None, b"legacy")
-1311283920
>>> "md4" in hashlib.algorithms_available
False
>>> hashlib.new("md4")
<md4 _hashlib.HASH object @ 0x7f404308faf0>

Your environment

  • CPython versions tested on: 3.11.0b1, 3.10.4 with 1b6acaad9a18b2498386c60f24351ab749061e3a backported, 3.9.12
  • Operating system and architecture: Gentoo Linux amd64
  • OpenSSL version: 3.0.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the hashlib.algorithms_available and hashlib.new entry points and reproduce the behavior after loading OpenSSL's legacy provider at runtime. Trace how the available-hash set is populated, then verify that hashes exposed by a newly loaded backend appear in algorithms_available while hashlib.new continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cryptography
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.