The implementation of crypto.createCipher() derives keys using the OpenSSL function EVP_BytesToKey with the digest algorithm set to MD5, one iteration, and no salt. The lack of salt allows dictionary attacks as the same password always creates the same key. The low iteration count and non-cryptographically secure hash algorithm allow passwords to be tested very rapidly.
In line with OpenSSL's recommendation to use pbkdf2 instead of EVP_BytesToKey it is recommended that developers derive a key and IV on their own using crypto.pbkdf2() and to use crypto.createCipheriv() to create the Cipher object. Users should not use ciphers with counter mode (e.g. CTR, GCM or CCM) in crypto.createCipher().
Hi,
It looks like you're not using any sort of key derivation algorithm, so it's very easy/fast to brute-force keys to try and decrypt the chaabi file.
The
crypto.createCipher
documentation touches upon this, and notes that it's not safe to usecreateCipher
with CTR mode, either:ps. Found the project via https://dev.to/ben/what-are-some-useful-npm-packages-i-might-not-know-about-55i