Skip to main content

Insecure service configuration - Salt

Description

Salt is generated in an insecure way, which makes the password easier to guess.

Impact

Obtain valid credentials through dictionary attacks.

Recommendation

Generate the Salt with a secure hashing function.

Threat

Anonymous attacker from the Internet.

Expected Remediation Time

⌚ 30 minutes.

Score

Default score using CVSS 3.1. It may change depending on the context of the vulnerability.

Base

  • Attack vector: N
  • Attack complexity: H
  • Privileges required: N
  • User interaction: N
  • Scope: U
  • Confidentiality: L
  • Integrity: N
  • Availability: N

Temporal

  • Exploit code madurity: P
  • Remediation level: O
  • Report confidence: X

Result

  • Vector string: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N/E:P/RL:O/RC:X
  • Score:
    • Base: 3.7
    • Temporal: 3.4
  • Severity:
    • Base: Low
    • Temporal: Low

Code Examples

Compliant code

The hashing configuration is set up with a secure hashing function

namespace Controllers {
public class Encrypt {
public static void Process(string password) {
var salt = RNGCryptoServiceProvider().GetBytes(salt=new byte[16]);
var fromHardcoded = new Rfc2898DeriveBytes(password, salt);
var fromPassword = new Rfc2898DeriveBytes(password, Encoding.UTF8.GetBytes("test"));
var fromUnicode = new Rfc2898DeriveBytes(password, Encoding.Unicode.GetBytes("test"));
}
}
}

Non compliant code

The service configuration uses an insecure hashing function

namespace Controllers {
public class Encrypt {
public static void Process(string password) {
var salt = Encoding.UTF8.GetBytes("salt");
var fromHardcoded = new Rfc2898DeriveBytes(password, salt);
var fromPassword = new Rfc2898DeriveBytes(password, Encoding.UTF8.GetBytes("test"));
var fromUnicode = new Rfc2898DeriveBytes(password, Encoding.Unicode.GetBytes("test"));
}
}
}

Requirements