Skip to main content
Chapter 5 CSRF — Cross-Site Request Forgery

CSRF From Zero — Discovery & Classic Exploit

9 min read Lesson 25 / 95 Preview

Cross-site request forgery, in one lesson

CSRF works because the browser automatically attaches cookies to any request — including requests another website triggers. If a state-changing endpoint authenticates the user with cookies alone and lacks any anti-CSRF defence, an attacker page can act on behalf of the logged-in victim.

What to check on every endpoint

The endpoint accepts POST, PUT or DELETE. It is authenticated by cookie alone, with no Authorization header and no token in the body. The session cookie does not have SameSite=Lax or Strict. There is no CSRF token, or the token is not actually validated on the server side. Any endpoint that ticks all four boxes is exploitable.

A classic proof of concept

Build a tiny HTML page that contains a form pointing at the target endpoint, with the form fields set to whatever the attacker wants to change — typically the victim's email address. Add a small script that auto-submits the form. Host the page and trick the victim into visiting it while they are logged in. The browser submits the form, the cookie is attached, the email gets changed, the password reset email arrives at the attacker, and the account is taken over.

Modern reality in 2026

Browsers default cookies to SameSite=Lax, which kills classic POST-based CSRF for cross-site requests. So in 2026 your hunt focuses on the surfaces where Lax does not protect: GET-based state changes, top-level navigation forms, JSON endpoints that read text/plain content-type to dodge CORS preflight, and applications that explicitly set SameSite=None for legacy iframe support. There is still plenty of CSRF to find — you just have to know where it lives now.

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support