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
0
votes
0 answers

Rails CRSF authentication token, how to put the div created with form_for at bottom instead of top?

Good afternoon everyone, I'm using rails to build a web application (naturally) and I'm currently working on a form. This form gets created by using the form_for rails helper. The form_for helper also includes CSRF if it's enabled which it is. My…
SidOfc
  • 4,552
  • 3
  • 27
  • 50
0
votes
1 answer

SYMFONY2 - CSRF Token invalid Allwais

So... basically it. i have a form class and then I render but allways return csrf error. Form class: class FormTest extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder …
0
votes
0 answers

GET and SET CSRF Token in AJAX request

I am sending some data to my server via $AJAX, now i keep getting the Token Mismatch Exception Error . When i use $http i do not get this error so i do not understand what makes $AJAX soo different. I have checked online for solutions but all…
user3718908x100
  • 7,939
  • 15
  • 64
  • 123
0
votes
1 answer

Cake3: Controller TestCase is black-holed

When I use the Security component in Cake3 I always get the error message: "The request has been black-holed" in my controller tests. It works as expected because the request is really black-holed in that case but I need a possibility to test my…
Stefan D.
  • 287
  • 4
  • 9
0
votes
1 answer

Yii2 validateCsrfToken does not work as expected

I have the following create action that has two ways to be accessed, one via AJAX and the other ordinary way: public function actionCreate() { if (Yii::$app->request->isAjax &&…
SaidbakR
  • 13,303
  • 20
  • 101
  • 195
0
votes
2 answers

CSRF token is null on file upload- spring mvc

I am uploading a file. The jsp has the following.
On clicking the submit button, the csrf token is…
Mary
  • 1,505
  • 5
  • 27
  • 44
0
votes
1 answer

POST, PUT and DELETE method requests fail

I'm doing some tests with Laravel 5's RESTful APIs. I created the UserController controller using the command php artisan make:controller UserController, and updated routes.php like so: Route::group(['prefix' => 'api'], function() { …
Hort
  • 57
  • 2
  • 7
0
votes
2 answers

Shownig csrf verification failed in django

When i click submit it is showing csrf verification failed eventhough i used {% csrftoken %} here my view.py: @csrf_protect def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): …
Jerin A Mathews
  • 8,572
  • 4
  • 26
  • 49
0
votes
1 answer

Codeigniter csrf protection error in Javascript form submit

I am using CSRF protection in CodeIgniter 2.2.1 I want to form submit process when I click datatable. Therefore, I create form element in javascript in click event. When form submit process run I get "500 Internal Server Error". Here is my code for…
0
votes
1 answer

Problems with unit testing ZF2 form with CSRF

I'm trying to unit test a ZF2 application. I have a form that changes slightly depending on whether it's for students or employees, and I have two separate factories for producing them. Anyway, I tried testing the student form in the following…
blainarmstrong
  • 1,040
  • 1
  • 13
  • 33
0
votes
0 answers

How to Implement Anti XSRF token in ASP.net 3.5

i have added the Anti Xsrf Token code generated by VS 2012 in .Net web application in frame work 3.5, On Submission of any form in Application i got the error : System.Web.HttpException: Validation of viewstate MAC failed. If this application is…
Sohail Hameed
  • 978
  • 2
  • 9
  • 25
0
votes
2 answers

rails protect_from_forgery raises with exception

I have Rails project which is working on production. But on localhost it raises on every POST request with ActionController::InvalidAuthenticityToken. I know what is it. AuthToken is protection from csrf attacks. I have in my…
Pavel Kalashnikov
  • 2,092
  • 1
  • 19
  • 22
0
votes
1 answer

CSRF Guard: Injects token in POST Request?

I have implemented CSRF Guard into my web application. It's working fine for GET requests (with AJAX and without AJAX) however for POST request token is not getting injected into the request that's why CSRF guard throwing an exception: Token is…
SK.
  • 4,174
  • 4
  • 30
  • 48
0
votes
0 answers

CodIgniter CSRF error when submitting with disabled textfield

I have a search form in navigation created with form_open() and the action from the search controller. Now when I want to submit something and disable the form for visualize a processing operation site CodeIgniter shows: An Error Was Encountered The…
Mike
  • 161
  • 1
  • 12
0
votes
0 answers

CodeIgniter: action not allowed on form submit in Firefox when csrf=true

I am using exact code as it is from here: https://ellislab.com/codeigniter/user-guide/libraries/form_validation.html It all works great when csrf_protection in config file is set on false. But when I set it on true, and submit a form, I get an…
Uroš Podkrižnik
  • 8,607
  • 5
  • 21
  • 31