csrf

CSRF prevention for AJAX call from extjs to Struts action [closed]

可紊 提交于 2020-01-07 15:46:07
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I need to implement CSRF attack prevention using token in application that uses ajax post requests (ExtJs library) to Struts actions. How can I implement token generation and validation in such case? 回答1: In ExtJS you can use this: Ext.Ajax.setDefaultHeaders({ token: 'xyz' }) This

CSRF漏洞

寵の児 提交于 2020-01-07 08:18:42
CSRF漏洞也叫夸站脚本伪造 XSS和CSRF的区别 从信任的角度来分析的话 XSS:是利用用户对站点的信任 CSRF:利用站点对客户端的信任 - 默认情况下站点是对客户端不信任的站点只会对已经身份验证过的客户端有一定的信任 利用 结合社工在身份认证会话过程中实现供给 修改账号密码、个人信息(email、收货地址) 发送伪造的业务请求(网银、购物、投票) 关注他人社交账号、推送博文 在用户非自愿、不知情的情况下提交请求 下面这样黑客就叫你的用户密码给盗取了 还有好多不如骗访问量和投票量还有广告还有产品推广 比如我们发送一个链接点击这个链接就会给我投票等等等 业务逻辑漏洞 服务器对关键操作缺少确认机制 提交密码修改没有确认机制,还有二次认证,确认机制就是列我们每次登陆一个帐号密码之后都会出现一个验证码这个就是确认机制 自动扫描程序无法发现此漏洞 无法检测的是否是恶意的修改密码,自动扫面程序是检测不出来的应为都是正常提交数据 漏洞利用条件 被害用户已经完成身份认证 新请求的提交不需要重新身份认证或确认机制 攻击者必须了解 Web APP 请求的参数构造 诱使用户触发攻击的指令(社工) 实验开始 下面这个带有CSRF漏洞的服务器 下面输入密码直接就可以确认修改没有如何认证机制 用Burp截断下来 在kali开一个服务器里做一个简单的页面 http://192.168.43.245

CSRFGuard - request token does not match page token & How can generate token per session

情到浓时终转凉″ 提交于 2020-01-07 06:48:20
问题 I am trying to incorporate the CSRFGuard library(< org.owasp csrfguard 3.1.0 >) in order to rectify some CSRF vulnerabilities in an application. However after configuring as specified here I am now getting the below message: Here I would like to explain scenario when I am getting this message - For suppose my application landing page like this And code snippet for this page(HelloWorld.jsp) is <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@

Guzzle add CSRF token

不打扰是莪最后的温柔 提交于 2020-01-07 03:41:22
问题 I am trying to create a product in drupal commerce using guzzle and restful webservices. When i am trying to create a new product i use the following process: 1) Login as a user who has the rights to create a product (succes) 2) Request CSRF token (succes) 3) Create product : Uh oh!: Client error response [status code] 401 [reason phrase] Unauthorized: Access to this operation not granted Now when i am doing this process trough poster (Firfox add-on). I can succesfully create a product, but

Django 模板渲染

六月ゝ 毕业季﹏ 提交于 2020-01-06 20:37:16
模板语言    {{ 变量 }}   {% 逻辑 %} {{ 变量 }} {{ 变量 }}中的点号   用于取出字典/列表等类型数据的值   {{ list.2 }} 获取列表list中索引为2的值   {{ dict.name }} 获取字典中name的值 {{ 变量 }}内置的过滤器    以|分隔    {{ a|safe }} 于django输出前,要求不对字符进行转义。自动转义关闭时自动失效   {{ time|date:'Y-m-d H:i:s' }} 格式化输出时间 年月日时分秒   {{ list|join:',' }} 相当于 ‘,’.join(list)   {{ str|truncatechars:8 }} 显示内容为5个字符与3个点号 共8个字符   {{ str|truncatechars:8 }} 同上 显示单位为单词 按空格辨别   {{ str|length }} str的长度   {{ list|slice:'0-2' }} 切片索引0-2不含2   {{ var|default:'xxx' }} 为var设置默认值为‘xxx’   {{ str|lower }}{{ str|upper }} 输出显示为小/大写   {{ int|filesizeformat }} 转为内存大小单位 类似于2GB 1TB {% 逻辑 %}   for循环 <ul>

csrf token issue with multiple templates

我只是一个虾纸丫 提交于 2020-01-06 13:52:37
问题 I've got a template (index.html. It extends base.html) containing a form with a csrf_token wich works good. I use JS/Ajax to send data to my view. So no problem with that. The issue is that if i copy/paste my form to another template (for example : new.html wich also extends base.html) i get : CSRF token missing or incorrect error. (HTTP 403 error in console) Both templates use same JS function. The forms are exactly the same in both templates. Any suggestion please? Here the form (same in

How to return JSON response for unauthorized AJAX calls instead of login page as AJAX response?

戏子无情 提交于 2020-01-06 01:30:07
问题 I have implemented Spring Security in my application. Whenever someone tries to access any url if authentication is required for these urls user will be redirected to login page. Now, if AJAX call is made for any such url I would like to return JSON response instead of login page's HTML as AJAX response. How can I do that ? 回答1: You have to create json for this i am doing here with .net var url="url"; $.ajax({ type: "get", dataType: "json", data:url, async: true, url: "testCall",//this can be

HTTP(S) request security using random headers

…衆ロ難τιáo~ 提交于 2020-01-05 14:28:24
问题 I understand that CSRF is a major security concern for HTTP(S)-based applications. From the looks of it, most frameworks send the CSRF token as part of the request body. However, in my case that is somewhat inelegant for several reasons; most importantly I don't want to mess with the transport layer which might send POST requests in many different formats, not necessarily all are JSON or x-www-form-urlencoded . As a solution, I was thinking of a much less intrusive alternative; particularly,

Phoenix CSRF token not matching

怎甘沉沦 提交于 2020-01-05 05:26:14
问题 Trying to get ajax working the Phoenix. I get the csrf token by doing the following so i have it: <input type="hidden" id="_csrf_token" name="_csrf_token" value="<%= get_csrf_token() %>"> Then use it like so: $.ajax({ type: "POST", url: "<%= lesson_path @conn, :create %>", beforeSend: function(xhr) { token = $('#_csrf_token').val(); xhr.setRequestHeader('_csrf_token', token ); }, data: data, success: function(data, textStatus, jqXHR) { alert(textStatus); } }); The issue is that the token i

Flask Preventing Form Injection

本秂侑毒 提交于 2020-01-04 05:43:13
问题 How can python / flask block foreign form injections? Consider the following mwe: app.py from flask import Flask, request, render template app = Flask(__name__) @app.route('/', methods=['GET','POST']) def helloworld(): if request.method == 'GET': return render_template('index.html') if request.method == 'POST': print(request.form['info']) ## do something with the info, like write to a database return 'nothing' if __name__ == '__main__': app.run(debug=True) templates/index.html <html> <head>