Weak Cryptography

Weak cryptography in C#

Description

MD5 and SHA-1 are unsuitable for integrity checks that need collision resistance. DES has a short key, and ECB mode reveals repeated plaintext blocks.

Potential impact

Altered data may pass verification, or ciphertext may reveal patterns or sensitive data.

Remediation

Use a collision-resistant hash such as SHA-256 for integrity checks and authenticated encryption such as AES-GCM for data. Use a dedicated password hash for password storage.

Examples

Before

csharp
using var md5 = MD5.Create();

After

csharp
using var sha256 = SHA256.Create();

SHA256.Create() creates the SHA-256 object used to compute a digest.

References