Skip to content

Allow md5hash to function in fips environments #1267

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

trevor-scale
Copy link

@trevor-scale trevor-scale commented Apr 15, 2025

Many secure environments disable the hashlib.md5 function because it is insecure, this causes the line below to fail making dateparser unusable in these environments:

return hashlib.md5("".join(keys).encode("utf-8")).hexdigest()

This is remedied by replacing that line with return hashlib.new("md5", "".join(keys).encode("utf-8"), usedforsecurity=False).hexdigest() which appropriately bypasses the fips security check because dateparser is not using the md5 hash for security applications.

Corresponding issue: #1258

@ghmj2417
Copy link

I posted this in #1258 as well. Change usedforsecurity=True to usedforsecurity=False. The suggestion/example provided in issue 1258 was to use hashlib.new but it also included the full command which had usedforsecurity=True to test a failure when using FIPS compliant encryptions/hashes/etc. My apologies for not being clear.

@trevor-scale
Copy link
Author

I posted this in #1258 as well. Change usedforsecurity=True to usedforsecurity=False. The suggestion/example provided in issue 1258 was to use hashlib.new but it also included the full command which had usedforsecurity=True to test a failure when using FIPS compliant encryptions/hashes/etc. My apologies for not being clear.

Thanks for catching this wasn't looking closely when I copy-pasted haha. Will update now!

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.

2 participants