Boss lesson · Unit 02
The request you did not make
Cookies ride along: tokens, SameSite and the same-origin policy
What you practise
- Cookies ride along on cross-site requests
- CSRF tokens and
SameSite - How same-origin policy and CORS fit
- Clickjacking
- Then order the defences for one small app
Try a question from this lesson
Pick one
Browsers attach a site's cookies to requests to that site, whichever page caused them. What does the bank receive from the hidden form in tab 2?
tab 1: bank.example (logged in)
tab 2: evil.example
hidden form --> POST
bank.example/transferCorrect answer
A request carrying your session cookie: it looks like you
Why
The cookie rides along, so the bank sees an ordinary logged-in request. This is cross-site request forgery (CSRF). Browsers now hold cookies back in some of these cases; this lesson covers how and when.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
CSRF: your browser, their request
The attacker never sees your cookie and never reads the bank's reply. They do not need to.
They only need your browser to send one request that changes something: a transfer, a new email address, a deleted account.
The defence: every state-changing request must carry something a foreign page cannot know or cannot send.
Concept
SameSite cookies
SameSite tells the browser when to attach a cookie to requests that another site started.
Strict: never. Lax: only when the user navigates to the site with a safe method, such as clicking a link, and not on cross-site form POSTs or background requests. None: always, and then Secure is required.
Many browsers now treat a cookie with no SameSite as Lax.
Set-Cookie: sid=abc123; HttpOnly;
Secure; SameSite=Lax10 more exercises in the app
- 5× multiple choice
- 1× fill the blanks
- 1× type the answer
- 1× true or false
- 1× match the pairs
- 1× order the lines
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.