我是js新手。我正在开发的项目之一依赖于dhtmlHistory.js。据我了解,这个js库用于跟踪历史记录和书签相关功能,主要在IE中。另外,这个库似乎已经死了。
当我运行 Fortify 安全扫描时,发现了一些漏洞,例如:
var initialHash = this.getCurrentLocation();
if (this.isInternetExplorer()) {
document.write("<iframe style='border: 0px; width: 1px; "
+ "height: 1px; position: absolute; bottom: 0px; "
+ "right: 0px; visibility: visible;' "
+ "name='DhtmlHistoryFrame' id='DhtmlHistoryFrame' "
+ "src='blank.html?" + initialHash + "'>"
+ "</iframe>");
// wait 400 milliseconds between history
// updates on IE, versus 200 on Firefox
this.WAIT_TIME = 400;
}
此处,传递给 src 参数的initialHash 值未经过验证。这是实际风险吗?
有没有办法让我知道是否可以摆脱这个库,因为目前几乎所有现代浏览器都能够在没有第三方依赖项的帮助下处理这些功能?
是否有邮件列表可以询问这个问题?
更新:
getCurrentLocation: function() {
var currentLocation = this.removeHash(window.location.hash);
return currentLocation;
},
removeHash: function(hashValue) {
if (hashValue == null || hashValue == undefined)
return null;
else if (hashValue == "")
return "";
else if (hashValue.length == 1 && hashValue.charAt(0) == "#")
return "";
else if (hashValue.length > 1 && hashValue.charAt(0) == "#")
return hashValue.substring(1);
else
return hashValue;
},
最佳答案
是的,这是一个风险。
如果攻击者使用具有如下哈希集的 URL 将用户重定向到此页面:
https://example.com/page.htm#'/>+<img+src="x"+onerror="alert('xss')"+/>
文档写入功能将写入此内容,而不仅仅是 IFrame:
<iframe style='border: 0px; width: 1px; height: 1px;
position: absolute; bottom: 0px; right: 0px; visibility: visible;'
name='DhtmlHistoryFrame' id='DhtmlHistoryFrame'
src='blank.html?'/> <img src="x" onerror="alert('xss')" />'>
</iframe>
繁荣 - 你有 XSS。
关于javascript - 这是跨站脚本: DOM in dhtmlHistory. js吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32859294/