csrf

How to detect CSRF vulnerabilities [closed]

有些话、适合烂在心里 提交于 2019-12-21 21:15:18
问题 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 5 years ago . given a website, how to detect potential CSRF vulnerabilities? thanks in advance 回答1: This is a CSRF attack:- A page on www.evil.com that the victim is enticed to browse contains the following code:- <form method="post" action="https://www.example.com/executeAction"> <input type=

Angular2 and Django: CSRF Token Headache

£可爱£侵袭症+ 提交于 2019-12-21 20:27:25
问题 The Issue I'm Having I'm making an Ajax POST request from my Angular2 client to my Django (v1.9) backend (both on localhost, different ports). I'm not yet using the Django REST framework, I'm just dumping the JSON in Django without any add-ons. I have been issued a csrf token by the server, and I'm manually sending it back in the HTTP headers (I can see it there when I make the call). However, I still get the error from django: Forbidden (CSRF cookie not set.) I've read a number of other

Django的CSRF防护机制

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 20:07:27
什么是CSRF?    CSRF(Cross-site request forgery), 中文名称:跨站请求伪造,也被称为:one click attack/session riding,缩写为:CSRF/XSRF CSRF攻击过程       从上图可以看出,要完成一次CSRF攻击,受害者必须依次完成两个步骤:     1、登陆受信任的网站A,并在本地客户端(浏览器)产生Cookie;     2、在不退出A的情况下(准确的说是在访问A网站产生的Cookie不过期的情况下),访问危险网站B; Django 的CSRF防御机制   注:django框架只对来自客户端的post请求进行CSRF防御,get请求django默认是合法的请求   django 在第一次响应来自某个客户端的请求时,会在服务器端随机产生一个token,把这个token放在cookie里,然后每次   post请求都会携带这个token,这样就能避免CSRF攻击。 具体的实现方法   django通过中间件 django.middleware.csrf.CsrfViewMiddleware 来防止跨站请求伪造,而对于django中设置防止 跨站请求伪造功能分为全局设置和局部设置 全局:   中间件 django.middleware.csrf.CsrfViewMiddleware   注

Correctly set headers for Laravel 5 CSRF Token

牧云@^-^@ 提交于 2019-12-21 19:20:12
问题 Alright, been searching this one for hours and just can't find the start of a solution. I am using an angularJS frontend with a laravel backend. Restangular is my communcation service. My POST are fine, because I can include the _token in the data and it will work. But for Restangular to call a destroy function it looks like... Restangular.all('auth/logout').remove(); //maps to AuthController@Destroy All fine, but then you will get a TOKENMISMATCH Exception, which is a good security messure

spring security 3.2.0 csrf token not working in freemarker template

假如想象 提交于 2019-12-21 18:34:46
问题 After uprading to Spring Security 3.2.0 and configuring the xml, the _csrf token is not working. Fundamentals: Spring 4.0.1 Spring Security 3.2.0. Freemarker Template Language Step 1 - the spring security xml configuration: <!-- enable csrf protection via csrf-element --> <sec:http> <!-- --> <sec:csrf token-repository-ref="csrfTokenRepository" /> </sec:http> <!-- rewrite headerName --> <bean id="csrfTokenRepository" class="org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository">

CSRF protection of GET links

故事扮演 提交于 2019-12-21 18:05:15
问题 I need to add CSRF protection to a web application. Problem is in the fact that the app relies heavily on links (GET requests that is) to make changes in the database. Links are generated using a class, so I could easily add an extra parameter for CSRF token to each link. However, I understand that CSRF token in a GET request might not be a good enough protection. Note that app is only available over HTTPS, so GET params can not be exposed/stolen during client/server communication (but

Is it safe to bypass CSRF protection for XHR? (Rails)

假如想象 提交于 2019-12-21 17:05:36
问题 A component of our webapp is (more-or-less) an SPA. i.e. it runs using javascript, and doesn't generate any page views or refreshes. This can cause CSRF tokens to go stale. Particularly for mobile phone users, who might switch the browser off and open it a few days/weeks later. This SPA occasionally needs to POST updates to the server. We see some javascript POST requests that generate a 422 error, with a warning about CSRF protection. I'm pretty sure that the CSRF token is present, but is

大白话理解网络攻击(XSS、CSRF)

落爺英雄遲暮 提交于 2019-12-21 14:49:13
本文主要介绍了 XSS 和 CSRF 的攻击原理和防御措施及两者区别。接下来我们来了解下。 XSS 一、XSS 原理 Xss(cross-site scripting) 攻击: 通过向某网站写入 js 脚本或插入恶意 html标签来实现攻击 。 比如:攻击者在论坛中放一个 看似安全的链接,骗取用户点击后,窃取 cookie 中的用户私密信息; 或者攻击者在论坛中加一个恶意表单, 当用户提交表单的时候,却把信息传送到攻击者的服务器中,而不是用户原本以为的信任站点。 二、XSS攻击的类型 分为存储性(持久型)、反射型(非持久型)、基于DOM 1、存储性(持久型) 用户输入的带有恶意脚本的数据存储在 服务器端 。当浏览器请求数据时,服务器返回脚本并执行。 常见的场景: 攻击者在社区或论坛上写下一篇包含恶意 Js代码的文章或评论,文章或评论发表后,所有访问该文章或评论的用户,都会在他们的浏览器中执行这段恶意的 JavaScript 代码。 2、反射型(非持久型) 把用户输入的数据"反射"给 浏览器 。通常是,用户点击链接或提交表单时,攻击者向用户访问的网站注入恶意脚本。 常见的场景: 在正常页面上添加一个恶意链接。恶意链接的地址指向localhost:8080。然后攻击者有一个node服务来处理对localhost:8080的请求: 当用户点击恶意链接时

前端安全之XSS和csrf攻击

一笑奈何 提交于 2019-12-21 14:48:49
1.Csrf攻击概念: csrf攻击( Cross-site request forgery ): 跨站请求伪造 ; 2.Csrf攻击原理: 用户是网站A的注册用户,且登录进去,于是网站A就给用户下发cookie。 从上图可以看出,要完成一次CSRF攻击,受害者必须满足两个必要的条件: (1)登录受信任网站A,并在本地生成Cookie。(如果用户没有登录网站A,那么网站B在诱导的时候,请求网站A的api接口时,会提示你登录) (2)在不登出A的情况下,访问危险网站B(其实是利用了网站A的漏洞)。 我们在讲CSRF时,一定要把上面的两点说清楚。 温馨提示一下,cookie保证了用户可以处于登录状态,但网站B其实拿不到 cookie。 举个例子,前端事假你,微博网站有个api接口有漏洞,导致很多用户的粉丝暴增。 3.Csrf如何防御 方法一、Token 验证:(用的最多) (1)服务器发送给客户端一个token; (2)客户端提交的表单中带着这个token。 (3)如果这个 token 不合法,那么服务器拒绝这个请求。 方法二:隐藏令牌: 把 token 隐藏在 http 的 head头中。 方法二和方法一有点像,本质上没有太大区别,只是使用方式上有区别。 方法三、Referer 验证: Referer 指的是页面请求来源。意思是,只接受本站的请求,服务器才做响应;如果不是,就拦截。

CSRF 攻击介绍

邮差的信 提交于 2019-12-21 14:32:24
CSRF是什么?   CSRF(Cross-site request forgery),中文名称:跨站请求伪造,也被称为:one click attack/session riding,缩写为:CSRF/XSRF。CSRF(Cross Site Request Forgery, 跨站域请求伪造)是一种网络的攻击方式,它在 2007 年曾被列为互联网 20 大安全隐患之一。其他安全隐患,比如 SQL 脚本注入,跨站域脚本攻击等在近年来已经逐渐为众人熟知,很多网站也都针对他们进行了防御。然而,对于大多数人来说,CSRF 却依然是一个陌生的概念。即便是大名鼎鼎的 Gmail, 在 2007 年底也存在着 CSRF 漏洞,从而被黑客攻击而使 Gmail 的用户造成巨大的损失。 CSRF可以做什么?   你这可以这么理解CSRF攻击:攻击者盗用了你的身份,以你的名义发送恶意请求。CSRF能够做的事情包括:以你名义发送邮件,发消息,盗取你的账号,甚至于购买商品,虚拟货币转账......造成的问题包括:个人隐私泄露以及财产安全。 CSRF攻击原理 从上图可以看出,要完成一次CSRF攻击,受害者必须依次完成两个步骤:   1.登录受信任网站A,并在本地生成Cookie。   2.在不登出A的情况下,访问危险网站B。   看到这里,你也许会说:“如果我不满足以上两个条件中的一个