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.
More on Foundations, Threat Modeling and OWASP
What is DevSecOps, and how is it different from DevOps?BeginnerWhat does "shift-left" mean?BeginnerIf we shift left, why do we still need "shift-right" controls?IntermediateWhat are the phases of a secure SDLC and a security activity for each?BeginnerExplain the CIA triad with a DevOps example for each property.BeginnerWhat is threat modeling and when should you do it?Beginner