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

[TECH DEBT] Migrating away from M2Crypto #66149

Open
1 of 6 tasks
facutuesca opened this issue Feb 27, 2024 · 7 comments
Open
1 of 6 tasks

[TECH DEBT] Migrating away from M2Crypto #66149

facutuesca opened this issue Feb 27, 2024 · 7 comments

Comments

@facutuesca
Copy link

facutuesca commented Feb 27, 2024

Description of the tech debt to be addressed, include links and screenshots

Following up on #63066: Salt currently uses M2Crypto for some of its cryptographic operations. M2Crypto is a wrapper around OpenSSL's APIs that has some drawbacks:

I'm opening this issue to list the places where M2Crypto is still being used inside Salt, and to assess the interest in migrating away from it towards more well-maintained alternatives, such as pyca/cryptography. To note: Salt already depends on pyca/cryptography, so this migration would not add new dependencies.

Going through the codebase, these are the usages that I could find, along with the feasibility of migrating to alternatives:

I'm opening the discussion to see if there is interest in migrating away from M2Crypto, and to discuss related issues such as blockers, deprecation paths, fallback alternatives, etc.

Copy link

welcome bot commented Feb 27, 2024

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@dwoz
Copy link
Contributor

dwoz commented Feb 27, 2024

@facutuesca The intent is to migrate everything to cryptography. We just have not had a chance to prioritize it. Any contributions moving things in that direction are welcome.

@dwoz dwoz added this to the Argon v3008.0 milestone Feb 27, 2024
@mcepl
Copy link

mcepl commented Feb 28, 2024

A couple more comments from tired maintainer of M2Crypto, who doesn’t wish anything more than to let M2Crypto leave its duties for peace of retirement.

Following up on #63066: Salt currently uses M2Crypto for some of its cryptographic operations. M2Crypto is a wrapper around OpenSSL's APIs that has some drawbacks:

Besides, M2Crypto follows OpenSSL API very closely, so it is very easy to create insecure application with it, no, sometimes it is actually quite difficult to call OpenSSL APIs in secure manner. If cryptography is doing more in preventing its users to shoot into their feet, it is great advantage of it.

* The build/installation process requires [installing `swig`](https://gitlab.com/m2crypto/m2crypto/-/blob/0.41.0/INSTALL.rst?ref_type=tags&plain=1#L21-22), something that adds complexity and results in [user installation issues](https://github.com/saltstack/salt/issues?q=is%3Aissue+swig+is%3Aclosed).

And the header files for OpenSSL (which might be cryptography problem as well).

  * Fallbacks to using `PyCryptodome` or else `PyCrypto` if `M2Crypto` is not found

Whatever I said about M2Crypto however pale in comparison with PyCrypto* with its home-brew cryptographic algorithms and much lesser level of audit than what OpenSSL gets. I would strongly encourage getting rid of any traces of relation to it.

@facutuesca
Copy link
Author

@facutuesca The intent is to migrate everything to cryptography. We just have not had a chance to prioritize it. Any contributions moving things in that direction are welcome.

First PR for the migration is up here: #66166

@dwoz
Copy link
Contributor

dwoz commented Mar 1, 2024

@facutuesca I will take care of salt/crypt.py and salt/channel/*

@dwoz
Copy link
Contributor

dwoz commented Mar 2, 2024

Most uses can be migrated to pyca/cryptography. An exception is encryption/decryption with X931 padding, but Salt already has its own fallback

This module should also be migrated to use cryptography's openssl backend instead of ctypes.

@dwoz
Copy link
Contributor

dwoz commented Mar 2, 2024

Most uses can be migrated to pyca/cryptography. An exception is encryption/decryption with X931 padding, but Salt already has its own fallback

This module should also be migrated to use cryptography's openssl backend instead of ctypes.

On second thought, let's get off x9.31 all together as it's likely considered to be insecure: openssl/openssl#10919 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants