【问题标题】:Avoid cross-site scripting (XSS) in vue toasted notification title避免在 vue toasted 通知标题中执行跨站点脚本 (XSS)
【发布时间】:2018-04-09 22:21:22
【问题描述】:

我在注入 js 代码 ex 时使用 vue-toasted"><img src=1 onerror=prompt(document.cookie);> 输入并点击提交。

这样的通知显示: 和带有 cookie 的弹出显示:/。

console.log(response.data.message); 显示:
Created Site ""><img src=1 onerror=prompt(document.cookie);>" successfully!

vue 正在转义 html 但toasted 不是,这里是代码:

handleFormSubmit: function(response) {
        this.showAddSiteModal = false;
        if (response.data.status === 'success')
        {
            console.log(response.data.message);
            this.$toasted.success(response.data.message); //<<< problem here
            this.addSite(response.data.site);
        }
        else
        {
            this.$toasted.error(response.data.message);
        }
    },

【问题讨论】:

    标签: javascript vue.js scripting xss cross-site


    【解决方案1】:

    在php端使用htmlspecialchars()

    【讨论】:

      猜你喜欢
      • 2014-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-27
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      • 2015-08-15
      相关资源
      最近更新 更多