Security Playbook
by Federico Tejedor Llorente
Learn
Learning path
Concepts
Breaches
Practice
Labs
Playground
Quiz
Work with me
🔥 0
⚡ 0
Playbooks
Playbooks
System Design
Security
●
Algorithms
Portfolio
↗
en
English
✓
Español
← All code reviews
Find the bug · 10/10
Hard
One-click account deletion
The cookie already uses SameSite=Lax. Look closer.
routes/account.ts
01 · Tap the vulnerable line
1
// session cookie: HttpOnly; Secure; SameSite=Lax
2
app.get("/account/delete", requireUser, async (req, res) => {
3
await db.user.delete({ where: { id: req.session.userId } });
4
req.session.destroy(() => res.redirect("/goodbye"));
5
});
02 · What's the problem?
Cross-site request forgery (CSRF)
Missing ownership check (IDOR)
Cross-site scripting (XSS)
Insecure session cookie
03 · How do you fix it?
Switch the cookie to SameSite=None
Add a confirmation dialog in the frontend
Make it a POST with a CSRF token (and ask for the password), never a GET
Check answer