ESLint InterlaceESLint Interlace
Plugin: node-securityRules

no-weak-cipher-algorithm

ESLint rule documentation for no-weak-cipher-algorithm

📡 Live from GitHub — This documentation is fetched directly from no-weak-cipher-algorithm.md and cached for 6 hours.

Keywords: DES, 3DES, RC4, Blowfish, weak cipher, encryption, CWE-327, security, ESLint rule, LLM-optimized CWE: CWE-327
OWASP: A02:2021-Cryptographic Failures

Disallow weak cipher algorithms (DES, 3DES, RC4, Blowfish, RC2, IDEA)

Detects usage of weak cipher algorithms (DES, 3DES, RC4, Blowfish, RC2, IDEA) in Node.js crypto operations. This rule is part of eslint-plugin-node-security and provides LLM-optimized error messages with fix suggestions.

🚨 Security rule | 💡 Provides suggestions | ⚠️ Set to error in recommended

Quick Summary

AspectDetails
CWE ReferenceCWE-327 (Broken Crypto)
SeverityCritical (security vulnerability)
Auto-Fix💡 Suggests fixes (AES-256-GCM, ChaCha20-Poly1305)
CategorySecurity
ESLint MCP✅ Optimized for ESLint MCP integration
Best ForNode.js applications using crypto.createCipheriv()

Vulnerability and Risk

Vulnerability: DES, 3DES, RC4, Blowfish, RC2, and IDEA are obsolete cipher algorithms with known vulnerabilities. DES has a 56-bit key (brute-forceable), RC4 has statistical biases, and 3DES is deprecated by NIST since 2023.

Risk: Using weak ciphers allows attackers to decrypt sensitive data through brute force attacks, statistical analysis, or known cryptographic attacks like BEAST and POODLE.

Rule Details

This rule detects weak cipher algorithms passed to crypto.createCipheriv(), crypto.createDecipheriv(), and deprecated crypto.createCipher/createDecipher methods.

Why This Matters

RiskImpactSolution
🔓 Brute ForceDES can be cracked in hoursUse AES-256-GCM
📊 Statistical AttacksRC4 leaks data through biasesUse ChaCha20-Poly1305
🔒 ComplianceFails PCI-DSS, HIPAA, NIST requirementsReplace all weak cipher usage

Configuration

OptionTypeDefaultDescription
additionalWeakCiphersstring[][]Additional weak ciphers to flag
allowInTestsbooleanfalseAllow weak ciphers in test files
{
  rules: {
    'node-security/no-weak-cipher-algorithm': ['error', {
      additionalWeakCiphers: ['cast5'],
      allowInTests: false
    }]
  }
}

Examples

❌ Incorrect

import crypto from 'crypto';

// DES - 56-bit key, brute-forceable
const cipher = crypto.createCipheriv('des', key, iv);

// 3DES - deprecated by NIST since 2023
const tripleDesCipher = crypto.createCipheriv('des-ede3', key, iv);

// RC4 - statistical biases, completely broken
const rc4Cipher = crypto.createCipheriv('rc4', key, iv);

// Blowfish - weak 64-bit block size
const bfCipher = crypto.createCipheriv('bf', key, iv);

✅ Correct

import crypto from 'crypto';

// AES-256-GCM - authenticated encryption (recommended)
const iv = crypto.randomBytes(16);
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);

// ChaCha20-Poly1305 - fast, secure, constant-time
const chachaCipher = crypto.createCipheriv('chacha20-poly1305', key, iv);

// AES-256-CBC with HMAC - if GCM not available
const cbcCipher = crypto.createCipheriv('aes-256-cbc', key, iv);

Security Impact

VulnerabilityCWEOWASPCVSSImpact
Broken Crypto327A02:20219.1 CriticalData decryption
Weak Encryption326A02:20217.5 HighBrute force attacks

Migration Guide

Phase 1: Discovery

{
  rules: {
    'node-security/no-weak-cipher-algorithm': 'warn'
  }
}

Phase 2: Replacement

// Replace weak ciphers with AES-256-GCM
crypto.createCipheriv('des', key, iv); // ❌ Before
crypto.createCipheriv('aes-256-gcm', key, iv); // ✅ After

crypto.createCipheriv('rc4', key, iv); // ❌ Before
crypto.createCipheriv('chacha20-poly1305', key, iv); // ✅ After

Phase 3: Enforcement

{
  rules: {
    'node-security/no-weak-cipher-algorithm': 'error'
  }
}

Known False Negatives

Dynamic Algorithm Names

Why: Dynamic strings cannot be analyzed statically.

// ❌ NOT DETECTED
const algo = getConfig().cipher;
crypto.createCipheriv(algo, key, iv);

Mitigation: Use constants for algorithm names.

Further Reading

On this page

No Headings