Web security ยท try it live

Why do CORS and CSRF exist if the backend already checks auth?

Two sites, one bank. Watch a random page try to read and rob your logged-in session, for real.

๐Ÿงช This is a sandbox demo. A fake bank with pretend money, no real accounts and nothing to break. Click around freely.
๐Ÿฆ
The bank visit โ†—
api.barisalgun.dev
The real backend. You log in here. Fake money.
๐Ÿ˜ˆ
This page
barisalgun.dev
Some other site, riding your open session.
๐Ÿ”  Open DevTools โ†’ Network (F12) before clicking. That is where you see it for real.
This page
barisalgun.dev
Bank session
โ€”
Balance
โ€”

STEP 0 Log into the bank first

CSRF only works on a session you already have. Log in on the bank's own site, then come back.

๐Ÿฆ Open the bank & log in โ†—
Log in at the bank, then check.

Can it READ your data? CORS

Your cookie is sent automatically. But reading the reply needs the bank's permission.

โ€”

Can it CHANGE your data? CSRF

Reading is blocked, but a write needs no reading. One transfer checks a token, one does not.

โ€”

Request log

Real setup: this page on barisalgun.dev, the bank on api.barisalgun.dev. Same site, different origin, just like a frontend and its API.