Skip to content

Insecure Cryptography #1

@paragonie-scott

Description

@paragonie-scott

hardbin/js/hardbin.js

Lines 5 to 11 in c77c2d7

function encrypt(data, key) {
return CryptoJS.AES.encrypt(data, key).toString();
}
function decrypt(data, key) {
return CryptoJS.AES.decrypt(data, key).toString(CryptoJS.enc.Utf8);
}
-> http://cryptojs.altervista.org/secretkey/doc/doc_aes_cryptojs-v3.html

You're using unauthenticated AES-CBC. https://paragonie.com/blog/2015/05/using-encryption-and-authentication-correctly

Your About section says:

Since nobody can modify the code, and nobody can view the key unless you show it to them, nobody without the key can either read the plaintext or ship a malicious viewer which would exfiltrate the plaintext (or key).

...but this is strictly not true with unauthenticated encryption. In fact, you can recover the plaintext with a padding oracle attack.

Also, your RNG is biased.

hardbin/js/hardbin.js

Lines 13 to 25 in c77c2d7

function generate_key() {
var alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var randombytes = new Uint8Array(32);
crypto.getRandomValues(randombytes);
var k = '';
for (var i = 0; i < 32; i++) {
var idx = Math.floor(randombytes[i] * alphabet.length / 256);
k += alphabet.charAt(idx);
}
return k;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions