-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add dependency version pinning and hash verification #10
Conversation
This is a very important point indeed! Will look into it in the next few days. |
Hey @VEDRAN6, we are looking for a method to enforce this behavior also for who installs this library directly from pip, but this would require adding the hashes to setup.py. Otherwise this only works by manually cloning the lib from github and doing We could not find a way to add the hashes to setup.py, we would appreciate any help about that. |
To my knowledge, this may be hard to do. Besides, if a user is simply installing from pypi without knowing which version of btcpy they're downloading and what its hash should be, they are still trusting that pypi hasn't been compromised and serving them a bad copy of btcpy. One way to deal with this issue is to specify a list of btcpy versions and their corresponding hashes in a visible place independent from pypi.org (e.g. in the README file here). We should also make it known to users to only use the following installation idiom:
Using this, pip will print out the remote hash, and the user will have an opportunity to verify that the remote hash matches the one in the README file, and will then have to specify it manually in order to proceed. This is a trust issue that manifests quite often with pgp keys, where people choose to trust key directories without verifying key identities independently and through a secondary channel. Ultimately this type of security is hard to outsource and make "transparent" for end users, and eventually education is the only way to make sure that good security practices are enforced. |
This is an important point, but I think the question meant something else. At the moment, we pinned dependency versions in |
Understood. It doesn't seem to be possible at the moment: pypa/pip#3137 One workaround might be removing remote dependencies and implementing ecdsa and base58 locally. Neither is too hard to implement. |
Another possible solution, a bit hacky albeit:
|
That might be a good solution. Unfortunately I have never played with setup.py and I do not have much time in my hands but I'd be glad to merge a PR about that. |
From https://pip.pypa.io/en/stable/reference/pip_install/#hash-checking-mode:
Since btcpy is likely to be used in wallets and handle real money, it is imperative that it use dependency version pinning and hash verification to protect against the possibility of the pypi repository (or package maintainers) being compromised.
Hashes can be determined manually by downloading their respective wheel packages from pypi and running them through
sha256sum
, or using the procedure described here.Once hashes are specified, pip will refuse to install any dependency whose sha256 hash doesn't match the one specified in the requirements file.