简体   繁体   English

避免在vue烤的通知标题中使用跨站点脚本(XSS)

[英]Avoid cross-site scripting (XSS) in vue toasted notification title

I use vue-toasted when inject js code ex. 我在注入js代码前使用vue-toasted "><img src=1 onerror=prompt(document.cookie);> in input and click submit. "><img src=1 onerror=prompt(document.cookie);>在输入中输入"><img src=1 onerror=prompt(document.cookie);> ,然后点击提交。

Notification show like that: 通知显示如下: 在此处输入图片说明 and popup show with cookie :/ . 并弹出显示cookie:/。

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

vue is escaping html but toasted is not, here is the code: 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);
        }
    },

在php端使用htmlspecialchars()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM