Eliminate MD5 usage by adopting Project wide SHA-256 checksums#951
Eliminate MD5 usage by adopting Project wide SHA-256 checksums#951in-manishkr wants to merge 1 commit into
Conversation
c029d90 to
1d116be
Compare
There was a problem hiding this comment.
Excellent, thanks. I did not see problems with the code and I am approving it.
WARNING I am afraid that other products depending on Feilong will need to be updated due to the API change. I am thinking in particular at the Go Connector for Feilong and the Terraform provider for Feilong that I am maintaining, but the ICIC guys are probably hit too for the openstack code that uses Feilong.
PLEASE When this is merged, close issue #888
I agree with you, due to which I have included a python script database_migration_md5_to_sha256.py which can be used to re-evaluate the checksums for all existing images and updates the checksum column with newly calculated values. |
Thank you for that database upgrade script, Manish. But this is not only about database contents. Your PR is also a breaking change for the API, which means that every program that uses the Feilong API will have to be rewritten. This could be mitigated though by accepting both the old parameter name ( |
Yes, thats a good suggestion, i will incorporate these changes asap for backward compatibility. |
Replace MD5-based checksum generation with SHA-256 to address known MD5 collision vulnerabilities and improve security. Also update MD5-specific references to generic checksum naming where applicable. Signed-off-by: Manish Kumar <Manish.Kumar176@ibm.com>
1d116be to
f99b689
Compare
|
I have incorporated the requested changes as a fallback mechanism:
please re-review |
Thanks. It might be you also need to accept both values in the validation code (on top of my head: |
Summary
Replace MD5-based checksum generation with SHA-256 and standardize MD5-specific naming to generic checksum terminology throughout the codebase.
MD5 is no longer considered secure due to known collision vulnerabilities. This change improves file integrity verification by adopting SHA-256 and aligns the codebase with modern security practices.
In addition, a database migration script has been added to migrate existing image metadata and recalculate checksums for restored databases.
Changes
Core implementation
hashlib.md5()withhashlib.sha256()_get_md5sum()to_get_checksum()Database
md5sumtochecksumAPI and validation
md5sumtochecksumTests
Documentation
Migration tooling
feilong/database_migration_md5_to_sha256.pySecurity Impact
This change eliminates the use of MD5 for checksum generation and verification. SHA-256 provides significantly stronger collision resistance and better aligns with current security recommendations and compliance requirements.
Benefits include:
Compatibility Notes
Breaking Change
md5sumhas been renamed tochecksummd5sumhas been renamed tochecksumDatabase Migration Requirement
For deployments restoring or upgrading an existing
sdk_image.sqlitedatabase, the following migration script must be executed after the database is restored:The migration script:
md5sumtochecksumFailure to run the migration script after database restoration may result in schema mismatches or invalid checksum data.
Upgrade Considerations
Operators upgrading existing environments should:
sdk_image.sqlitedatabase if required.feilong/database_migration_md5_to_sha256.py.checksumfield and SHA-256 values.Testing