Interview Prep/DevSecOps/Foundations, Threat Modeling and OWASP

What is CSRF and how do SameSite cookies help?

IntermediateConceptFoundations, Threat Modeling and OWASP
Answer

CSRF tricks a logged-in user's browser into sending an authenticated, state-changing request to your site from another origin. The browser attaches cookies automatically, so the server cannot tell it was forged.

Defences: anti-CSRF tokens (synchroniser or double-submit), SameSite=Lax or Strict on session cookies so they are not sent on cross-site subrequests, checking Origin/Referer, and requiring custom headers for APIs. APIs using bearer tokens in the Authorization header are not CSRF-prone.

All DevSecOps questions Roadmap: Security in the pipeline

More on Foundations, Threat Modeling and OWASP