Weak Key Size
Using cryptographic keys shorter than recommended minimums (RSA less than 2048 bits, AES less than 128 bits) makes encryption vulnerable to brute-force attacks with modern hardware.
How It Works
Cryptographic key size directly determines how resistant encryption is to brute-force attacks. RSA keys under 2048 bits can be factored with modern computing clusters — a 1024-bit RSA key was factored in 2010 and 768-bit keys are trivially breakable. For symmetric encryption, DES (56-bit keys) and 3DES (effective 112-bit) are deprecated. AES-128 is the minimum acceptable symmetric key size, with AES-256 recommended for long-term protection. As computing power increases and quantum computing advances, weak key sizes become exponentially more vulnerable. Keys that are secure today may be breakable tomorrow if undersized.
const crypto = require('crypto');
// RSA key too small
const { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', {
modulusLength: 1024
});
// AES key too small
const key = crypto.randomBytes(8); // 64-bit key
const cipher = crypto.createCipheriv('aes-128-gcm', key, iv);const crypto = require('crypto');
// RSA with adequate key size
const { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', {
modulusLength: 4096
});
// AES-256 with proper key size
const key = crypto.randomBytes(32); // 256-bit key
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);Real-World Example
In 2017, the ROCA vulnerability (CVE-2017-15361) affected RSA key generation in Infineon TPM chips used in government IDs and security tokens. Keys of 1024 and 2048 bits generated by these chips could be factored, compromising Estonian national ID cards and numerous corporate security tokens. The attack cost around $20,000 in cloud computing for 2048-bit keys.
How to Prevent It
- Use RSA key sizes of at least 2048 bits, preferably 4096 bits
- Use AES-256 (32-byte key) for symmetric encryption
- Consider switching to elliptic curve cryptography (Ed25519) for better security with smaller keys
- Audit existing key sizes and rotate any keys below recommended minimums
Affected Technologies
Data Hogo detects this vulnerability automatically.
Scan Your Repo FreeRelated Vulnerabilities
ECB Mode
mediumUsing ECB (Electronic Codebook) mode for encryption produces identical ciphertext blocks for identical plaintext blocks, revealing patterns in the encrypted data.
Static IV/Nonce
highUsing a hardcoded or constant Initialization Vector (IV) or nonce for encryption defeats the purpose of the IV and allows attackers to detect patterns and decrypt data.
Certificate Validation Disabled
criticalDisabling TLS certificate validation with NODE_TLS_REJECT_UNAUTHORIZED=0 or rejectUnauthorized: false allows man-in-the-middle attacks on all HTTPS connections.
Weak PRNG for Security
highUsing Math.random() or Date.now() to generate tokens, session IDs, or reset codes produces predictable values that attackers can guess or reproduce.