doramart / DoraCMS

DoraCMS是基于Nodejs+eggjs+mongodb编写的一套内容管理系统,结构简单,较目前一些开源的cms,doracms易于拓展,特别适合前端开发工程师做二次开发。
https://www.html-js.cn
MIT License
3.47k stars 1.02k forks source link

Hardcoded-key vulnerability usage of static salt #190

Open LennonCMJ opened 5 years ago

LennonCMJ commented 5 years ago

Application uses static key when performing encryption which makes it easier for an attacker to conduct brute force password guessing.

Affected URL: https://github.com/doramart/DoraCMS/blob/9fee40914eccfd06dc225ebdd3e7c4bff0be799f/server/lib/utils/crypto.js

const AESkey = "doracms_";
const MD5key = "dora";
export default {
    AES: {
        encrypt: (message) => {//加密
            return CryptoJS.AES.encrypt(message, AESkey, {
                mode: CryptoJS.mode.CBC,
                padding: CryptoJS.pad.Pkcs7
            }).toString();
        },
Affected URL:
https://github.com/doramart/DoraCMS/blob/9fee40914eccfd06dc225ebdd3e7c4bff0be799f/server/lib/controller/user.js

  if (fields.password) {
                userObj.password = service.encrypt(fields.password, settings.encrypt_key);
            }
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)};
    }

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

doramart commented 5 years ago

Thank you, I will confirm that