A modern approach to preventing CSRF in Go
alexedwards.net·9h·
Flag this post

Go 1.25 introduced a new http.CrossOriginProtection middleware to the standard library — and it got me wondering:

Have we finally reached the point where CSRF attacks can be prevented without relying on a token-based check (like double-submit cookies)? Can we build secure web applications without bringing in third-party packages like justinas/nosurf or gorilla/csrf?

And I think the answer now may be a cautious “yes” — so long as a few important conditions are met.

If you want to skip the explanations and just want to see what those conditions are, you can click here.

The http.CrossOriginProtection middleware

The new http.CrossOriginProtection middleware works by checking the values in a request’s `Sec-F…

Similar Posts

Loading similar posts...