News for hackers. Stuff that matters.
Re:A modern approach to preventing CSRF in Go by RagingCactus on Wednesday October 15, 2025 @06:05AM (#45590206)
The SameSite cookie flag is effective against CSRF when you put it on your session cookie, it's one of its main use cases. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/... for more information.

SameSite=Lax (default for legacy sites in Chrome) will protect you against POST-based CSRF.

SameSite=Strict will also protect against GET-based CSRF (which shouldn't really exist as GET is not a safe method that should be allowed to trigger state changes, but in practice some applications do it). It does, however, also make it so users clicking a link to your page might not be logged in once they arrive unless you implement other measures.

In practice, SameSite=Lax is appropriate and just works for most sites. A notable exception are POST-based SAML SSO flows, which might require a SameSite=None cookie just for the login flow.

Re:A modern approach to preventing CSRF in Go by hmry on Wednesday October 15, 2025 @06:24AM (#45590336)
This page has some more information about the drawbacks/weaknesses of SameSite, worth a read: https://developer.mozilla.org/en-US/docs/Web/Security/Attack...

You usually need another method as well

Re:A modern approach to preventing CSRF in Go by RagingCactus on Wednesday October 15, 2025 @06:33AM (#45590389)
Yes, you're definitely right that there are edge cases and I was simplifying a bit. Notably, it's called SameSite, NOT SameOrigin. Depending on your application that might matter a lot.

In practice, SameSite=Lax is already very effective in preventing _most_ CSRF attacks. However, I 100% agree with you that adding a second defense mechanism (such as the Sec header, a custom "Protect-Me-From-Csrf: true" header, or if you have a really sensitive use case, cryptographically secure CSRF tokens) is a very good idea.

Re:A modern approach to preventing CSRF in Go by jeremyscanvic on Wednesday October 15, 2025 @06:16AM (#45590282)
Thanks for correcting me - I see my web sec knowledge is getting rusty!