Dhanurbhanga: The Fractured Invariant

By Team Cryptonite · 2 min read

About the CTF: Pinaka CTF

Produce a well-formed Pinaka Tension Machine (PTM) program whose final register equals TARGET = 3205865151537252764. A formal proof says that's impossible over unbounded integers, but the real checker does its…

Dhanurbhanga: The Fractured Invariant

**Pinaka CTF 2026** · Reverse engineering · Team Cryptonite · All 44 Pinaka write-ups


Category: reverse engineering / logic

Flag: PINAKA{dhanurbhangaasingleuint64wrapshattersshivasunbreakablebow}

Overview

Produce a well-formed Pinaka Tension Machine (PTM) program whose final register equals TARGET = 3205865151537252764. A formal proof says that's impossible over unbounded integers, but the real checker does its arithmetic in uint64.

Files:

Analysis

The machine:

pinaka_check.c

Why the proof says no. With X0 = 0 and every immediate divisible by 3, "x == 0 (mod 3)" survives every opcode:

Every reachable x is divisible by 3, but TARGET == 2 (mod 3), so it's unreachable over Z. formal_model.py implements exactly this and rejects every attempt.

The crack. The proof assumed exact integers, but the checker works mod 2^64, and:


2^64  ==  1 (mod 3)     (not 0)

Every wraparound subtracts a multiple of 2^64, and because that isn't divisible by 3, it shifts the residue of x mod 3. One overflow is enough to escape the invariant.

Solution

We need a true-integer sum S divisible by 3 (so every immediate is legal) and congruent to TARGET mod 2^64:


S = TARGET + k*2^64 ,   need S  ==  0 (mod 3)
   =>  (TARGET + k)  ==  0 (mod 3)   =>   k  ==  -TARGET  ==  1 (mod 3)

With k = 1:


S = TARGET + 2^64 = 21652609225246804380      (S % 3 == 0, S mod 2^64 == TARGET)

Split S into two ADDK immediates, each below 2^64 and divisible by 3 (2^64 - 1 == 0 mod 3):


10 ffffffffffffffff   ADDK 18446744073709551615   (= 2^64-1,  ==  0 mod 3)
10 9d892eb35e857d2c   ADDK  3205865151537252765    ( ==  0 mod 3)
00                    HALT

Program hex (19 bytes): 10ffffffffffffffff109d892eb35e857d2c00

Under uint64: 0 + (2^64-1) = 2^64-1, then adding 3205865151537252765 overflows once and wraps to exactly TARGET.

Local verification:

formal_model.py rejecting the program next to the compiled pinaka_check accepting it

Submission


POST /mithila/dhanurbhanga   {"program":"10ffffffffffffffff109d892eb35e857d2c00"}
 ->  {"status":"bow-broken",
   "checker":"ACCEPT x=3205865151537252764 == TARGET",
   "flag":"PINAKA{dhanurbhanga_a_single_uint64_wrap_shatters_shivas_unbreakable_bow}"}

Notes

Read this post on CyberHx →