0xnhl

The Riddler's Cipher Delight

/ Update
2 min read

Challenge#

Category: Cryptography
Difficulty: Easy
Given this python code:

The Vulnerability: Low Public Exponent Attack#

In this script, standard RSA encryption is used: cme(modN)c \equiv m^e \pmod N.
However, two conditions create a classic vulnerability:

  1. Small Exponent: The public exponent is very small (e=3e = 3).
  2. Small Message / No Padding: The message mm is just the byte-representation of the text in flag.txt. A typical CTF flag is around 40-50 bytes, meaning m2400m \approx 2^{400}.

When we cube mm, m3(2400)3=21200m^3 \approx (2^{400})^3 = 2^{1200}.

Because NN is generated from two 1024-bit primes, NN is a 2048-bit number (N22048N \approx 2^{2048}). Since m3<Nm^3 < N, the modulo operation m3(modN)m^3 \pmod N never actually “wraps around” or triggers.

This means that the ciphertext cc is literally just the normal integer cube of the message: c=m3c = m^3.

The Solution#

To retrieve the flag, we just need to calculate the standard integer cube root of the ciphertext cc, and then convert that integer back to bytes.

Here is a Python solver script. You don’t even need the NN value to solve it. I’ve included a simple binary search algorithm for the cube root so you don’t need to install any external math libraries like gmpy2.

Running the code , we get the flag : apoorvctf{3ncrypt1ng_w1th_RSA_c4n_b3_4_d4ng3r0us_cl1ff_83}

The Riddler's Cipher Delight
https://nahil.xyz/vault/writeups/apoorvctf2026/cryptography/the-riddlers-cipher-delight/
Author Nahil Rasheed
Published at March 24, 2026
Disclaimer This content is provided strictly for educational purposes only.