All jobs / Frontend / web developer / Security

Frontend / web developer interview question · 1–3 years

A cookie-session SPA posts state-changing requests. What do you do in the browser about CSRF?

The strongest answer

Use SameSite=Lax or Strict cookies, send a CSRF token or a custom header on mutations, and don't assume Origin is always present

Why it works

Cookie auth means CSRF is your problem: SameSite plus a token or custom header on POST/PUT/DELETE.

What a good answer covers

Answers that fall short

Who gets asked this

More Security questions