logoalt Hacker News

tmsbrgyesterday at 11:02 PM4 repliesview on HN

I'm surprised there's no mention of the SameSite cookie attribute, I'd consider that to be the modern CSRF protection and it's easy, just a cookie flag:

https://scotthelme.co.uk/csrf-is-dead/

But I didn't know about the Sec-Fetch-Site header, good to know.


Replies

tordrttoday at 3:04 AM

Yep SameSite lax, and just make sure you never perform any actions using Get requests, which you shouldn’t anyway.

show 1 reply
nhumrichtoday at 3:42 AM

This is "not allowing cross site at all" so, technically it's not "request forgery" protection. Yes, this is very semantic, but, CSRF is a vulnerability introduced by enabling CS and CORS. So, technically, same-site cookies are not "protection" against CSRF.

show 2 replies
hatefulhearttoday at 5:17 AM

I’m confused, how does this prevent a CSRF attack?

SameSite or not is inconsequential to the check a backend does for a CSRF token in the POST.

show 2 replies
miguelgrinbergyesterday at 11:32 PM

The OWASP CSRF prevention cheat sheet page does mention SameSite cookies, but they consider it defense in depth: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Re....

show 2 replies