Skip to content

[SECURITY] User passwords hashed with MD5 or without proper salting - vulnerable to rainbow table attacks #473

Description

@anshul23102

Description

The user model or authentication service hashes passwords using md5(password) or a similarly weak function without a unique per-user salt. MD5 is a fast hashing algorithm designed for data integrity, not password storage. Pre-computed rainbow tables can reverse most common passwords in seconds.

Steps to Reproduce

  1. Register a user with password Password123.
  2. Access the database directly and read the stored hash.
  3. Paste the hash into any online MD5 reverse lookup tool.
  4. Observe Password123 is recovered instantly.

Root Cause

A cryptographically weak function is used for password hashing instead of a slow, salted algorithm like bcrypt, scrypt, or Argon2.

Impact

A database breach exposes all user passwords. Even "strong" passwords are at risk because MD5 can be computed at billions of hashes per second on commodity hardware.

Proposed Fix

const bcrypt = require("bcrypt");
const SALT_ROUNDS = 12;

// On registration:
const hash = await bcrypt.hash(plainPassword, SALT_ROUNDS);

// On login:
const match = await bcrypt.compare(plainPassword, storedHash);

Migrate existing hashes by prompting users to reset their passwords.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions