codeforgood-official / chaabi

Simplest and trustworthy way to encrypt anything. All locally.
6 stars 0 forks source link

Missing key derivation #1

Open akx opened 7 years ago

akx commented 7 years ago

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 use createCipher with CTR mode, either:

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().

ps. Found the project via https://dev.to/ben/what-are-some-useful-npm-packages-i-might-not-know-about-55i

makeitcount commented 7 years ago

Thanks @akx for pointing this out. Added to ToDo list.