Why it matters
They must not protect integrity, sign data or store passwords.
How to fix it
Use SHA256.Create() or SHA256.HashData for integrity, and a password hasher (ASP.NET Core Identity's PasswordHasher, or PBKDF2 with a high iteration count) for passwords.
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 Checksums
{
public static byte[] Of(byte[] data)
{
using var md5 = MD5.Create();
return md5.ComputeHash(data);
}
}using System.Security.Cryptography;
public static class Checksums
{
public static byte[] Of(byte[] data)
{
return SHA256.HashData(data);
}
}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
- XXE DTD processing (C#)
C#Severity: High
trustivan-csharp-xxe-dtd-processing - Weak cipher (C#)
C#Severity: High
trustivan-csharp-weak-cipher - XXE XML resolver (C#)
C#Severity: High
trustivan-csharp-xxe-xml-resolver - ECB mode (C#)
C#Severity: High
trustivan-csharp-ecb-mode - Json type name handling (C#)
C#Severity: High
trustivan-csharp-json-type-name-handling - Static IV (C#)
C#Severity: High
trustivan-csharp-static-iv
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