BreizhCTF 2025 | Write-up of my challenges
Write-up of my cryptography challenges for BreizhCTF 2025: AES-GCM, SIS/ISIS, LLL and Module-LWE.

Table of contents
Introduction
BreizhCTF is a French CTF held on-site at the Couvent des Jacobins in Rennes; there are no qualifications. This year it brought together more than 100 teams of 5 people each! The challenges are made every other year by students from ENSIBS (my school!) and ESNA (our friends from Rennes 👀). This year it was my school’s turn, and I had the opportunity, along with ThéoR, to design the cryptography challenges for the event.
Here is a summary table of our challenges:
| Challenge | Author | Difficulty | Solves | Tags |
|---|---|---|---|---|
| Cube Median | TheoR | Easy | 58 | PRNG, QR code |
| AutHentification (ou pas…) | skilo | Easy | 19 | AES-GCM, Nonce reuse |
| Leaked | TheoR | Easy | 6 | Side Channel, Elliptic curve |
| Demi-tour | skilo | Medium | 4 | SIS |
| Locked | TheoR | Hard | 0 | PRNG, Time-lock encryption |
| AutHentification, le retour ! | skilo | Hard | 1 | AES-GCM, Implementation error |
| As-tu de bons yeux ? | skilo | Very hard | 0 | Module LWE, CRT |
The blog article below details the solving steps for each of my challenges. Here is a TL;DR of the solution for each of them:
- AutHentification (ou pas…) : No GCM tag verification and nonce reuse make it possible to forge a valid administrator ticket;
- Demi-tour : This challenge implements a hash function built on the SIS problem (Short Integer Solution), i.e. given , find with a small infinity norm such that ). The SIS problem is poorly dimensioned, so it is possible to find a preimage using LLL or BKZ;
- AutHentification, le retour ! : An implementation error in GCM mode makes it possible to forge valid tags (a Forbidden Fruit style attack);
- As-tu de bons yeux ? : Requires breaking an instance of Module-LWE in its decisional version with the module ; the quotient polynomial has a particular factorization allowing Module-LWE to be solved in several smaller-dimensional Euclidean lattices via the Chinese remainder theorem.
For all these challenges, the sources and Python/SageMath solving scripts are available at the following address: github.com/BreizhCTF/breizhctf-2025/crypto. In addition, my challenges are available for replay on the CryptoHack platform: cryptohack.org/challenges/ctf-archive/.
Challenge solutions
AutHentification 1
The goal of this challenge is to forge an admin cookie in order to access the administrator area. To do so, we must manage to encrypt JSON containing the payload: "role": "super_admin".
The encryption used is AES-GCM 128. In our case, we can view this encryption as AES-CTR; indeed, authenticity is not verified, which can be seen in the crypto.py code by diffing it against the same challenge at a higher difficulty.
We can also notice that the AES key is constant and the IV is fixed at 0, so the keystream will always be the same. By combining this with the fact that we can create an account by choosing the username (let’s call it account 1, and denote its cookie C1), we are able to forge an admin cookie (let’s call it account 2, and denote its cookie C2).
Indeed, the user cookie is: C1 = keystream XOR JSON_user; we know JSON_user, so we can recover the keystream because: keystream = C1 XOR JSON_user.
We can now forge C2 by computing: C2 = keystream XOR JSON_admin, with JSON_admin being a JSON of our choice containing the super_admin role.
A complete implementation of this solution is available in Python in the solve.py file.
Demi-tour
Some notation
- : the set .
- : the set of vectors of size with coefficients in .
- : the set of matrices of size with coefficients in .
- : the ring of integers modulo , also denoted .
- If is a vector of size , then are its coordinates.
Parameters
| Parameter | Value |
|---|---|
| 48 | |
| 50 | |
| 2 | |
| 256 |
Goal
The goal of this challenge is to find a preimage for the hash() function.
def hash(msg: str):
msg = msg.encode()
msg = sanitize(msg, l)
x = vector(Zn, msg)
A = Matrix(Zn, k, l, get_a())
return bytes(A*x)
Let us analyze this function, step by step.
sanitize
def sanitize(a: bytes, l: int):
a = pad(a, BLOCK_LEN)
out = b"\x00"*BLOCK_LEN
for i in range(0, len(a), BLOCK_LEN):
out = xor(out, a[i:i+BLOCK_LEN])
return btq(out)[:l]
Here is how this function works:
- The message — after being padded with PKCS #7 — is grouped into 16-byte blocks.
- The blocks are all XORed together into
out. - The
outvariable is converted into a base-5 representation and then truncated to the -th element (i.e. it is converted into a vector of ); it is this truncated version that is returned.
The input of this function is a byte string of length 16 (see the assert in the chal.sage file), and the output is a vector of .
>>> log(256**16, 2) # Size in bits of the input set
128.0
>>> log(5**50, 2) # Size in bits of the output set
116.09640474436812
This function introduces a slight compression — 12 bits — so nothing serious; it will not be hard to reverse with brute force (indeed, we have a stopping condition: the flag format). Let us now analyze the rest of the hash() function.
A*x
We have : the constant matrix (see the A.txt file), and : our message after going through the sanitize() function. The hash is an element of , obtained by the product: .
The problem of recovering in (i.e. finding an with only small coefficients; in ) from and is called ISIS (for Inhomogeneous Secret Integer Solution).
In our case, the parameters are weak, so we have to solve an ISIS problem of small dimension, which is very efficient with the LLL algorithm (or its BKZ variant).
Solving
A complete implementation of the solution is available in the solve.sage file
TL;DR
- We will build the matrix whose kernel is the set of such that .
- Then we will run
LLL()on the matrix generating this kernel in order to look for a small solution (yes, we are looking for a small ). - Magic (or not…): the small we are looking for will be in the reduced matrix.
- We brute-force to reverse
sanitize(). Done.
If I build the matrix:
We notice, by expanding the matrix product, that with , the product (iff the are chosen correctly to remove or add the right number of times the modulus ).
The vector therefore lies in the kernel of . It now suffices to compute this kernel. Since has a small norm, applying LLL() or BKZ() to the matrix generating this kernel will allow us to recover and therefore .
Here is the implementation of this process in SageMath:
L = block_matrix([A, -h, n*identity_matrix(k)])
kerL = L.right_kernel().matrix()
llled = kerL.LLL()
for idx, vec in enumerate(llled.rows()):
vec = vec[:l]
if all([v in range(-beta, beta+1) for v in vec]):
x = list(vec)
break
It then suffices to brute-force the missing characters of the flag until the flag, as a bytestring, matches the flag format.
AutHentification 2
This challenge is the same as its first version, with one detail: the tag is now verified.
Let us recall the context:
- The cookies are encrypted and authenticated JSON containing two values: “username” and “role”.
- The goal is to forge an admin cookie, i.e. encrypt and authenticate the payload:
{ "username": "toto", "role": "super_admin"}. - The integrated encryption is provided by a Python implementation of AES-GCM 128 with a constant, null IV.
- For each (key, IV) pair, we have an encryption oracle over a single JSON payload.
With this context, we quickly deduce that:
- The encryption is very easy to bypass, see the
AutHentification (ou pas...)challenge. - For authentication: it is impossible to use the
Forbidden Attack(see point 4 above).
The statement and the header of the gcm.py file clearly say that the implementation was made by the intern; let us look for an implementation error. The code is quite long, so we will use a diffing approach. We will compare the functions one by one with the specifications cited in the comment at the top of the gcm.py file: NIST Special Publication 800-38D.
After comparing — algorithm by algorithm — the Python code with the specifications, we realize that in algorithm 5, at line 4, an increment is missing:
# Algorithm 5: GCM-AD_K
def decrypt(self, C, T, A=b""):
assert len(T) == BLOCK_LEN
J = self.iv + b"\x00"*(CTR_LEN-1) + b"\x01"
P = self.gctr(J, C) # Ici, sur le J.
TT = self.build_tag(C, A, J)
if TT != T:
return (P, False)
return (P, True)
This may seem harmless at first glance, but looking more closely at the diagram below, we realize that the nonces of the two GCTR_K calls (the one ensuring confidentiality and the one ensuring authentication) are then identical.

We deduce the following: (all the following operations take place in , with )
With the keystream (we know it; it is the same as the one ensuring confidentiality), and the AAD and the ciphertext (we will consider each of them to be one block long).
Moreover, according to the definition of GHASH:
We know ; it suffices to subtract it and then solve this equation for .
Once is recovered, it becomes trivial to forge a valid tag. A complete solution is implemented in the solve.sage file.
As-tu de bons yeux ?
Some notation
- : the set .
- : the ring of integers modulo , also denoted .
It is obviously impossible — at least today — to break the (D-)MLWE problem when it uses the level 5 parameters of ML-DSA; it is therefore necessary to find an implementation error.
We can notice that, in the parameters.sage file, the polynomial by which the ring is quotiented is instead of . The former is factorizable in . Indeed:
Let and ; we have a ring morphism from to that maps the elements to (in short, it is an evaluation at ).
It therefore maps the elements to (indeed, is isomorphic to ); what is nice about this morphism is that it “preserves” roughly the size of the coefficients, meaning that if an element of has coefficients in , then, at the output of the morphism, it becomes an element of . Since , the element remains “small”.
If we have an instance of D-MLWE: , where , and are vectors of and is a matrix over the same set. We can apply this morphism to each of these elements and thus end up with a D-MLWE instance with very small parameters and in (which is solved very efficiently with LLL()/BKZ()).
Indeed, if we find an and an with coefficients in , then it is an MLWE instance; otherwise, it is not. Thanks to this strategy, we can solve the challenge! A complete implementation of this solution is available in the solve.sage file.
For more resources on this topic, section 4.5 of the paper Basic Lattice Cryptography - The concepts behind Kyber (ML-KEM) and Dilithium (ML-DSA) by Vadim Lyubashevsky explains this attack very well.