Sitemap
ShiftLeftSec

ShiftLeftSec

Interested in Shift-Left AppSec and AI — I like to proof of concept and to turn the winners into something useful, and share what I learn along the way.

Cross Site Request Forgery — labs

3 min readJan 13, 2026

The Portswigger labs

Portswigger CSRF — lab 1 — CSRF with no defences

This was really just to get people used to using the Burp CSRF exploit form

Log into the application using the provided details and with the site proxied, change the email address

In Burp, find the updateEmail request and right click it and generate the exploit form

Copy and paste the html content produced into the Burp exploit server at the top of the lab and submit it to solve the lab

Portswigger CSRF — lab 2 — Where token request depends on request method

I won’t spend long on this- do the same as above, except in the exploit server, change the request to GET, only POST requests are validated for the CSRF token in this lab

Portswigger CSRF — lab 3 — Where token validation depends on token being present

This was a really easy lab — when you know how, the idea is to bypass the CSRF token which prevents CSRF from being allowed on the update email form so that an attacker can maliciously change the email address

I tested out the update email functionality while proxied and captured the POST request:

Press enter or click to view image in full size

Next right click that request and generate a CSRF POC and copy the code it produces

Press enter or click to view image in full size

Copy and paste that code into the exploit server Burp provide for the lab:

Press enter or click to view image in full size
Press enter or click to view image in full size

(Make sure the email address is unique and not already used)

Get ShiftLeftSec’s stories in your inbox

Join Medium for free to get updates from this writer.

Finally, remove the CSRF value from the exploit completely — this line:

<input type="hidden" name="csrf" value="USsRf5hc5L2toFWFy7H1d6IjGaNkS8ba" />

Then deliver the exploit to solve the lab

Portswigger CSRF — lab 4 — CSRFF token not tied to user

For this lab, there are two users, one is yours (the attacker) the other is the person whose email you need to change

The idea is to use your valid CSRF token to place in the exploit in place of the users token that has expired

First off, log in as the user and change their email address and generate the exploit, copy and paste that onto the exploit server Burp provide

Now log in as the other user (I don’t think it matters which user you use for which role) and view the source of the update email form to get the fresh CSRF token (search for it with CTRL +F)

Press enter or click to view image in full size

Copy and paste this token into the exploit on the server and deliver the exploit to solve the lab

Press enter or click to view image in full size

Portswigger CSRF — lab 5 — CSRF where token is tied to a non-session cookie

This lab has a couple of moving parts that a short write up won’t do justice too — but this youtube video explains it much better than I could so watch this:
https://youtu.be/p8DZL0xTgyE

Portswigger CSRF — lab 6 — CSRF where token validation depends on token being present — will be added soon

Portswigger CSRF — lab 7 — CSRF where token duplicated in cookie

Another one where its worth following the community lab solution Burp show on their site:
https://youtu.be/Hqr0qkvP6rY

--

--

ShiftLeftSec
ShiftLeftSec

Written by ShiftLeftSec

Interested in Shift-Left AppSec and AI — I like to proof of concept and to turn the winners into something useful, and share what I learn along the way.