Data is encrypted with DES, RC4, Blowfish or in ECB mode

tx0/ts:broken-cipherrecommendedwarningsecurity, cwe-327

What it finds

DES and triple DES have blocks small enough to collide in practice, RC4 and RC2 leak their key stream, Blowfish has 64-bit blocks too, and ECB mode encrypts equal blocks to equal output so that patterns in the data stay visible. Data encrypted this way is not confidential.

Reported are createCipheriv and createDecipheriv from Node's crypto module with such an algorithm name as a literal: names starting with des, rc2, rc4, bf or blowfish, cast and idea, and any name ending in -ecb.

From the rule's source, broken_cipher.rs.

Example from the rule's tests
import { createCipheriv, createDecipheriv } from "crypto";export function ciphers(key: Buffer, iv: Buffer) {  const a = createCipheriv("des-ede3-cbc", key, iv);tx0 reports: des-ede3-cbc does not keep data confidential  const b = createDecipheriv("aes-128-ecb", key, null);tx0 reports: aes-128-ecb does not keep data confidential  const c = createCipheriv("rc4", key, "");tx0 reports: rc4 does not keep data confidential  const d = createCipheriv("aes-256-gcm", key, iv);  const e = createCipheriv("bf-cbc", key, iv);tx0 reports: bf-cbc does not keep data confidential  return [a, b, c, d, e];}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:broken-cipher" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:broken-cipher] reason="..."

tx0 explain tx0/ts:broken-cipher shows the same in the terminal. Found a false positive? Report it.