当不需要使用AntiForgeryToken的/需要的? [英] When the use of a AntiForgeryToken is not required /needed?

查看:245
本文介绍了当不需要使用AntiForgeryToken的/需要的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UPD:同样的问题问及<一个href=\"http://security.stackexchange.com/questions/2120/when-the-use-of-a-antiforgerytoken-is-not-required-needed\">security.stackexchange.com而我得到的答案是不同的。请按照那里,得到正确的答案!

UPD: Same question asked on security.stackexchange.com and the answer I got is different. Please follow there, to get the correct answer!

我每天跑一个相当大的网站成千上万的访问,以及一个相当大的用户群。

I'm running a rather large site with thousands of visits every day, and a rather large userbase.

自从我开始迁移到MVC 3,我已经把AntiForgeryToken在一些形式,即修改受保护的数据等。

Since I started migrating to MVC 3, I've been putting the AntiForgeryToken in a number of forms, that modify protected data etc.

一些其他形式,如登录/注册也使用了AntiForgeryToken了,但我已经变成半信半疑他们首先需要在那里,一对夫妇的原因...

Some other forms, like the login / registration also use the AntiForgeryToken now, but I'm becoming dubious about their need there in the first place, for a couple reasons...


  1. 登录表单需要海报知道正确的凭据。我真的不能想到的任何方式CSRF攻击会在这里受益。特别是,如果我检查该请求来自同一个主机来(检查网址标头)

  2. 的AntiForgeryToken令牌生成不同的值,每次页面加载时..如果我有两个选项卡的登录页面打开,然后尝试张贴,第一个将成功加载。第二个将失败,AntiForgeryTokenException(第一次加载这两个网页,然后尝试张贴)。随着越来越多的安全页面 - 这显然是一个必要之恶,与登录页面 - 似乎矫枉过正,并自找麻烦:•

有可能的其它原因会一次使用/不使用的令牌在其形式..我是正确的假设,在每个交形式使用令牌是坏/矫枉过正,如果是的话 - 将受益是什么样的形式从中,哪些绝对不会受益?

There are possibly other reasons why would one use/not use the token in their forms.. Am I correct in assuming that using the token in every post form is bad / overkill, and if so - what kind of forms would benefit from it, and which ones would definitely NOT benefit?

推荐答案

防伪造令牌是在用户还没通过身份验证,如登录和注册形式网站的公共部位没用。方式CSRF攻击的工作原理是这样的:

Anti forgery tokens are useless in public parts of the site where users are not yet authenticated such as login and register forms. The way CSRF attack works is the following:


  1. 恶意用户将他的网站上HTML表单它类似于您的网站。这种形式可能包含隐藏字段为好。

  2. 他的技巧你的网站用户访问了恶意URL中的一个。

  3. 用户认为自己是在您的网站,填写表格并提交你的网站。

  4. 如果用户已经在您的网站进行身份验证表单提交成功,毫无戒心的用户已删除他的帐户(或任何你能想象)。

所以,你可以在你的网站上包含的行动验证部分可能以某种方式修改用户状态下使用反伪造令牌。

So you could use anti forgery tokens on authenticated parts of your site containing actions that could modify somehow the user state.

注:检查Referer头用于鉴定的请求从您的网站是不安全来了。任何人都可以伪造一个请求,并欺骗这个头。

Remark: checking the Referer header for identifying that a request came from your site is not secure. Anyone can forge a request and spoof this header.

这篇关于当不需要使用AntiForgeryToken的/需要的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆