An RSA key is generated with fewer than 2048 bits
What it finds
rsa.GenerateKey(rand.Reader, 1024): RSA keys below 2048 bits are within reach of factoring with enough resources, and NIST no longer allows them. 2048 bits is the minimum, 3072 or more for keys that must stay safe for long.
The size must be an integer literal below 2048 passed to GenerateKey or GenerateMultiPrimeKey of crypto/rsa, resolved through the imports. Tests often use small keys for speed; findings there are as expected.
From the rule's source, small_rsa_key.rs.
package p import ( "crypto/rand" "crypto/rsa") func keys() { weak, _ := rsa.GenerateKey(rand.Reader, 1024)tx0 reports: an RSA key of 1024 bits is too small strong, _ := rsa.GenerateKey(rand.Reader, 4096) _, _ = weak, strong} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/go:small-rsa-key" = "off"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/go:small-rsa-key] reason="..."tx0 explain tx0/go:small-rsa-key shows the same in the terminal. Found a false positive? Report it.