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
5
votes
1 answer

When is the ring anti-forgery token inserted?

I'm trying to understand when the ring anti-forgery token is generated or inserted in an HTML page. I'm using Compojure / ring / hiccup but I take it my question is really about ring. I don't have any problem per se: I just want to know when and how…
Cedric Martin
  • 5,945
  • 4
  • 34
  • 66
5
votes
2 answers

How to Prevent Cross-Site Request Forgery Attack?

We ran Burp Suite on our product and found some security vulnerabilities. The tool detected some of the CGI files which are vulnerable to Cross-Site Request Forgery attacks (CSRF). As usual I did search for CSRF protection module on CPAN and found…
Chankey Pathak
  • 21,187
  • 12
  • 85
  • 133
5
votes
1 answer

InvalidAuthenticityToken errors in mobile

I have read multiple questions and answers here on StackOverflow about InvalidAuthenticityToken and protect_from_forgery but get none the wiser. I have a website that get hundreds of these errors every day. They seem to be mainly (only?) from…
Christoffer
  • 2,271
  • 3
  • 26
  • 57
5
votes
2 answers

How to prevent my web app from CSRF(Cross site request forgery) in java

I am trying to prevent my web application from CSRF(Cross site request forgery) I followed this link Link for CSRF This is what I have tried. To implement this mechanism in Java I choose to use two filters, one to create the salt for each request,…
Varun
  • 4,342
  • 19
  • 84
  • 119
5
votes
1 answer

CSRF in token based authentication

We have a token based OAuth authentication mechanism for our angularjs application. The acunetix tool indicated that XSRF threat is there. Is CSRF an issue for token based authentication (Because we are not using any cookies for user identification…
rahulmr
  • 681
  • 1
  • 7
  • 19
5
votes
2 answers

Rails 5.0.0beta3: ActionController::InvalidAuthenticityToken in development

I have just started a simple app with a couple of forms on Rails 5.0.0beta3. In development, using http://localhost:3000 on Safari or Chrome to access the app, if I fill a form and submit it I always get an ActionController::InvalidAuthenticityToken…
5
votes
4 answers

laravel 5 csrf_token value is Empty

Why laravel 5 csrf_token value is empty always ? How can i get that token value ? I tried, {!! csrf_token !!} , {{ csrf_token }} and {{ Form::open() }} ....{{ Form::close() }} MY OUTPUT
Shankar Thiyagaraajan
  • 1,705
  • 4
  • 28
  • 46
5
votes
1 answer

Customizing CSRF error page in Spring Security

Normally when a page is left until session expiration and I try to submit a POST action, the CSRF token generated by Spring Security will not be matching the server's expected value. An error is the expected result in this case. However, I always…
usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305
5
votes
0 answers

Making Rails Authenticity Token work with iFrame or Facebook

It's been known that the Rails CSRF authenticity token doesn't work inside an iframe or Facebook canvas. Iframe causes Can't Verify CSRF Token Authenticity n Rails The recommended solution is turning it off. However, I've been getting some bots…
5
votes
1 answer

Rails Can't verify CSRF token authenticity on Heroku/production only

The app works OK locally in both development and production mode, but once deployed on Heroku, the CSRF validation fails. This is a vanilla, non-ajax request. Locally, I run in producion mode with RAILS_ENV=production heroku local -e production I…
aaandre
  • 2,502
  • 5
  • 33
  • 46
5
votes
1 answer

Error: CSRF token missing, hackathon-starter plus AngularJS

I'm integrating AngularJS into hackathon-starter. It was done as I mentioned it here with the following test.html and test.controller.js
The record: {{record}}
5
votes
1 answer

Cross site request forgery

I read this tutorial which gives a nice explanation to prevent CSRF but it is still going out from my brain. According to this tutorial in method one they are including a random token with each request. So in the form they have included something…
Shubham Gupta
  • 227
  • 2
  • 9
5
votes
1 answer

How often does the CSRF token change in YII frame work

I have recently read about csrf tokens. I am using YII framework to develop my project. I enabled csrf validation in config/main.php and yii is putting a token in a hidden form field. And checking if the token is valid. Everything is fine. But I…
prasadmsvs
  • 1,621
  • 4
  • 18
  • 31
5
votes
2 answers

csrf token using

I'm interested in a protecting of my web application by using generation a csrf token. My question is how do I need to send that token back to a server: using query param or http header x-csrf-token ? And what is the difference
Erik
  • 14,060
  • 49
  • 132
  • 218
4
votes
3 answers

How does this CSRF protection work?

The following is an example taken from Facebook's authentication page. What is the idea behind adding data to the session and then redirecting to a URL using javascript? Also why do an md5 hash of a uniqid?
James P.
  • 19,313
  • 27
  • 97
  • 155