我目前正在了解有关 CSRF 的更多信息,并且我有一个关于 cookie 的基本问题。来自 Jeff Atwood's article on CSRF :
"When a POST request is sent to the site, the request should only be considered valid if the form value and the cookie value are the same. When an attacker submits a form on behalf of a user, he can only modify the values of the form. An attacker cannot read any data sent from the server or modify cookie values, per the same-origin policy. This means that while an attacker can send any value he wants with the form, he will be unable to modify or read the value stored in the cookie."
如果 cookies 是 a piece of text stored on a users computer ,他们怎么能不修改/读取 cookie 的值?
如果他们知道 cookie 的值并且可以看到隐藏在表单中的伪随机值,那么他们是否就拥有了执行攻击所需的一切?
谢谢
最佳答案
同源策略意味着攻击网站无法读取其他域的 Cookie。请参阅http://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_cookies
我们不是在谈论在用户计算机上拥有 rootkit 或类似内容的攻击者,CSRF 所保护的是恶意服务器,让用户通过 POST 请求向恶意服务器的域提交表单想要攻击。由于恶意服务器无法从目标域读取 cookie,因此它们无法正确填写其发出的 POST 请求的 CSRF 字段。
关于security - 基本 cookie 和 CSRF 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5750657/