An RSA or DSA key pair is generated with fewer than 2048 bits
What it finds
RSA and DSA keys shorter than 2048 bits can be factored or broken with resources that are within reach today, so signatures made with them can be forged and data encrypted with them read.
Reported are calls of Node's generateKeyPair and generateKeyPairSync for "rsa", "rsa-pss" or "dsa" whose modulusLength is a literal below 2048.
From the rule's source, weak_key_size.rs.
import { generateKeyPairSync } from "crypto";export const weak = generateKeyPairSync("rsa", { modulusLength: 1024 });tx0 reports: a key of 1024 bits is too shortexport const strong = generateKeyPairSync("rsa", { modulusLength: 4096 });export const curve = generateKeyPairSync("ec", { namedCurve: "P-256" }); 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:
[rules]
"tx0/ts:weak-key-size" = "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:weak-key-size] reason="..."tx0 explain tx0/ts:weak-key-size shows the same in the terminal. Found a false positive? Report it.