Skip to content
Crypto Write-up Advanced

Factoring "short-sleeve" RSA keys with polynomials

A bug in CompleteFTP's random number generation for big integers caused RSA and DSA keys to have large blocks of zero bits, making them factorable. Attackers could recover private keys from public keys, and the researchers found hundreds of such keys in the wild.

blog.trailofbits.com

Published on blog.trailofbits.com

What happens when the bits of an RSA private key are heavily biased toward 0 instead of being randomly generated? The public key’s bits could be biased enough for us to detect these incorrectly generated keys in the wild.

The author, on blog.trailofbits.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a type mismatch in the big-integer random generation function, where 8-bit random bytes were copied into 32-bit limbs without proper scaling, leaving most bits of each limb as zero.

Impact

The vulnerability allowed recovery of private keys for 603 RSA and 74 DSA keys generated by vulnerable CompleteFTP versions; the impact is limited because only a small minority of hosts are affected and newer versions use standard crypto APIs.

What the attacker needed

CompleteFTP versions 10.0.0–12.0.0 (RSA); CompleteFTP versions 10.0.0–23.0.4 (DSA); keys generated with vulnerable versions

The fix

CompleteFTP was fixed by refactoring key generation to use standard .NET cryptographic APIs, and later versions include a check that alerts users to regenerate vulnerable keys.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

RSA keys rely on two large secret prime numbers. If the random number generator used to create these primes is flawed, the resulting public key may have a predictable pattern. Here, a coding mistake left long runs of zeros in the key, which made it possible to work out the secret primes and break the key.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.