csrf

Rails 3 protect_from_forgery not working correctly?

﹥>﹥吖頭↗ 提交于 2019-12-03 16:05:01
I am using Rails 3.0.2 which has protect_from_forgery by default in application_controller.rb. I wanted to trigger an InvalidAuthenticityToken . To do this I have added this javascript to my page: $('input[name=authenticity_token]').val('aaa') Checking the DOM with Firebug I see the authenticity_token hidden field is correctly updated. If I submit the form and check the log from the server I see the relative parameter is correctly set to 'aaa'. I would expect to get a InvalidAuthenticityToken while the request is processed as it was correct! How is this possible? The documentation for the

One token vs. multiple tokens to prevent CSRF attacks

我的未来我决定 提交于 2019-12-03 15:05:22
I'm using Codeigniter and I want to prevent CSRF attacks attempts that may happen. And to achieve this I add a hidden input tag with a random token to each form I want to protect, and in the same time I keep this token in a session to compare against when begin handling this form data. // set a token to prevent CSRF attacks $csrf_token = md5(uniqid(rand(), true)); $this->session->set_userdata("csrf_token", $csrf_token); And the form will look like this: <form action="path/to/handler/page" method="post"> <input type="text" name="title"> <input type="text" name="date"> <textarea name="content"><

How specifically does Laravel build and check a CSRF token?

筅森魡賤 提交于 2019-12-03 15:03:51
问题 I'm using Laravel's CSRF protection on my public site. However since Laravel uses a session to maintain this, I'm worried that a user might walk away from their computer and return to a page they have previously left open, only to find ajax requests don't work. The ajax requests don't work because the session has timed out (and the token no longer validates?). If these users were "logged in" users, then I could simply redirect them back to the login page. Since they are public users, then the

How to convert a Django HttpResponse to a Django render call

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 14:51:36
I have the following code def ajax_login_request(request): try: request.POST[u'login'] dictionary = request.POST except: dictionary = request.GET user = authenticate(username = dictionary[u'login'], password = dictionary[u'password']) if user and user.is_active: login(request, user) result = True else: result = False response = HttpResponse(json.dumps(result), mimetype = u'application/json') return response which is being called via ajax. I'm a noob and this is from an example in a book. Unfortunately the version of Django I'm using throws a CSRF error on this. I've done the other CSRF bits,

Ruby on Rails Devise Oauth-facebook OmniAuth::Strategies::OAuth2::CallbackError

女生的网名这么多〃 提交于 2019-12-03 14:49:57
Im implementing oauth login with facebook and devise and When returning from accepting the app (the popup) i get the following error: Could not authenticate you from Facebook because "Csrf detected". this is the log: Started GET "/users/auth/facebook/callback" for 127.0.0.1 at 2014-01-23 23:59:58 +0100 ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations" (facebook) Callback phase initiated. (facebook) Authentication failure! csrf_detected: OmniAuth::Strategies::OAuth2::CallbackError, csrf_detected | CSRF detected My user model class User <

Why does Express/Connect generate new CSRF token on each request?

非 Y 不嫁゛ 提交于 2019-12-03 14:26:31
As far as I understand there are two approaches in protecting from CSRF attacks: 1) token per session , and 2) token per request 1) In the first case CSRF token is being generated only once when the user's session is initialized. So there is only one valid token for the user at once. 2) In the second case new CSRF token is being generated on each request and after that an old one becomes invalid. It makes harder to exploit the vunerability because even if attacker steals a token (via XSS) it expires when the user goes to the next page . But on the other hand this approach makes webapp less

Playframework with CSRF : “CSRF token not found in session”?

五迷三道 提交于 2019-12-03 14:14:16
I'm making a simple authentication system using Playframework with their built-in CSRF filter and Security.Authenticator system, but I'm facing a problem : When the user fill his login/password and submit enter, I have the following error : CSRF token not found in session I checked my form and the CSRF token is really present and correctly placed (inside the tag) Here is my routes : GET /login controllers.Authentication.login POST /login controllers.Authentication.authenticate And my Authentication.java class : @play.filters.csrf.AddCSRFToken public static Result login() { if (Session

Node.js use csurf conditionally with express 4

时光毁灭记忆、已成空白 提交于 2019-12-03 14:11:06
I try to use csurf on just a few routes in my express app. that's the approach: var express = require('express'); var session = require('express-session'); var csrf = require('csurf'); // some more stuff var csrfExclusion = ['/myApi','/unsecure']; var app = express(); var conditionalCSRF = function (req, res, next) { if (csrfExclusion.indexOf(req.path) !== -1){ next(); } else{ csrf(); } }); app.use(conditionalCSRF); even tried: var conditionalCSRF = function (req, res, next) { if (csrfExclusion.indexOf(req.path) !== -1){ next(); } else{ csrf(req, res, next); next(); } }); and var

MVC 2 AntiForgeryToken - Why symmetric encryption + IPrinciple?

怎甘沉沦 提交于 2019-12-03 13:03:14
We recently updated our solution to MVC 2, and this has updated the way that the AntiForgeryToken works. Unfortunately this does not fit with our AJAX framework any more. The problem is that MVC 2 now uses symmetric encryption to encode some properties about the user, including the user's Name property (from IPrincipal ). We are able to securely register a new user using AJAX, after which subsequent AJAX calls will be invalid as the anti forgery token will change when the user has been granted a new principal. There are also other cases when this may happen, such as a user updating their name

CSRF and RESTful API (symfony2, php)

放肆的年华 提交于 2019-12-03 13:01:05
问题 I'm developing RESTful API using php/symfony2. Symfony2 comes with CSRF protection out of the box and it works fine when using normal form data (it passes CSRF token to the form and when posted back it expects the same token which is embeded in the form). Nonetheless this solution is not fit for purpose if you develop RESTful API, where my communication between backend<->frontend is purely JSON based. Because of that I disabled CSRF. I'm aware not having CSRF token is not safe, so I'm