October 15, 2026
Most Cookies | CyLab (PicoCTF) | Medium | Write-up
This CTF is somewhat of a continuation of the other cookie-based CTF I went over, just slightly more challenging.
By ohwow
2 min read
So, just from the description we can tell that we're going to be dealing with flask cookies, great.
The creator was also nice enough to hand us the code directly!
The code is pretty straight forward, the first thing I did was skim through the code looking for a variable of something along the lines of "secret key". Found it right at the very top of the code.
As we can see, the so called secure secret key is just a random choice from the list of cookie names above.
Another part of the code that caught my attention, was this.
Since we know what the secret key can only be one word from the ones that were so generously given to us, we can just bruteforce it using flask unsign, but first, I would like to see what my current session cookie has to say.
From the block of code we saw above, if that check variable is equal to "admin" we get a response with the flag (assuming we also have the necessary session cookie).
To bruteforce the cookie we need, I'm first going to get all the words from the list in the code and sort them out nicely to use as a wordlist.
Then, using flask unsign with the wordlist I just created, we can start the bruteforce.
What this does is launch a bruteforce attack on the secret key by treating every word in the wordlist as a candidate for it, then uses it to mathematically recompute the signature, and checks if it matches the one attached to my own cookie.
It takes an entry from the wordlist and combines it with the payload, and then calculates what the signature would be. To put it more simply, say that my payload is {'very_auth': 'snickerdoodle'}, and the secret key is "secretkey123", essentially the formula for the signature is the hashed value of the secret key + the payload.
So, if any entry in the wordlist after getting signed matches the signature of my cookie, it is the secret key. Since the other entries in the wordlist don't have a signature given by the server (unlike my cookie and the secret key).
After we get the secret key, all we have to do is sign it and replace our original session cookie with it using the developer tools.