CVE-2023-46133 (JSON, published 2023-10-25T21:15Z)
Description: value: CryptoES is a cryptography algorithms library compatible with ES6 and TypeScript. Prior to version 2.1.0, CryptoES PBKDF2 is 1,000 times weaker than originally specified in 1993, and at least 1,300,000 times weaker than current industry standard. This is because it both defaults to SHA1, a cryptographic hash algorithm considered insecure since at least 2005, and defaults to one single iteration, a 'strength' or 'difficulty' value specified at 1,000 when specified in 1993. PBKDF2 relies on iteration count as a countermeasure to preimage and collision attacks. If used to protect passwords, the impact is high. If used to generate signatures, the impact is high. Version 2.1.0 contains a patch for this issue. As a workaround, configure CryptoES to use SHA256 with at least 250,000 iterations.
Severity: nan (CVSS v3 base score: 9.1)
Weakness: CWE-327 \u2014 Use of a Broken or Risky Cryptographic Algorithm
The product uses a broken or risky cryptographic algorithm or protocol.
Repository: https://github.com/entronad/crypto-es
Files changed:
CHANGELOG.md
__tests__/debug.js
__tests__/pbkdf2.test.ts
lib/pbkdf2.js
package-lock.json
package.json
Commit message: v2.1.0


Vulnerable code:
const data = {};
data.saltA = C.enc.Hex.parse('AA00000000000000');
const encryptedA = C.Blowfish.encrypt('Test', 'pass', { salt: data.saltA, hasher: C.algo.SHA256 }).toString();
console.log(encryptedA);
      .toBe('cdedb5281bb2f801565a1122b2563515');
      .toBe('cdedb5281bb2f801565a1122b25635150ad1f7a04bb9f3a333ecc0e2e1f70837');
      .toBe('01dbee7f4a9e243e988b62c73cda935d');
      .toBe('01dbee7f4a9e243e988b62c73cda935da05378b93244ec8f48a99e61ad799d86');
      .toBe('5c08eb61fdf71e4e4ec3cf6ba1f5512b');
      .toBe('5c08eb61fdf71e4e4ec3cf6ba1f5512ba7e52ddbc5e5142f708a31e2e62b1e13');
      .toBe('d1daa78615f287e6a1c8b120d7062a49');
      .toBe('d1daa78615f287e6a1c8b120d7062a493f98d203e6be49a6adf4fa574b6e64ee');
      .toBe('139c30c0966bc32ba55fdbf212530ac9');
      .toBe('139c30c0966bc32ba55fdbf212530ac9c5ec59f1a452f5cc9ad940fea0598ed1');
      .toBe('9ccad6d468770cd51b10e6a68721be61');
      .toBe('9ccad6d468770cd51b10e6a68721be611a8b4d282601db3b36be9246915ec82a');
      .toBe('6b9cf26d45455a43a5b8bb276a403b39');
      .toBe('6b9cf26d45455a43a5b8bb276a403b39e7fe37a0c41e02c281ff3069e1e94f52');
import { SHA1Algo } from './sha1.js';
     * @property {Hasher} hasher The hasher to use. Default: SHA1
     * @property {number} iterations The number of iterations to perform. Default: 1
        hasher: SHA1Algo,
        iterations: 1,
      "name": "crypto-es",
  "version": "2.0.4",

Fixed code:
## 2.1.0

**2023-10-24**

- Change pbkdf2 default params to enhance security: https://github.com/entronad/crypto-es/security/advisories/GHSA-mpj8-q39x-wq5h

// const data = {};
// data.saltA = C.enc.Hex.parse('AA00000000000000');
// const encryptedA = C.Blowfish.encrypt('Test', 'pass', { salt: data.saltA, hasher: C.algo.SHA256 }).toString();
// console.log(encryptedA);

const start = (new Date()).getTime();
console.log(C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128 / 32}).toString());
const end = (new Date()).getTime();
console.log(end - start);
      .toBe('62929ab995a1111c75c37bc562261ea3');
      .toBe('62929ab995a1111c75c37bc562261ea3fb3cdc7e725c4ca87c03cec5bb7663e1');
      .toBe('262fb72ea65b44ab5ceba7f8c8bfa781');
      .toBe('262fb72ea65b44ab5ceba7f8c8bfa7815ff9939204eb7357a59a75877d745777');
      .toBe('c76a982415f1acc71dc197273c5b6ada');
      .toBe('c76a982415f1acc71dc197273c5b6ada32f62915ed461718aad32843762433fa');
      .toBe('74e98b2e9eeddaab3113c1efc6d82b07');
      .toBe('74e98b2e9eeddaab3113c1efc6d82b073c4860195b3e0737fa21a4778f376321');
      .toBe('c1dfb29a4d2f2fb67c6f78d074d66367');
      .toBe('c1dfb29a4d2f2fb67c6f78d074d663671e6fd4da1e598572b1fecf256cb7cf61');
      .toBe('22344bc4b6e32675a8090f3ea80be01d');
      .toBe('22344bc4b6e32675a8090f3ea80be01d5f95126a2cddc3facc4a5e6dca04ec58');
      .toBe('44b0781253db3141ac4174af29325818');
      .toBe('44b0781253db3141ac4174af29325818584698d507a79f9879033dec308a2b77');
import { SHA256Algo } from './sha256.js';
     * 
     * The default `hasher` and `interations` is different from CryptoJs to enhance security:
     * https://github.com/entronad/crypto-es/security/advisories/GHSA-mpj8-q39x-wq5h
     * @property {Hasher} hasher The hasher to use. Default: SHA256
     * @property {number} iterations The number of iterations to perform. Default: 250000
        hasher: SHA256Algo,
        iterations: 250000,
        "fsevents": "^2.3.2",
  "version": "2.1.0",