v0.14 is out: a mobile auth pack for Swift/iOS and Android, catching insecure token storage, cleartext traffic, and OAuth in embedded WebViews. Read more →
HIGH AI PREVALENCE: HIGH auth.csharp.crypto.weak-password-hash

A password is hashed with a fast general-purpose digest (MD5, SHA1, SHA256, SHA512) from System.Security.Cryptography.

Why AI tools produce this: AI coding tools generate this anti-pattern by default, it appears in a large share of AI-written auth code.

Why this matters

These are designed to be fast, which makes offline brute-force and rainbow-table attacks cheap; they are NOT suitable for storing passwords (CWE-916).

Use ASP.NET Core Identity's PasswordHasher<TUser>, or a slow, salted password KDF: PBKDF2 (Rfc2898DeriveBytes with a high iteration count), bcrypt, or Argon2.

VULNERABLE
vulnerable.cs
using System.Security.Cryptography;
using System.Text;

public class Accounts
{
    public byte[] HashPassword(string password)
    {
        // ruleid: auth.csharp.crypto.weak-password-hash
        return SHA256.HashData(Encoding.UTF8.GetBytes(password));
    }

    public byte[] LegacyHash(string password)
    {
        // ruleid: auth.csharp.crypto.weak-password-hash
        return MD5.HashData(Encoding.UTF8.GetBytes(password));
    }
}
SAFE
safe.cs
using Microsoft.AspNetCore.Identity;
using System.Security.Cryptography;
using System.Text;

public class Accounts
{
    private readonly PasswordHasher<object> _hasher = new();

    public string HashPassword(object user, string password)
    {
        // ok: dedicated slow, salted password hasher
        return _hasher.HashPassword(user, password);
    }

    // ok: SHA256 over a file, not a password
    public byte[] Checksum(byte[] fileBytes)
    {
        return SHA256.HashData(fileBytes);
    }
}

Suppressing this rule

If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.

// oauthlint-disable-next-line auth.csharp.crypto.weak-password-hash -- <reason>

References

https://learn.microsoft.com/aspnet/core/security/data-protection/consumer-apis/password-hashing ↗https://cwe.mitre.org/data/definitions/916.html ↗