csrf

Why is Safari causing a Rails CSRF exception where Chrome isn't?

只谈情不闲聊 提交于 2019-12-05 09:29:09
I want to create sessions in my Rails 4 application via an AJAX request in an iframe. In the iframe I've included a form for a new session with the attribute remote: true as usual, and included <%= token_tag %> in the form body as well as <%= csrf_meta_tags %> in the head of the layout. Chrome has no problem posting this form and creating a session. Under identical conditions Safari causes a CSRF exception. Why does this happen, and what can I do to stop it? As I understand it, this is not a situation where CSRF is essential, as there is no session to hijack, but I'm still wary of turning it

PHP further security on anti-CSRF token

Deadly 提交于 2019-12-05 09:16:11
问题 I am learning about how to prevent CSRF using anti-CSRF tokens. Essentially, the idea is to:- 1) generate a token eg Md5 or Sha1 then store this value in a session variable:- $token = md5(uniqid(rand(), TRUE)); $_SESSION['token'] = $token; 2) All forms include this token value in a POST hidden field <input type='hidden' name='token' value='$nonce_token' /> Eg what it would look like to user in source code:- <input type='hidden' name='token' value='9ee66e4e63a06ee4b83a3edde4ecd587' /> 3) Once

Getting 403 error when using CSRF filter with tomcat 6.0.32

你离开我真会死。 提交于 2019-12-05 08:50:22
This is my filer config in web.xml <filter> <filter-name>CSRFPreventionFilter</filter-name> <filter-class>org.apache.catalina.filters.CsrfPreventionFilter</filter-class> <init-param> <param-name>entryPoints</param-name> <param-value>/login<param-value> </init-param> </filter> <filter-mapping> <filter-name>CSRFPreventionFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> Am I missing something? Are any code-changes necessary to enable csrf protection in tomcat pd40 Note that a 403 is the CSRFPreventionFilter response if a nonce is not provided and the filter expects

CSRF token missing or incorrect. Django + AngularJS

泄露秘密 提交于 2019-12-05 08:33:48
I'm getting CSRF token missing or incorrect error while doing a POST request to a remote django api from my localhost machine. My settings on AngularJS: .config(['$httpProvider', function($httpProvider){ $httpProvider.defaults.xsrfCookieName = 'csrftoken'; $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; }]); but im still getting the CSRF token missing or incorrect error. I check what headers are being sent and apparently angular is not sending HTTP_X_CSRFTOKEN . But I can see that the cookie csrftoken=something is sent. Does anyone know what is going on? Request Header POST /s/login/

详解Django的CSRF认证

為{幸葍}努か 提交于 2019-12-05 07:44:11
1.csrf原理 csrf要求发送post,put或delete请求的时候,是先以get方式发送请求,服务端响应时会分配一个随机字符串给客户端,客户端第二次发送post,put或delete请求时携带上次分配的随机字符串到服务端进行校验 2.Django中的CSRF中间件 首先,我们知道Django中间件作用于整个项目。 在一个项目中,如果想对全局所有视图函数或视图类起作用时,就可以在中间件中实现,比如想实现用户登录判断,基于用户的权限管理(RBAC)等都可以在Django中间件中来进行操作 Django内置了很多中间件,其中之一就是CSRF中间件 MIDDLEWARE_CLASSES = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware

Questions about CSRF

梦想与她 提交于 2019-12-05 07:08:55
问题 Is it safe to use a signal auth-token in cookie for auth (post and requst only json via ajax)? Why attacker can not get the form token in hidden field? How an attacker do a CSRF attack with a POST request? 回答1: Is it safe to use a single token in a cookie for authentication? Sort of, if that cookie is HTTP-only (which helps protect against XSS) and SSL then there's no way anyone outside your site can read that cookie. However, the user's browser can retain that cookie, and will automatically

Is it ok to use the (cryptographically strong) session cookie as CSRF token?

╄→尐↘猪︶ㄣ 提交于 2019-12-05 06:43:33
Reading OWASP CSRF prevention cheat sheet , one of the methods proposed to prevent these kind of attacks is the synchronizer token pattern. If the session token is cryptographically strong, can it double as the csrf token as described in the following pseudocode? Client: <script> dom.replace(placeholder, getCookie("session-cookie")) </script> <form> <input type="hidden" name="csrf-cookie" value="placeholder-value"/> <input type="text" /> </form> Server: if(request.getParameter("csrf-cookie") != user.getSessionCookie()) print "get out you evil hacker" The cookie is set with javascript on page

GWT & XSRF Protection

你说的曾经没有我的故事 提交于 2019-12-05 05:43:36
I'm looking at possible solutions to protect my GWT app against XSRF. If I understand GWT's solution correctly - it makes available a Servlet which you use to both generate the token on the client-side (when calling your RPC endpoint) and to validate on the server-side (when the call hits your service). Does this solution only cater for RPC calls? Surely we need it to cover all user generated requests to the server? Any other recommended XSRF solutions (I'm also looking at OWASP's CSRFGuard )? I modified the GWT Sample App to be protected against XSRF. This solution is roughly based of the

playframework disable CSRF filter

≡放荡痞女 提交于 2019-12-05 05:13:11
We have a play application written in Scala. We wanted to completely disable CSRF filter based on our requirement. there is no much instruction given on the play document ( https://www.playframework.com/documentation/2.5.x/JavaCsrf ) . Any help will be appreciated. The easiest way to disable the CSRF filter, as far as version 2.6 goes, is to add the following line to application.conf: play.filters.disabled += play.filters.csrf.CSRFFilter See Disabling Default Filters in Play Framework documentation. If you are using compile-time dependency injection, the runtime configuration for filters is

进阶-使用Spring Security3.2搭建LDAP认证授权和Remember-me(2)

浪尽此生 提交于 2019-12-05 04:36:44
接上 进阶-使用Spring Security3.2搭建LDAP认证授权和Remember-me(1) javaconfig 使用javaconfig,只需要生成两个类,就可以完成XML配置下的3个步骤。这两个类非别是: 继承于org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter的一个子类。 继承于org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer的子类。 原理如下: SpringServletContainerInitializer实现了servlet 3中的一个规范接口javax.servlet.ServletContainerInitializer. 一旦实现了这个接口,当web container启动时,就会自动加载SpringServletContainerInitializer. 而SpringServletContainerInitializer会调用 AbstractSecurityWebApplicationInitializer类。以上的步骤完成了相当于SpringSecurityFilterChain的配置。