csrf

zblog php添加Token防止CSRF攻击

这一生的挚爱 提交于 2019-12-06 03:45:51
CSRF全称Cross Site Request Forgery,即跨站点请求伪造,通过伪装成受信任用户的请求来利用受信任的网站。如果使用的zblog应用有通过cmd.php处理的链接,或提交数据,应该同时提交一个token参数。另外,您的应用如果有副作用,也务必需要加入CSRF Token。 通过GET方法提交,如果您的目标地址是cmd.php,那么您可以使用以下函数: 1 <?php echo BuildSafeCmdURL('act=TagPst'); ?> 如果不是,那么您也可以直接 1 <?php echo BuildSafeURL('main.php'); ?> 通过POST方法提交,您可以在form表单内加入 1 echo '<input type="hidden" name="csrfToken" value="' . $zbp->GetCSRFToken() . '">'; 如果需要兼容旧版Z-BlogPHP,可以使用 1 <?php if (function_exists('CheckIsRefererValid')) {echo '<input type="hidden" name="csrfToken" value="' . $zbp->GetCSRFToken() . '">';}?> 如果您想在您的应用内集成CSRF Token检测

My jquery AJAX POST requests works without sending an Authenticity Token (Rails)

隐身守侯 提交于 2019-12-06 03:30:13
问题 Is there any provisions in rails that would allow all AJAX POST requests from the site to pass without an authenticity_token? I have a Jquery POST ajax call that calls a controller method, but I did not put any authenticity code in it and yet the call succeeds. My ApplicationController does have 'request_forgery_protection' and I've changed config.action_controller.consider_all_requests_local to false in my environments/development.rb I've also searched my code to ensure that I was not

Is Access-Control-Allow-Origin sufficient in preventing XSRF attacks?

雨燕双飞 提交于 2019-12-06 03:27:51
We're building an app with a Java Spring/Hibernate backend running in JBoss. The frontend is AngularJS. We haven't yet done anything to setup XSRF tokens on the server end. We also don't (not yet anyway) have a requirement to allow other domains access to our web resources. I figured I'd try to see if our site was vulnerable to an XSRF attack so I set up a malicious webapp to post to one of our real app's urls using Angular's $http.post(). I logged in to the real app, then I tried posting from the malicious app. In the browser I got a 401 response and saw the error: XMLHttpRequest cannot load

Is CSRF possible without Cookies?

最后都变了- 提交于 2019-12-06 03:21:10
问题 I have been investigating this for some time, but I haven't found anything to satisfy my curiosity. Is it possible, as a user, to be the victim of a CSRF attack if cookies are disabled. Obviously CSRF depends on the users browser to send the user's credentials with the forged request to the legitimate server. Besides IP addresses, browsers don't automatically send in any other session values do they? In that case, as long as a user can login with cookies disabled, they would be safe from CSRF

Is Firebase Auth's local (persisted auth state) secure and safe from XSS and CSRF for browsers?

别等时光非礼了梦想. 提交于 2019-12-06 00:59:51
I am using Firebase Auth for a web app that involves financial transactions. Thus, security is the most important thing for my app. According to this doc , Firebase can persist its token across multiple sessions by storing it somewhere. It does not mention how safe it is from XSS. Of course, I can just assume it's safe because it's Google, but I want to know more about it. We've all read articles noting how localStorage is unsafe for storing auth, and cookie + csrf token + jwt + httpOnly is more secure way to handle auth for browsers. How does Firebase store its token? Does it use localStorage

Django RestFramework学习笔记

狂风中的少年 提交于 2019-12-06 00:23:59
文章目录 @[toc] 安装 使用细节 修改`settings.py` 在app中创建`serializers.py`文件——序列化文件 在`views.py`中创建类 在`urls.py`中注册路由 请求 http请求方式 状态码 使用例子 自定义数据返回结构 解决跨域请求问题 方法1 修改settings配置, 避开csrf验证 方法2 使用csrf_exempt装饰器对特定view进行屏蔽 方法3 重写SessionAuthorization中的enforce_csrf filter筛选 分页 参考 安装 pip install djangorestframework 使用细节 修改 settings.py INSTALLED_APPS中加入’rest_framework’, 在app中创建 serializers.py 文件——序列化文件 from rest_framework import serializers from .models import MyModel class MyModelSerializer(serializers.ModelSerializer): class Meta: # 关联数据表(前面不是变量名) model = MyModel # 确定需要序列化的字段(返回给用户的具体表中的字段)(前面不是变量名) fields = ['id',

Issue in adding Xsrf-Token in an Angular 6

主宰稳场 提交于 2019-12-06 00:17:03
Posting data from the form submit via API was successful. But after adding X-CSRF-TOKEN to the header and setting withCredentials: true resulted data were not posted to the script named insert.php Error: Failed to load http://localhost/simple_api/insert.php : Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin ' http://localhost:4200 ' is therefore not allowed access. The credentials mode of requests initiated by the

如何防止CSRF攻击?

ぐ巨炮叔叔 提交于 2019-12-06 00:01:18
CSRF攻击 CSRF漏洞的发生 相比XSS,CSRF的名气似乎并不是那么大,很多人都认为CSRF“不那么有破坏性”。真的是这样吗? 接下来有请小明出场~~ 小明的悲惨遭遇 这一天,小明同学百无聊赖地刷着Gmail邮件。大部分都是没营养的通知、验证码、聊天记录之类。但有一封邮件引起了小明的注意: 甩卖比特币,一个只要998!! 聪明的小明当然知道这种肯定是骗子,但还是抱着好奇的态度点了进去(请勿模仿)。果然,这只是一个什么都没有的空白页面,小明失望的关闭了页面。一切似乎什么都没有发生…… 在这平静的外表之下,黑客的攻击已然得手。小明的Gmail中,被偷偷设置了一个过滤规则,这个规则使得所有的邮件都会被自动转发到hacker@hackermail.com。小明还在继续刷着邮件,殊不知他的邮件正在一封封地,如脱缰的野马一般地,持续不断地向着黑客的邮箱转发而去。 不久之后的一天,小明发现自己的域名已经被转让了。懵懂的小明以为是域名到期自己忘了续费,直到有一天,对方开出了 $650 的赎回价码,小明才开始觉得不太对劲。 小明仔细查了下域名的转让,对方是拥有自己的验证码的,而域名的验证码只存在于自己的邮箱里面。小明回想起那天奇怪的链接,打开后重新查看了“空白页”的源码: <form method="POST" action="https://mail.google.com/mail/h

pass csrf token to blueimp fileupload

≡放荡痞女 提交于 2019-12-05 22:42:59
I'm building a SPA (Single Page Application) using AngularJS, and for FileUpload I'm trying to use Blueimp File Upload. Server side is in NodeJS, using csrf so all requests would be sent to the server with csrf token (X-XSRF-TOKEN set by AngularJS). Now when I'm trying to upload the file using Blueimp it fails with "Error: invalid csrf token" as it dint attach the necessary token in the request, now I'm wondering on how to set the token. Please note that I'm already using AngularJS, and I dont have any meta tag set to csrf, but the token is available in the cookies. Thank you!! In case anyone

L5 random TokenMismatchExceptions

ぐ巨炮叔叔 提交于 2019-12-05 21:41:07
I'm getting random TokenMismatchExceptions in Laravel 5. Using the following code in the tokensMatch() function I've been trying to debug this weird issue: Log::debug($request->session()->token(). ', ' . $token); The output is as follows: [2015-03-21 17:04:22] local.DEBUG: XJhAXXQumM0JLX9tFcQn1tQZMI1FtglDFuhi8abT, XJhAXXQumM0JLX9tFcQn1tQZMI1FtglDFuhi8abT [2015-03-21 17:04:34] local.DEBUG: XJhAXXQumM0JLX9tFcQn1tQZMI1FtglDFuhi8abT, XJhAXXQumM0JLX9tFcQn1tQZMI1FtglDFuhi8abT [2015-03-21 17:04:36] local.DEBUG: snE0IERJ1VY0o4qmSMuHb4wH9lhQUf5ZtVObOFnR, XJhAXXQumM0JLX9tFcQn1tQZMI1FtglDFuhi8abT [2015