Skip to content

Use of a broken or risky cryptographic algorithm

Description

The application was found using an insecure or risky digest or signature algorithm. MD2, MD4, MD5, and SHA1 hash algorithms have been found to be vulnerable to producing collisions. This means that two different values, when hashed, can lead to the same hash value. If the application is trying to use these hash methods for storing passwords, then it is recommended to switch to a password hashing algorithm such as Argon2id or PBKDF2.

Examples

Insecure Code

python
import hashlib; hashlib.sha1(b"data")

Secure Code

python
from cryptography.hazmat.primitives import hashes; digest = hashes.Hash(hashes.SHA384()); digest.update(b"some data to hash"); result = digest.finalize()

Remediation

Use a secure hash algorithm like SHA384 from the cryptography package. Example: from cryptography.hazmat.primitives import hashes; digest = hashes.Hash(hashes.SHA384()); digest.update(b"some data to hash"); result = digest.finalize()

Rule Details

FieldValue
IDCODE-0132
CategoryCrypto
SeverityMEDIUM
CWECWE-327
ConfidenceHIGH
ImpactMEDIUM
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagsinsecure algorithm, hash collision
OWASPA3:2017-Sensitive Data Exposure, A02:2021-Cryptographic Failures