Skip to main content
HighCodeOWASP A02:2021CWE-327

How to fix: Weak cryptography protecting secrets and tokens

The code uses deprecated or broken cryptographic algorithms (MD5, SHA1, DES, RC4) that are no longer considered secure.

Why it matters

MD5 and SHA1 are broken for security purposes. Attackers can forge hashes via collision attacks. DES/RC4 ciphers have been cryptanalyzed and can be brute-forced. Using them for passwords, signatures, or encryption provides false security and actual exposure.

Deprecated algorithms like MD5 and SHA1 are vulnerable to collision attacks. Use SHA-256 or higher for hashing, AES-256-GCM for encryption, and bcrypt/argon2 for password hashing.

How to fix it

  1. 1Replace MD5/SHA1 with SHA-256 or SHA-3 for integrity checks
  2. 2Replace DES/3DES with AES-256-GCM
  3. 3Replace RC4 with AES-GCM for stream encryption
  4. 4Use bcrypt, argon2, or scrypt for password hashing

Code examples

Use modern algorithms instead of MD5/SHA1/DES

TypeScript
import { createHash, randomBytes, createHmac } from "crypto";

// BAD: MD5 / SHA1 are broken for security use
// createHash("md5").update(data).digest("hex");

// GOOD: SHA-256 for hashing
const hash = createHash("sha256").update(data).digest("hex");

// For passwords: use bcrypt / argon2
import bcrypt from "bcryptjs";
const hash2 = await bcrypt.hash(password, 12);

// For symmetric encryption: AES-256-GCM
import { createCipheriv } from "crypto";
const key = randomBytes(32);
const iv  = randomBytes(12);
const cipher = createCipheriv("aes-256-gcm", key, iv);

References

Detected automatically by VulnRadar. The check id is insecure-crypto, stable across every scan so you can filter or diff on it.

See every code check

Questions

How severe is Weak cryptography protecting secrets and tokens?
VulnRadar rates this high severity in the code category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id insecure-crypto, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Weak cryptography protecting secrets and tokens map to?
It maps to CWE-327. In the OWASP Top 10 it falls under A02:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for weak cryptography protecting secrets and tokens

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

Weak cryptography protecting secrets and tokens | VulnRadar