Questions tagged [csrf-protection]

Cross-site request forgery, also known as a one-click attack or session riding and abbreviated as CSRF (sometimes pronounced sea-surf) or XSRF, is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts. Unlike cross-site scripting (XSS), which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user's browser.

Cross-site request forgery, also known as a one-click attack or session riding and abbreviated as CSRF (sometimes pronounced sea-surf) or XSRF, is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts. Unlike cross-site scripting (XSS), which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user's browser.

Web sites have various CSRF countermeasures available:

  • Requiring a secret, user-specific token in all form submissions and side-effect URLs prevents CSRF; the attacker's site cannot put the right token in its submissions. This technique is commonly referred to as the Synchronizer Token Pattern.
  • Requiring the client to provide authentication data in the same HTTP Request used to perform any operation with security implications (money transfer, etc.)
  • Limiting the lifetime of session cookies
  • Ensuring that there is no clientaccesspolicy.xml file granting unintended access to Silverlight controls
  • Ensuring that there is no crossdomain.xml file granting unintended access to Flash movies
  • Verifying that the request's header contains a X-Requested-With (used by Ruby on Rails before v2.0 and Django before v1.2.5), or checking the HTTP Referer header and/or HTTP Origin header. These protections have been proven insecure under a combination of browser plugins and redirects which can allow an attacker to provide custom HTTP headers on a request to any website, hence allowing a forged request.

Links:

712 questions
6
votes
1 answer

Spring CSRF token life

I am implementing CSRF protection using Spring security as per the doc One question I have is: When this token will get invalidated by the Spring security? Does the token gets invalidated for each request submit?
Rakesh
  • 217
  • 2
  • 10
6
votes
1 answer

Symfony2 logout CSRF protection: csrf_provider unrecognized

How can I protect the logout action? I read default configuration, and set logout: csrf_parameter: _token csrf_provider: ~ intention: logout but when I'm trying to clear cache the following error…
Invis1ble
  • 1,295
  • 2
  • 17
  • 35
6
votes
1 answer

Where does Rails 4 store the authentication token for CSRF protection?

Inside one of my controllers, I write the following to protect certain pages from CSRF. protect_from_forgery :only => [:foo, :bar] When I load the URL's which correspond to foo and bar, and I view the HTML, I do not see any hidden input fields or…
merlin2011
  • 71,677
  • 44
  • 195
  • 329
6
votes
1 answer

Laravel 4.1 _token error on form submit

I am doing simple cms in laravel 4.1 , i created many form and they working fine, but the last form which i create throws error on submit. Illuminate \ Database \ Eloquent \ MassAssignmentException _token The data posted by form also show on error…
Dexture
  • 976
  • 1
  • 11
  • 29
6
votes
0 answers

CSRF token in GET method

I am going to avoid CSRF atack in my web application. I've set up csrf configuration on my apache, like this: ... CSRF_Enable on CSRF_Action deny CSRF_EnableReferer off Also, I've installed the following…
fashuser
  • 2,152
  • 3
  • 29
  • 51
6
votes
5 answers

laravel 4: why is Request::header() not getting the specified header?

I'm trying to get a header value with: Request::header('csrf_token') though, my firebug says in the headers that I have the csrf_token set to baMDpF0yrfRerkdihFack1Sa9cchUk8qBzm0hK0C. In fact, I can get that csrf_token instead with a native php…
Tyro Hunter
  • 755
  • 1
  • 8
  • 20
5
votes
1 answer

Ajax call failing in Django

I have the following ajax call to update a particular field of a model $("#updateLink").click(function(){ var dec_text = $('#desc_text').val(); $.ajax({ type: "POST", url:"/users/update_desc/", data: { 'val':…
Sachin
  • 3,672
  • 9
  • 55
  • 96
5
votes
2 answers

Are we really secured from CSRF?

confirm.php
Do…
kornesh
  • 618
  • 2
  • 9
  • 24
5
votes
1 answer

Simulate CSRF Attack

I want to simulate CSRF Attack to check my website vulnerability. I tried it on my asp.net webapplication but failed to simulate. So please help me to simulate the CSRF attack. I have simulated by having a test.aspx.
Tej
  • 51
  • 1
  • 3
5
votes
1 answer

How to configure my NGINX to allow CSRF protection on my Spring Boot application

I am trying to separate my Spring Boot application from my front-end, namely my Angular 7+ application, by using an NGINX reverse proxy. My Spring Boot application is of version 2.0.3+.RELEASE and has CSRF protection enabled. My Security…
DanielM
  • 127
  • 1
  • 9
5
votes
0 answers

How to add x-xsrf-token using HttpClientXsrfModule angular 6

I am using the JWT token for the authentication and storing that in local storage and now wanted to add CSRF token with that, is it possible to activate CSRF just in angular? As JWT token generate is it possible to generate CSRF randomly with that…
vaibhav
  • 51
  • 1
  • 4
5
votes
4 answers

Laravel 5.7 Auth::loginUsingId() not working after CSRF token generated

I am trying to auto-login user on step-2 of registration steps. After successful insert into db i am using Auth::loginUsingId($user_id) to auto-login user using ajax. I am always submitting CSRF token on each steps. Now the problem is after…
Mahesh Singh Chouhan
  • 2,558
  • 1
  • 16
  • 26
5
votes
6 answers

Prevent Logout Action from Happening from Untrusted Sources in PHP

I have an action in my site: http://mysite.com/User/Logout This will log the current user out of his/her session. Since this is a simple GET request, a malicious user could either create links to this page or even put this link in an image's src…
Doctor Blue
  • 3,769
  • 6
  • 40
  • 63
5
votes
4 answers

How to protect web application from cookie stealing attack?

My web application's authentication mechanism currently is quite simple. When a user logs in, the website sends back a session cookie which is stored (using localStorage) on the user's browser. However, this cookie can too easily be stolen and used…
5
votes
2 answers

How to protect against CSRF by default in ASP.NET Core

Inspired by: How to protect against CSRF by default in ASP.NET MVC 4? Is there a way to achieve the same result in ASP.NET Core?
Ludisposed
  • 1,709
  • 4
  • 18
  • 38