javascript - 这是跨站脚本: DOM in dhtmlHistory. js吗

标签 javascript security internet-explorer

我是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/

相关文章:

javascript - 当允许自定义页眉和页脚时,我们是否应该剥离 JavaScript?

linux - 在 Linux 中通过网页进行一些管理工作的最佳方法(安全性)?

security - 为什么我可以从不属于我的域发送电子邮件?

internet-explorer - Internet Explorer 的兼容性 View 破坏了我的网站设计

javascript - 在 es5 中创建一个 angular 2 服务

javascript - Socket.io console.log 多次

javascript - 分配给变量的匿名函数发生意外错误

java - SecurityManager 堆栈溢出错误

javascript - 为什么 .change 在 IE8 上不起作用

internet-explorer - 试图找出HTTP请求的来源