Solution usage of a random salt :
this.encrypt = function(message, password) {
var salt = forge.random.getBytesSync(128);
var key = forge.pkcs5.pbkdf2(password, salt, 4, 16);
var iv = forge.random.getBytesSync(16);
var cipher = forge.cipher.createCipher('AES-CBC', key);
cipher.start({iv: iv});
cipher.update(forge.util.createBuffer(message));
cipher.finish();
var cipherText = forge.util.encode64(cipher.output.getBytes());
return {cipher_text: cipherText, salt: forge.util.encode64(salt), iv: forge.util.encode64(iv)};
}
Application uses static key when performing encryption which makes it easier for an attacker to conduct brute force password guessing.
Source https://auth0.com/blog/adding-salt-to-hashing-a-better-way-to-store-passwords/ https://www.thepolyglotdeveloper.com/2014/10/implement-aes-strength-encryption-javascript/ https://cwe.mitre.org/data/definitions/329.html