Home  >  Article  >  Backend Development  >  现在浏览器这么安全,是不是没必要进行csrf防御了?

现在浏览器这么安全,是不是没必要进行csrf防御了?

WBOY
WBOYOriginal
2016-06-06 16:44:411541browse

首先,服务端nginx等需要设置跨域请求以及跨域frame请求是否允许(默认都是不允许的)。
再者,浏览器端对跨域ajax限制非常严格,根本不允许跨域访问cookie。

那么我们web开发时,现在对csrf所做的措施(一般是给form 加个hidden csrf token input),是否是多此一举了,完全没必要?

回复内容:

哈哈哈,当然仍旧需要。

测了下,虽然,nginx配置'X-Frame-Options' to 'SAMEORIGIN'后,同domain下居然不能iframe不同子域名,既然打不开就更别说之后的通过js来获取cookie进而得到session id。

但是一种更简单的攻击仍旧无法避免:

如果你在一个被我做了手脚的wifi环境(局域网)中,我污染了dns,并且做了个恶意站叫做csrf-attack,然后你登陆了某个没有csrf防御的站叫做no-csrf-token, 然后我在csrf-attack里做了个页面,里面有个这样的表单:

action="no-csrf-token/reset-password" method="post"> type="hidden" name="password" value="password123"> type="hidden" name="repassword" value="password123">
浏览器无法阻止crsf攻击。 【现在浏览器这么安全】......

这真的不是钓鱼贴? 所有的东西都在后台可以看到
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn