Why it matters
A stolen password hash can then be brute-forced quickly on commodity hardware.
How to fix it
Use at least 600,000 iterations with SHA-256 (OWASP's 2023 guidance), or ASP.NET Core Identity's PasswordHasher.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
using System.Security.Cryptography;
public static class Passwords
{
public static byte[] Hash(string password, byte[] salt)
{
return Rfc2898DeriveBytes.Pbkdf2(password, salt, 1000, HashAlgorithmName.SHA256, 32);
}
}using System.Security.Cryptography;
public static class Passwords
{
public static byte[] Hash(string password, byte[] salt)
{
return Rfc2898DeriveBytes.Pbkdf2(password, salt, 600000, HashAlgorithmName.SHA256, 32);
}
}What TrustIvan reads
Runs on repository scans of C# source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- Weak RSA key (C#)
C#Severity: Medium
trustivan-csharp-weak-rsa-key - TLS validation disabled (C#)
C#Severity: High
trustivan-csharp-tls-validation-disabled - Insecure random secret (C#)
C#Severity: Medium
trustivan-csharp-insecure-random-secret - Insecure TLS protocol (C#)
C#Severity: Medium
trustivan-csharp-insecure-tls-protocol - Static IV (C#)
C#Severity: High
trustivan-csharp-static-iv - Hardcoded password connection string (C#)
C#Severity: High
trustivan-csharp-hardcoded-password-connection-string
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation