A hash function is defined as an algorithm that maps arbitrarily sized data into a fixed-sized digest (output) such that the following properties hold:
Building on this definition, a cryptographic hash function must also ensure that a malicious actor cannot leverage the hash function to have a reasonable chance of success at determining any of the following:
What is regarded as "reasonable" varies by context and threat model, but in general, "reasonable" could cover any attack that is more efficient than brute force (i.e., on average, attempting half of all possible combinations). Note that some attacks might be more efficient than brute force but are still not regarded as achievable in the real world.
Any algorithm that does not meet the above conditions will generally be considered weak for general use in hashing.
In addition to algorithmic weaknesses, a hash function can be made weak by using the hash in a security context that breaks its security guarantees. For example, using a hash function without a salt for storing passwords (that are sufficiently short) could enable an adversary to create a "rainbow table" [REF-637] to recover the password under certain conditions; this attack works against such hash functions as MD5, SHA-1, and SHA-2.
Scope | Impact | Likelihood |
---|---|---|
Access Control | Bypass Protection Mechanism |
References | Description |
---|---|
CVE-2022-30320 | Programmable Logic Controller (PLC) uses a protocol with a cryptographically insecure hashing algorithm for passwords. |
CVE-2005-4900 | SHA-1 algorithm is not collision-resistant. |
CVE-2020-25685 | DNS product uses a weak hash (CRC32 or SHA-1) of the query name, allowing attacker to forge responses by computing domain names with the same hash. |
CVE-2012-6707 | blogging product uses MD5-based algorithm for passwords. |
CVE-2019-14855 | forging of certificate signatures using SHA-1 collisions. |
CVE-2017-15999 | mobile app for backup sends SHA-1 hash of password in cleartext. |
CVE-2006-4068 | Hard-coded hashed values for username and password contained in client-side script, allowing brute-force offline attacks. |
Use an adaptive hash function that can be configured to change the amount of computational effort needed to compute the hash, such as the number of iterations ("stretching") or the amount of memory required. Some hash functions perform salting automatically. These functions can significantly increase the overhead for a brute force attack compared to intentionally-fast functions such as MD5. For example, rainbow table attacks can become infeasible due to the high computing overhead. Finally, since computing power gets faster and cheaper over time, the technique can be reconfigured to increase the workload without forcing an entire replacement of the algorithm in use.
Some hash functions that have one or more of these desired properties include bcrypt [REF-291], scrypt [REF-292], and PBKDF2 [REF-293]. While there is active debate about which of these is the most effective, they are all stronger than using salts with hash functions with very little computing overhead.
Note that using these functions can have an impact on performance, so they require special consideration to avoid denial-of-service attacks. However, their configurability provides finer control over how much CPU and memory is used, so it could be adjusted to suit the environment's needs.
CAPEC-ID | Attack Pattern Name |
---|---|
CAPEC-461 | Web Services API Signature Forgery Leveraging Hash Function Extension Weakness An adversary utilizes a hash function extension/padding weakness, to modify the parameters passed to the web service requesting authentication by generating their own call in order to generate a legitimate signature hash (as described in the notes), without knowledge of the secret token sometimes provided by the web service. |
CAPEC-68 | Subvert Code-signing Facilities Many languages use code signing facilities to vouch for code's identity and to thus tie code to its assigned privileges within an environment. Subverting this mechanism can be instrumental in an attacker escalating privilege. Any means of subverting the way that a virtual machine enforces code signing classifies for this style of attack. |
Name | Organization | Date | Date release | Version |
---|---|---|---|---|
PLOVER | Draft 3 |
Name | Organization | Date | Comment |
---|---|---|---|
CWE Content Team | MITRE | updated Relationships, Observed_Example, Taxonomy_Mappings | |
CWE Content Team | MITRE | updated Description | |
CWE Content Team | MITRE | updated Description, References | |
CWE Content Team | MITRE | updated Relationships | |
CWE Content Team | MITRE | updated Common_Consequences | |
CWE Content Team | MITRE | updated References, Related_Attack_Patterns, Relationships | |
CWE Content Team | MITRE | updated Demonstrative_Examples, Potential_Mitigations, References | |
CWE Content Team | MITRE | updated Potential_Mitigations, References | |
CWE Content Team | MITRE | updated Relationships | |
CWE Content Team | MITRE | updated Relationships | |
CWE Content Team | MITRE | updated Applicable_Platforms, Modes_of_Introduction, References, Relationships | |
CWE Content Team | MITRE | updated Relationships | |
CWE Content Team | MITRE | updated Demonstrative_Examples | |
CWE Content Team | MITRE | updated Description, Maintenance_Notes, Name, Observed_Examples, References, Relationships | |
CWE Content Team | MITRE | updated Demonstrative_Examples, Observed_Examples, References | |
CWE Content Team | MITRE | updated Applicable_Platforms | |
CWE Content Team | MITRE | updated Detection_Factors, References, Relationships | |
CWE Content Team | MITRE | updated Mapping_Notes, Relationships | |
CWE Content Team | MITRE | updated Demonstrative_Examples, Description, References |