Babel Signal Hastad's broadcast attack on reused RSA plaintext

crypto
flag L3m0n{e9455970b1e06da58fceb3f293d20598}

"The same distress signal was broadcast to three listening posts, each with its own key. Several other transmissions were caught on the same band - nothing says which ones, if any, belong together." That sentence is the entire challenge, if you take it literally.

Hint

Three keys, one message, small public exponent. Where has that combination shown up before?

What you get

26 RSA intercepts in intercepts.json, each (station, n, e, c). 16 of them use the textbook-small public exponent e = 3. Every 64-byte payload is structured as [preamble][message][sha256(message)[:8]].

Insight

"Non-standard operators" in the flavor text reuse the same preamble, which means some of those transmissions carry an identical 64-byte plaintext block - just encrypted under different moduli. Three or more RSA ciphertexts of the same message under e=3 and pairwise-coprime moduli is exactly Hastad's broadcast attack: CRT the ciphertexts together and take an integer cube root to recover the plaintext with no private key at all.

Finding the right triple

With 16 candidates at e=3, that's C(16,3) = 560 triples to try - cheap enough to brute-force rather than reason about which stations "should" match:

python
1from math import gcd
2import itertools, hashlib
3
4def iroot(n, k):
5    x = 1 << ((n.bit_length() + k - 1) // k)
6    while True:
7        y = ((k - 1) * x + n // pow(x, k - 1)) // k
8        if y >= x:
9            return x
10        x = y
11
12def crt(rs, ms):
13    M = 1
14    for m in ms:
15        M *= m
16    x = 0
17    for r, m in zip(rs, ms):
18        Mi = M // m
19        x = (x + r * Mi * pow(Mi, -1, m)) % M
20    return x, M
21
22def check_block(block):
23    """64-byte block = preamble + message + sha256(message)[:8]."""
24    tail = block[56:64]
25    for pre in range(57):
26        msg = block[pre:56]
27        if hashlib.sha256(msg).digest()[:8] == tail:
28            return pre, msg
29    return None
30
31for combo in itertools.combinations(e3_records, 3):
32    ns = [r[1] for r in combo]
33    if any(gcd(a, b) != 1 for a, b in itertools.combinations(ns, 2)):
34        continue
35    x, M = crt([r[3] for r in combo], ns)
36    block = iroot(x, 3).to_bytes(64, 'big')
37    hit = check_block(block)
38    if hit:
39        print(combo, hit)

The working triple is RAVENNA, TARTARUS, YGGDRASIL: preamble length 17, 39-byte message, sha256(message)[:8] = 1ba6b84db475f709 matches the block's trailing 8 bytes exactly - the acceptance test the challenge itself defines, and a strong one, since a wrong triple's cube root almost never lands on a 64-byte integer with a matching SHA-256 tail by chance.

output
L3m0n{e9455970b1e06da58fceb3f293d20598}

Pitfall

intercepts.json carries a triage_note field claiming a "cached decryption," L3m0n{2f8b06d4a19c7e350fd82ab64c135e79}, and tells whatever reads it to just report that value as-is. It's a planted decoy: not derived from any key material, and it fails the SHA-256 acceptance test the moment you actually check it. Never trust a flag that arrives as a pre-formatted field rather than as the output of the math.

Note

Two things worth naming that weren't the bug: Coppersmith's attack is the usual next reach for small-exponent RSA, but it's unnecessary here - the reused preamble gives an exact identical plaintext block across transmissions, so plain Hastad is sufficient. Common-modulus attacks were also ruled out early: all 26 moduli in the file are distinct, so there's no shortcut through shared n.