include antiforgerytoken in ajax post ASP.NET MVC

I am having trouble with the AntiForgeryToken with ajax. I’m using ASP.NET MVC 3. I tried the solution in jQuery Ajax calls and the Html.AntiForgeryToken(). Using that solution, the token is now being passed: var data = { … } // with token, key is ‘__RequestVerificationToken’ $.ajax({ type: “POST”, data: data, datatype: “json”, traditional: true, … Read more

Django CSRF check failing with an Ajax POST request

I could use some help complying with Django’s CSRF protection mechanism via my AJAX post. I’ve followed the directions here: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ I’ve copied the AJAX sample code they have on that page exactly: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax I put an alert printing the contents of getCookie(‘csrftoken’) before the xhr.setRequestHeader call and it is indeed populated with some data. … Read more

jQuery Ajax calls and the Html.AntiForgeryToken()

I have implemented in my app the mitigation to CSRF attacks following the informations that I have read on some blog post around the internet. In particular these post have been the driver of my implementation Best Practices for ASP.NET MVC from the ASP.NET and Web Tools Developer Content Team Anatomy of a Cross-site Request … Read more

Where to store JWT in browser? How to protect against CSRF?

I know cookie-based authentication. SSL and HttpOnly flags can be applied to protect cookie-based authentication from MITM and XSS. However, more special measures will be needed to apply in order to protect it from CSRF. They are just a bit complicated. (reference) Recently, I discover that JSON Web Token (JWT) is quite hot as a … Read more

Why is it common to put CSRF prevention tokens in cookies?

I’m trying to understand the whole issue with CSRF and appropriate ways to prevent it. (Resources I’ve read, understand, and agree with: OWASP CSRF Prevention CHeat Sheet, Questions about CSRF.) As I understand it, the vulnerability around CSRF is introduced by the assumption that (from the webserver’s point of view) a valid session cookie in … Read more