Blog | G5 Cyber Security

RSA Attacks: Common Weaknesses

TL;DR

RSA is generally secure, but attacks are possible if certain conditions aren’t met. This guide covers common weaknesses like small exponents, predictable moduli, and related-message attacks. We’ll show you how these work and what to do to prevent them.

1. Small Exponent Attacks (e = 3)

If the public exponent ‘e’ is too small (like e=3), RSA becomes vulnerable. This is because calculating the cube root of a ciphertext can be easier than factoring the modulus, especially if the message ‘m’ is also small.

# Example of calculating the cube root in Python (for demonstration only - not secure)
m = round(c**(1/3))

2. Common Modulus Attacks

If multiple parties use the same modulus ‘n’ but different exponents, an attacker can potentially recover messages.

3. Wiener’s Attack

Wiener’s attack exploits RSA when the private exponent ‘d’ is too small relative to the modulus ‘n’.

# This attack requires specialized libraries and is complex.
# It's not easily demonstrated with a simple code snippet.

4. Related-Message Attacks

If an attacker can get RSA to encrypt related messages (e.g., m and m+1), they can sometimes recover the message.

# Example of a simple related message attack (for demonstration only - not secure)
# Assuming e=3 and small m values.
c1 = pow(m, 3, n)
c2 = pow(m+1, 3, n)
# From these you can potentially solve for m

5. Low Encryption Exponent Attacks (e < 4)

Using a very small encryption exponent ‘e’ (less than 4) is highly insecure.

# Example of calculating the square root in Python (for demonstration only - not secure)
m = round(c**(1/2))

6. Hastad’s Broadcast Attack

If RSA is used to encrypt the same message ‘m’ with multiple different moduli ‘ni‘, an attacker can recover ‘m’.

Exit mobile version