Usage of weak hashing library (CRC32)
- Rule ID: python_lang_weak_hash_crc32
- Languages: python
- Source: weak_hash_crc32.yml
Description
The use of CRC32 for hashing is insecure. CRC32 is designed for error-checking and not for security purposes, making it vulnerable to intentional data tampering.
Remediations
- Do not use CRC32 for hashing when security is a concern. It is not secure against intentional data modifications.
myhash = zlib.crc32(data) # unsafe
- Do opt for stronger hashing algorithms like SHA-256 to ensure data integrity and security.
myhash = hashlib.sha256(data).digest()
Associated CWE
OWASP Top 10
Configuration
To skip this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --skip-rule=python_lang_weak_hash_crc32
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=python_lang_weak_hash_crc32