Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何开启xss防御 #472

Closed
itDjango opened this issue Aug 8, 2019 · 35 comments · Fixed by #611
Closed

如何开启xss防御 #472

itDjango opened this issue Aug 8, 2019 · 35 comments · Fixed by #611

Comments

@itDjango
Copy link

itDjango commented Aug 8, 2019

image

@guang19
Copy link

guang19 commented Aug 12, 2019

吓得我

@guang19
Copy link

guang19 commented Aug 12, 2019

得去看看

@itDjango itDjango reopened this Aug 13, 2019
@itDjango
Copy link
Author

得去看看

所以你的项目有这个问题吗? 或者你怎么解决的?

@guang19
Copy link

guang19 commented Aug 13, 2019

我暂时还没又发现耶,可能是因为我对这个不是特别熟悉吧。

@itDjango
Copy link
Author

我暂时还没又发现耶,可能是因为我对这个不是特别熟悉吧。

你在编辑器里面 输入

image

不会弹吗

@guang19
Copy link

guang19 commented Aug 13, 2019

image
tan'le弹了

@guang19
Copy link

guang19 commented Aug 13, 2019

可是我不知道咋整呀

@itDjango
Copy link
Author

可是我不知道咋整呀

这是比较严重的安全问题,如果你项目对安全性要求很高的话!
我也没有找到解决办法,所以问问其他人有没有好的解决方案

@guang19
Copy link

guang19 commented Aug 13, 2019

嗯嗯,感谢

@chenghuan10081
Copy link

555
试试

@qifengwangye
Copy link

@hinesboy 大哥,这个怎么解决啊

@pengqiangsheng
Copy link

这个用转义
export const unHtml = (str) => {
return str ? str.replace(/[<">']/g, (a) => {
return {
'<': '<',
'"': '"',
'>': '>',
"'": '''
}[a]
}) : ''
}
-------------例子-----------------
const str = "

"
newStr = unHtml(str)
console.log(newStr)
// <p></p>

@iamKyun
Copy link

iamKyun commented Nov 22, 2019

刚npm安装完这插件就提示有安全漏洞了,貌似全部版本都有影响,只能自己先解决了

@PuZhiweizuishuai
Copy link

前端不太熟,不知道怎么办,但我在写后端时我是直接用spring的HtmlUtils做转义的。

@itDjango
Copy link
Author

itDjango commented Dec 4, 2019

这个用转义
export const unHtml =(str)=> {
return str?str.replace(/ [<“>'] / g,(a)=> {
return {
'<':'<',
'”':'“',
'>':'>',
”'“: '''
} [a]
}):''
}
-------------例子-----------------
const str =“


newStr = unHtml(str)
console.log(newStr)
//

</ p>

你这个方法可以解决他一边输入一边预览时xss吗? 俗称XSS自己。

@itDjango
Copy link
Author

itDjango commented Dec 4, 2019

前端不太熟,不知道怎么办,但我在写初步时我是直接用spring的HtmlUtils做转义的。

这个问题后台转义没用的,因为他是在输入的时候即时XSS,在输入完成后前端把数据传给后台时前端可以进行转义,后台也可以转义。
但是就是他在一边输入一边预览时,不知道怎么禁止XSS。

@itDjango
Copy link
Author

itDjango commented Dec 4, 2019

反正我后来是放了了这个编辑器,换了别的。因为我们对安全要求很高,XSS自己也不行。

@WRCoding
Copy link

反正我后来是放了了这个编辑器,换了别的。因为我们对安全要求很高,XSS自己也不行。

大哥,最后你换成了那个编辑器,能推荐下吗

@NateScarlet
Copy link

Duplicate of #285

我暂时是选择的禁用 html
不过看 #368 好像禁用了还是有问题 不知道什么情况

@jonathanpmartins
Copy link

jonathanpmartins commented Apr 4, 2020

I just intalled this editor, soon after...

  • When I run "npm audit" i get this message:

Screenshot from 2020-04-03 20-54-13

Visiting the npm advisory website I get this:
Screenshot from 2020-04-03 20-57-35

Any updates? This is bad security practice...

@itDjango
Copy link
Author

itDjango commented Apr 9, 2020

反正我后来是放了了这个编辑器,换了别的。因为我们对安全要求很高,XSS自己也不行。

大哥,最后你换成了那个编辑器,能推荐下吗

https://www.npmjs.com/package/wangeditor

@itDjango
Copy link
Author

itDjango commented Apr 9, 2020

I just intalled this editor, soon after...

  • When I run "npm audit" i get this message:

Screenshot from 2020-04-03 20-54-13

Visiting the npm advisory website I get this:
Screenshot from 2020-04-03 20-57-35

Any updates? This is bad security practice...

So I gave up and recommend you my new one
https://www.npmjs.com/package/wangeditor

@maltegrosse
Copy link

any updates?

High Cross-Site Scripting

Package mavon-editor

Patched in No patch available

Dependency of mavon-editor

Path mavon-editor

More info https://npmjs.com/advisories/1169

@Kylelkh
Copy link

Kylelkh commented Sep 22, 2020

可以考虑用xss插件进行转义

@giladnavot
Copy link

Any news regarding this variability?

@pnutmath
Copy link

pnutmath commented Nov 5, 2020

<img onerror="alert(1)" src="a"> I tried pasting this in mavon-editor, seems its not accepting it. Not even allow to type it.

I think, this issue has been resolved in version 2.8.2

https://snyk.io/vuln/SNYK-JS-MAVONEDITOR-459108

check #548

@jonathanpmartins
Copy link

would be nice to have NPM stop showing this issue!

@pnutmath
Copy link

Already mailed to npm security advisories. @jonathanpmartins you can mail them again

@ygj6
Copy link
Collaborator

ygj6 commented Dec 5, 2020

This issue has been fixed, see Snyk Report
To eliminate the npm audit warning, close this issue.

If you have any questions, you can comment.

@ygj6 ygj6 closed this as completed Dec 5, 2020
@itDjango
Copy link
Author

This issue has been fixed, see Snyk Report
To eliminate the npm audit warning, close this issue.

If you have any questions, you can comment.

image

好像并没有解决...
Doesn't seem to be resolved...

@ygj6
Copy link
Collaborator

ygj6 commented Jan 12, 2021

xss过滤默认不开启,如需开启,你可以在data中声明xssOptions选项,配置xss规则,并设置props;

例子仅供参考:

<template>
  <div id="editor">
    <mavon-editor v-model="aaa" style="height: 100%" :xssOptions="xssOptions"></mavon-editor>
  </div>
</template>
<script>
module.exports = {
  name: "editor",
  data() {
    return {
      aaa:"",
      xssOptions: {
        whiteList: {
          img: ["src", "alt", "width", "height"],
        },
        stripIgnoreTagBody: true
      }
    };
  },
  computed: {},
  methods: {}
};
</script>
<style>
#editor {
  margin: auto;
  width: 80%;
  height: 580px;
}
</style>

@itDjango
Copy link
Author

xss过滤默认不开启,如需开启,你可以在data中声明xssOptions选项,配置xss规则,并设置props;

例子仅供参考:

<template>
  <div id="editor">
    <mavon-editor v-model="aaa" style="height: 100%" :xssOptions="xssOptions"></mavon-editor>
  </div>
</template>
<script>
module.exports = {
  name: "editor",
  data() {
    return {
      aaa:"",
      xssOptions: {
        whiteList: {
          img: ["src", "alt", "width", "height"],
        },
        stripIgnoreTagBody: true
      }
    };
  },
  computed: {},
  methods: {}
};
</script>
<style>
#editor {
  margin: auto;
  width: 80%;
  height: 580px;
}
</style>

谢谢解答
但是这样在编辑时看到的是转义后的字符,如果我想编辑时和预览时看到的是一样的怎么处理呢?
image

@ygj6
Copy link
Collaborator

ygj6 commented Jan 12, 2021

你可以试试用代码块包起来,应该可以到达这种效果

@itDjango
Copy link
Author

你可以试试用代码块包起来,应该可以到达这种效果

您可能误会我的意思了,我的意思是像github编辑器这样 输入 < > 时,看到的就是< >。
而不是
image

@ygj6
Copy link
Collaborator

ygj6 commented Jan 12, 2021

这看上去是xss开启带来的副作用,后面需要优化,当然我们也欢迎PR。

Repository owner locked as resolved and limited conversation to collaborators Nov 27, 2021
@ygj6 ygj6 changed the title 怎么解决插件中self-xss问题?? 这么严重的问题大家都忽略了吗 如何开启xss防御 Nov 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.