Javascript Cryptojs Passphrase Mode
Description
Detects usage of CryptoJS encryption functions that rely on passphrase-based key derivation instead of proper cryptographic keys. This creates weak encryption since passphrases typically have low entropy and are vulnerable to brute force attacks, making the encrypted data easier to compromise.
Detection Strategy
• Scans JavaScript code for CryptoJS encryption method calls (such as AES.encrypt, DES.encrypt, etc.)
• Identifies when these encryption methods are called with string passphrases instead of proper cryptographic key objects
• Reports vulnerabilities when CryptoJS encryption functions use passphrase-based encryption mode, which provides weaker security than key-based encryption
Vulnerable code example
import CryptoJS from "crypto-js";
function encryptUserData(userData) {
const encrypted = CryptoJS.AES.encrypt(userData, "myPassword123"); // Weak: uses MD5-based key derivation
return encrypted.toString();
}
function decryptUserData(encryptedData) {...✅ Secure code example
import CryptoJS from "crypto-js";
function encryptUserData(userData, password) {
const salt = CryptoJS.lib.WordArray.random(128 / 8);
const key = CryptoJS.PBKDF2(password, salt, {
keySize: 512 / 32,
iterations: 150000
});...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.