Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util/ssl: make code resilient to missing hash functions #3434

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

shashankram
Copy link
Contributor

In certain environments such as in a FIPS enabled system, certain algorithms such as md5 may be unavailable. Due to the importing of such a module on a system where it is unavailable, urllib will crash and is unusable.

This change makes the code more resilient by deferring the usage of the hash function module unless they are required. If the hash function is unavailable but required, an SSLError is raised indicating the same. If the hash function is unavailable but not required, urllib functions instead of crashing.

Part of #3432

Copy link
Member

@illia-v illia-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @shashankram!

Please format the code with nox -rs format and add a changelog entry

test/with_dummyserver/test_https.py Outdated Show resolved Hide resolved
In certain environments such as in a FIPS enabled system,
certain algorithms such as md5 may be unavailable. Due
to the importing of such a module on a system where it
is unavailable, urllib will crash and is unusable.

This change makes the code more resilient by deferring the
usage of the hash function module unless they are required.
If the hash function is unavailable but required, an SSLError
is raised indicating the same. If the hash function is unavailable
but not required, urllib functions instead of crashing.

Part of urllib3#3432
@shashankram
Copy link
Contributor Author

@illia-v let me know if this looks good. I'll open a PR for 1.26.x next.

changelog/3432.bugfix.rst Outdated Show resolved Hide resolved
Copy link
Member

@illia-v illia-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! @shashankram feel free to claim the $100 bounty from our OpenCollective

@illia-v illia-v linked an issue Aug 2, 2024 that may be closed by this pull request
@illia-v illia-v merged commit b7b8115 into urllib3:main Aug 2, 2024
36 checks passed
@shashankram shashankram deleted the handle-disabled-hashes branch August 2, 2024 14:34
Ousret added a commit to jawah/urllib3.future that referenced this pull request Aug 4, 2024
- Fixed wrong upgrade attempt to QUIC when using a SOCKS proxy. Any usage of a proxy disable HTTP/3 over QUIC as per documented.
  until proper support is implemented in a next minor version.
- Backported upstream urllib3 urllib3#3434: util/ssl: make code resilient to missing hash functions.
  In certain environments such as in a FIPS enabled system, certain algorithms such as md5 may be unavailable. Due
  to the importing of such a module on a system where it is unavailable, urllib3(-future) will crash and is unusable.
  urllib3#3434
- Backported upstream urllib3 GHSA-34jh-p97f-mpxf: Strip Proxy-Authorization header on redirects.
  Added the ``Proxy-Authorization`` header to the list of headers to strip from requests when redirecting to a different host.
  As before, different headers can be set via ``Retry.remove_headers_on_redirect``.
- Fixed state-machine desync on a rare scenario when uploading a body using HTTP/3 over QUIC.
Ousret added a commit to jawah/urllib3.future that referenced this pull request Aug 4, 2024
- Fixed wrong upgrade attempt to QUIC when using a SOCKS proxy. Any
usage of a proxy disable HTTP/3 over QUIC as per documented. until
proper support is implemented in a next minor version.
- Backported upstream urllib3 urllib3#3434: util/ssl: make code resilient to
missing hash functions. In certain environments such as in a FIPS
enabled system, certain algorithms such as md5 may be unavailable. Due
to the importing of such a module on a system where it is unavailable,
urllib3(-future) will crash and is unusable.
urllib3#3434
- Backported upstream urllib3 GHSA-34jh-p97f-mpxf: Strip
Proxy-Authorization header on redirects. Added the
``Proxy-Authorization`` header to the list of headers to strip from
requests when redirecting to a different host. As before, different
headers can be set via ``Retry.remove_headers_on_redirect``.
- Fixed state-machine desync on a rare scenario when uploading a body
using HTTP/3 over QUIC.
@Ousret Ousret mentioned this pull request Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Usage of md5 in util/ssl_.py breaks in FIPS mode
2 participants