Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix Use of Weak Algorithm ntls.js #620

Open
RashidKhanPathan opened this issue Jan 4, 2025 · 0 comments
Open

fix Use of Weak Algorithm ntls.js #620

RashidKhanPathan opened this issue Jan 4, 2025 · 0 comments

Comments

@RashidKhanPathan
Copy link


please fix, use of weak algorithm in ntls.js which using DES-ECB

Description

The code at

var des = crypto.createCipheriv('DES-ECB', key, '');
uses the DES-ECB algorithm for encryption which is considered weak and insecure due to the below following reasons:

  1. DES is an outdated encryption standard with a key length of 56 bits, making it susceptible to brute-force attacks.
  2. The use of ECB mode reveals patterns in the plaintext, as identical plaintext blocks result in identical ciphertext blocks. This can leak sensitive information about the structure of the plaintext.

Code With Issue

function encrypt(buf) {
    var key = insertZerosEvery7Bits(buf);
    var des = crypto.createCipheriv('DES-ECB', key, '');
    return des.update("KGS!@#$%"); // page 57 in [MS-NLMP]
}

Impact

  • could be: The static string "KGS!@#$%" makes the encryption output predictable.
  • why its weak: Many security standards (e.g., PCI-DSS, NIST) prohibit the use of DES due to its known vulnerabilities.

Recommendation

To resolve this issue, I recommend switching to a modern encryption algorithm like AES (Advanced Encryption Standard) in GCM (Galois/Counter Mode) or CBC (Cipher Block Chaining) mode. For example:

// sample fix code
const crypto = require('crypto');

function encrypt(buf) {
    ...
    const cipher = crypto.createCipheriv('aes-256-gcm', key, iv); // fixed code
    return { encrypted, iv, tag };
    ...
}

to fix the issue

  • Replace DES-ECB with AES-GCM or AES-CBC.

References


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant