Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Hardcoded-key vulnerability usage of static salt #190

Open
LennonCMJ opened this issue Feb 19, 2019 · 1 comment
Open

Hardcoded-key vulnerability usage of static salt #190

LennonCMJ opened this issue Feb 19, 2019 · 1 comment

Comments

@LennonCMJ
Copy link

LennonCMJ commented Feb 19, 2019

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
Copy link
Owner

Thank you, I will confirm that

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants