سبحان الله و بحمده سبحان الله العظيم ❤️

← BACK TO WRITEUPS
AES-GCM BreizhCTF HIGH

AES-GCM Nonce Reuse — The Forbidden Attack

Target: Authentification-1 | Vulnerability: Counter Mismanagement

﴿وَقُلْ رَبِّ زِدْنِي عِلْمًا﴾ — طه: 114

Vulnerability

The Flask application uses a persistent MASTER_KEY and a static, hardcoded IV (12 bytes of nulls). The intern's implementation starts encryption at J₀ instead of J₁ = inc(J₀), meaning the first 16 bytes of keystream used for encryption are the same bytes used to blind the authentication tag.

def encrypt(self, P, A=b""):
    J = self.iv + b"\x00"*(CTR_LEN-1) + b"\x01"  # J0
    C = self.gctr(J, P)   # BUG: Starts at J0, not J1
    T = self.build_tag(C, A, J)  # Blinds tag with E_K(J0)
    return C, T

Exploitation

Key Takeaways

Flag

BZHCTF{ne_jamais_re-utiliser_le_nonce_e1d6ce70d3d1018c}