Missing salt for hashing operation
Hashed data is vulnerable to rainbow table attack
Description
This defect occurs when you use a digest context in these functions, but you hash data into the context only once or you use a null salt in all subsequent hashing operations. A salt is random data that you use to improve the security of a hashing operation. The hashing operation takes the salt as an input to produce a more secure hashed value.
EVP_DigestFinal
EVP_DigestSignUpdate
EVP_DigestVerifyUpdate
SHA*_Final
family of functions
Missing salt for hashing operation raises no defect if no information is available about the context. For instance, if the context is passed as an argument to the function that calls the hashing operation or if the context is declared outside the scope of the function. For example, no defect is raised in this code snippet.
EVP_MD_CTX ctx_global; void foo(EVP_MD_CTX* ctx) { //ctx passed as argument of func() EVP_DigestFinal(ctx, out_buf, &out_len); //no defect } void bar() { // ctx_global declared outside of bar() EVP_DigestFinal(&ctx_glob, out_buf, &out_len); //no defect }
Risk
Hashing the same data without a salt results in the same hashed value. For instance, if you hash user passwords and two users have the same passwords, the hashed passwords are identical. The hashing is then vulnerable to precomputed rainbow attacks.
Fix
Provide a salt when you hash data.
Examples
Result Information
Group: Cryptography |
Language: C | C++ |
Default: Off |
Command-Line Syntax:
CRYPTO_MD_NO_SALT |
Impact: Medium |
Version History
Introduced in R2019b
See Also
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)