-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
hashlib.new() allows MD5 in FIPS mode #116800
Comments
This seems expected as hashlib.new falls back in this case to python's internal md5 implementation and not the openssl one. If you compile with --without-builtin-hashlib-hashes (or --with-builtin-hashlib-hashes=) this should be fixed. However I guess it can be improved to not even allow the fallback in case fips mode is enabled but then Python would have to start tracking the FIPS related restrictions and their updates and apply those to the hashlib module. |
Thanks for replying! After reading the docs I was under impression that the fallback should happen when The way it is done now confused me with some XPASS tests ("Hey... Why do they pass if we use MD5 here?"). I'll try to compile Python without built-in hashes and see what fails then. |
The |
That's what I expected. The default value is I tried compiling Python with I'll leave this issue open for the contributors to decide if it's worth any action on Python's side. Thank you for help! |
cc'ing @tiran |
CPython doesn't support FIPS mode. Supporting it would be a new feature. (Or some might call it a mis-feature, since all it does is limit what you can do.) You can query OpenSSL's Similarly, AFAIK the |
Feel free to join the broader discussion to the recently started https://discuss.python.org/t/python-and-openssl-fips-mode/51389 thread. If you don't want non-OpenSSL hash implementations to be present so no fallbacks exist, I suggest building with |
see also #118224. |
When configuring python in that way, lots of tracebacks are shown upon I don't think it's ok, to close this issue (and also dissmiss my PR) when proposed "solutions" in python build configuration yield runtime tracebacks for users. Also majority of users do not have access to an alternative build of python matching the openssl runtime configuration. Most of the time openssl-fips is not a separate openssl build, but a runtime configuration & plugin only. Thus existing python is expected to work correctly with it. |
There's a disconnect in expectations here. CPython doesn't claim to work with OpenSSL FIPS mode itself. This is something some that re-packagers and distributors (like RedHat) have tried to make work themselves, for their own packages. The important gist of the discuss thread is that this configuration isn't supportable by CPython OSS contributors as is because there has been little interest in maintaining support for yet another unusual configuration, no CI or regression testing for it, and the specific goals are are not well defined. I recommend using that discuss thread for further conversation. |
Bug report
Bug description:
On a system with FIPS mode enabled,
hashlib.new()
allows MD5 hash to be created even without usingusedforsecurity
flag.hashlib.md5()
call fails, as expected.CPython versions tested on:
3.12
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: