CSRF Lab: Make a Victim’s Bank Send You Money

✨ AI Summary
The victim is logged in to QuickBank in one tab. In another tab, they open a page you control. Your page quietly submits a form to QuickBank's transfer endpoint, and their browser helpfully attaches their bank session cookie. QuickBank sees a valid, logged-in request and moves $9,999 to your account. The victim never clicks anything on the bank's site.
Lab at a glance: Intermediate · 90 XP · about 10 minutes · runs in your browser, no signup or setup. Try it yourself first; the full solution is behind a spoiler below.

What this lab teaches

Cross-site request forgery (CSRF) abuses the way browsers attach cookies automatically. If a site uses only a cookie to decide who you are, any other site can make your browser send a request to it, and that request will look like it came from you.

The attacker cannot read the response. They do not need to. For a state-changing action like a transfer, sending the request is enough.

How QuickBank handles transfers

QuickBank’s transfer form posts the recipient and amount and relies only on the session cookie to identify the user. There is no anti-CSRF token and no origin check. The lab shows the bank on one side and an attacker page on the other. It is solved when a transfer of $9,999 to attacker_account goes through from the victim’s session.

The attack approach

  • Look at the bank’s transfer request: which fields it sends, and that nothing in it is secret or unpredictable.
  • If every value can be guessed, a form on any other site can reproduce the request exactly.
  • The victim’s browser will add the bank cookie by itself because the request is going to the bank’s address.
  • Make the form submit automatically, so the victim only has to load the page.

Full walkthrough (spoiler)

Stuck after a few attempts? Open the steps below. Solving it yourself first is worth more XP, and more learning.

Show the step-by-step solution
  1. Click “Visit malicious page” to load the attacker site in the lab.
  2. Look at the hidden form it contains: it points at QuickBank’s transfer endpoint, with attacker_account and $9,999 already filled in.
  3. Click “Submit silently”. The form posts to QuickBank from the victim’s browser.
  4. The browser attaches the victim’s session cookie, QuickBank accepts the transfer as genuine, and the lab marks you solved.

Why it works

QuickBank checks who is sending the request, using the cookie, but not where it was started. Cookies are sent with every request to the site that set them, no matter which page triggered the request. Without a secret token that only the real site’s pages know, the bank cannot tell its own form from yours.

Core principleEvery state-changing request needs proof it came from your own pages: an anti-CSRF token, SameSite cookies, or an origin check.

Where this happens in the real world

CSRF was common enough to hold its own place in the OWASP Top 10 until 2017. It fell out partly because frameworks now include CSRF tokens by default and partly because browsers changed: since 2020 Chrome treats cookies without a SameSite attribute as SameSite=Lax, which blocks most cross-site POSTs. It still appears in custom code, legacy apps, APIs that use cookies, and anywhere protection has been switched off.

How to defend against it

  • Use anti-CSRF tokens (synchroniser tokens) on every state-changing form and request. Most frameworks do this for you.
  • Set SameSite on session cookies, Lax at least, Strict for sensitive apps.
  • Check the Origin or Referer header on state-changing requests as an extra layer.
  • Never change state with GET requests.
  • Ask again for sensitive actions, such as re-entering a password or confirming with a second factor for transfers.
Mr Elite tip: When testing a real app with permission, look for any state-changing request with no token: email changes, password changes and adding a payee are the high-value ones. An email-change CSRF often leads straight to account takeover through password reset.

Try it, then go further

Reading about it is the easy part. Open the lab, try your own approach before peeking at the spoiler, and see how many attempts it takes.

❓ Frequently asked questions

What is CSRF?
Cross-site request forgery is an attack where a malicious site makes a logged-in user's browser send a request to another site, which accepts it because the browser automatically includes the user's cookies.
Can a CSRF attacker read the response?
No. Same-origin rules stop the attacker reading the response, but for actions like transfers or email changes, sending the request is all they need.
Do SameSite cookies stop CSRF?
SameSite=Lax blocks most cross-site POST requests and SameSite=Strict blocks more, but tokens are still recommended as the primary defence.
What should I try next?
The OAuth missing state parameter lab, which uses the same idea to log a victim into the attacker's account.
⚡
Join free to earn XP for reading this article Track your progress, build streaks and compete on the leaderboard.
Join Free
Lokesh N. Singh aka Mr Elite
Lokesh N. Singh aka Mr Elite
Founder, Securityelites · AI Red Team Educator
Founder of Securityelites and creator of the SE-ARTCP credential. Working penetration tester focused on AI red team, prompt injection research, and LLM security education.
About Lokesh ->

Leave a Comment

Your email address will not be published. Required fields are marked *