Jump to solution
Verify

The Fix

pip install urllib3==1.26.20

Based on closed urllib3/urllib3 issue #3432 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -0,0 +1 @@ @@ -0,0 +1 @@ +Fixed a crash where certain standard library hash functions were absent in restricted environments. diff --git a/src/urllib3/util/ssl_.py b/src/urllib3/util/ssl_.py index c46dd83e53..b16779f153 100644
repro.py
$ python3 -m ensurepip --upgrade --default-pip ... File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/requests/__init__.py", line 43, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/__init__.py", line 13, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/connectionpool.py", line 12, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/connection.py", line 15, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/util/__init__.py", line 8, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/util/ssl_.py", line 8, in <module> ImportError: cannot import name 'md5' from 'hashlib' (/opt/python-fips/lib/python3.12/hashlib.py) Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/opt/python-fips/lib/python3.12/ensurepip/__main__.py", line 5, in <module> sys.exit(ensurepip._main()) ^^^^^^^^^^^^^^^^^ File "/opt/python-fips/lib/python3.12/ensurepip/__init__.py", line 284, in _main return _bootstrap( ^^^^^^^^^^^ File "/opt/python-fips/lib/python3.12/ensurepip/__init__.py", line 200, in _bootstrap return _run_pip([*args, *_PACKAGE_NAMES], additional_paths) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/python-fips/lib/python3.12/ensurepip/__init__.py", line 101, in _run_pip return subprocess.run(cmd, check=True).returncode ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/python-fips/lib/python3.12/subprocess.py", line 571, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['/usr/local/bin/python3', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmp052h8i17\', \'--upgrade\', \'pip\']\n
verify
Re-run: python3 -m ensurepip --upgrade --default-pip
fix.md
Option A — Upgrade to fixed release\npip install urllib3==1.26.20\nWhen NOT to use: This fix should not be used in environments where md5 is required for functionality.\n\n

Why This Fix Works in Production

  • Trigger: $ python3 -m ensurepip --upgrade --default-pip
  • Mechanism: The usage of md5 in urllib3 causes ImportError in FIPS mode due to its unavailability
  • Why the fix works: Makes the code resilient to missing hash functions in FIPS mode by deferring their usage until required, preventing crashes in such environments. (first fixed release: 1.26.20).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.12 in real deployments (not just unit tests).
  • The usage of md5 in urllib3 causes ImportError in FIPS mode due to its unavailability
  • Surfaces as: $ python3 -m ensurepip --upgrade --default-pip

Proof / Evidence

  • GitHub issue: #3432
  • Fix PR: https://github.com/urllib3/urllib3/pull/3434
  • First fixed release: 1.26.20
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.85
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.31

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“A fix will need to end up in 1.26.x to be available for pip”
@illia-v · 2024-07-29 · source
“Thanks for reporting this! We should make our usage of hashes lazy so that removed hashes don't block urllib3's usage in FIPS mode (or other…”
@sethmlarson · 2024-07-29 · source
“Agreed @illia-v, since this is a non-trivial amount of work I've attached a bounty. Fix must go into both 2.x and 1.26.x”
@sethmlarson · 2024-07-29 · source
“Besides the changes noted in https://github.com/urllib3/urllib3/issues/3432#issuecomment-2256669232, is there additional work involved?”
@shashankram · 2024-07-30 · source

Failure Signature (Search String)

  • $ python3 -m ensurepip --upgrade --default-pip

Error Message

Stack trace
error.txt
Error Message ------------- $ python3 -m ensurepip --upgrade --default-pip ... File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/requests/__init__.py", line 43, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/__init__.py", line 13, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/connectionpool.py", line 12, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/connection.py", line 15, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/util/__init__.py", line 8, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/util/ssl_.py", line 8, in <module> ImportError: cannot import name 'md5' from 'hashlib' (/opt/python-fips/lib/python3.12/hashlib.py) Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/opt/python-fips/lib/python3.12/ensurepip/__main__.py", line 5, in <module> sys.exit(ensurepip._main()) ^^^^^^^^^^^^^^^^^ File "/opt/python-fips/lib/python3.12/ensurepip/__init__.py", line 284, in _main return _bootstrap( ^^^^^^^^^^^ File "/opt/python-fips/lib/python3.12/ensurepip/__init__.py", line 200, in _bootstrap return _run_pip([*args, *_PACKAGE_NAMES], additional_paths) ^^^^^^^^^^^^^^^^^^^^^^^ ... (truncated) ...

Minimal Reproduction

repro.py
$ python3 -m ensurepip --upgrade --default-pip ... File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/requests/__init__.py", line 43, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/__init__.py", line 13, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/connectionpool.py", line 12, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/connection.py", line 15, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/util/__init__.py", line 8, in <module> File "/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl/pip/_vendor/urllib3/util/ssl_.py", line 8, in <module> ImportError: cannot import name 'md5' from 'hashlib' (/opt/python-fips/lib/python3.12/hashlib.py) Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/opt/python-fips/lib/python3.12/ensurepip/__main__.py", line 5, in <module> sys.exit(ensurepip._main()) ^^^^^^^^^^^^^^^^^ File "/opt/python-fips/lib/python3.12/ensurepip/__init__.py", line 284, in _main return _bootstrap( ^^^^^^^^^^^ File "/opt/python-fips/lib/python3.12/ensurepip/__init__.py", line 200, in _bootstrap return _run_pip([*args, *_PACKAGE_NAMES], additional_paths) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/python-fips/lib/python3.12/ensurepip/__init__.py", line 101, in _run_pip return subprocess.run(cmd, check=True).returncode ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/python-fips/lib/python3.12/subprocess.py", line 571, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['/usr/local/bin/python3', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmp052h8i17/pip-24.0-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmp052h8i17\', \'--upgrade\', \'pip\']\n

Environment

  • Python: 3.12

What Broke

Users experience crashes when using urllib3 in FIPS mode while installing pip.

Why It Broke

The usage of md5 in urllib3 causes ImportError in FIPS mode due to its unavailability

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install urllib3==1.26.20

When NOT to use: This fix should not be used in environments where md5 is required for functionality.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/urllib3/urllib3/pull/3434

First fixed release: 1.26.20

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be used in environments where md5 is required for functionality.

Verify Fix

verify
Re-run: python3 -m ensurepip --upgrade --default-pip

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
  • Upgrade behind a canary and run integration tests against the canary before 100% rollout.
  • Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
  • Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.

Version Compatibility Table

VersionStatus
1.26.20 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.