Skip to content

Use of weak hash

Description

The MD5 hashing algorithm is considered cryptographically weak and vulnerable to collision attacks, where two different inputs generate the same output hash. When used for hashing sensitive data, attackers can exploit this weakness to generate collisions, allowing them to bypass security checks or masquerade malicious data as legitimate.

Examples

Insecure Code

ruby
Digest::MD5.hexdigest "sensitive information"

Secure Code

ruby
OpenSSL::Digest::SHA256.new.hexdigest "sensitive information"

Remediation

Replace the MD5 hashing algorithm with stronger cryptographic hash functions, such as SHA-256 or SHA-3.

Rule Details

FieldValue
IDCODE-0521
CategoryCrypto
SeverityMEDIUM
CWECWE-328
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagshashing, cryptographic weakness
OWASPA3:2017-Sensitive Data Exposure, A02:2021-Cryptographic Failures

References