angular-summernote icon indicating copy to clipboard operation
angular-summernote copied to clipboard

Danger for XSS

Open bobmulder opened this issue 9 years ago • 6 comments

Hi,

This script is weak for XSS-attacks.

Tried to following:

<script>
alert('Hacked: ' + localStorage.getItem('auth-token'));
</script>

Should be fixed on the angular way maybe?

bobmulder avatar Sep 16 '15 18:09 bobmulder

@bobmulder What do you mean? Do you mean enter the script in summernote editor?

outsideris avatar Sep 17 '15 19:09 outsideris

@outsideris

I pressed the code button to see the html code. There I added the code from the first post. The result: When I load a page where I use summernote (using that html), the html is executed. In that case an alert was shown.

However, It could be possible this is an summernote-wide issue, instead angular alone...?

bobmulder avatar Sep 17 '15 20:09 bobmulder

@bobmulder Yes, this is in summernote-side. But, I think it is over summrenote's scope, because summernote is a front-end web editor. You should escape the contents you ennter before you store it database.

If the user enter the code above and change summernote mode to code view, it's not a problem, since the code is entered by the code. It is not XSS-attacks.

outsideris avatar Sep 18 '15 03:09 outsideris

@outsideris I see your point it's the responsibility of your API (of how you want to call it). But, in my opinion Summernote has a part of the responsibility too...

Take a look at this: https://docs.angularjs.org/api/ngSanitize/service/$sanitize. Would be helpfull to implement I guess?

bobmulder avatar Sep 18 '15 07:09 bobmulder

@bobmulder I still don't think so, because summernote is a general purpose editor. Somebody use the summernote for a article while others use it for code editor. We can't escape all of it. If you don't want to use codeview, you can hide it. And I think $sanitize is for display something safety in HTML, not editor.

outsideris avatar Sep 19 '15 16:09 outsideris

I has used this. I wish it can help u: $(document).ready(function (){ $(document).on('keyup', '.note-codable', function(){ if($(this).val().indexOf('<script>') > -1){ $(this).val($(this).val().replace('<script>', '')); } }); })

phamhieu2781 avatar Jan 11 '19 03:01 phamhieu2781