Security of RichTextEditor- malicious javascript or html code

Hello,

I have a markup string displaying the contents of the rich text editor on the website and I would like to know some more information about any security features of the rich text editor.

I am worried about someone being able to paste malicious javascript or html code in the rich text editor.

Is there anything built in to mitigate such an attack?


3 Replies 1 reply marked as answer

VJ Vinitha Jeyakumar Syncfusion Team August 12, 2022 01:12 PM UTC

Hi Pavel,

We have Cross-Site Scripting which is a security vulnerability and a client-side injection attack. Attackers inject the malicious code in a web application, usually JavaScript but could also be HTML or CSS. To prevent this aspect, the API EnableHtmlSanitizer is provided and its default value is set to true.

Code snippet:
<SfRichTextEditor EnableHtmlSanitizer="true">
      
</SfRichTextEditor>



Regards,
Vinitha



Marked as answer

PA Pavel November 5, 2022 10:33 PM UTC

If the user inserts special stuff into RichTextEditor....


like


<img src="\bbbb" onerror="alert('hahaha')"/>


Then the JS code still gets executed.


Can you advice proper way on how to achieve "no javascript at all" will be accepted scenario?

Thanks



VJ Vinitha Jeyakumar Syncfusion Team November 7, 2022 02:09 PM UTC

Hi Pavel,


When we set true to the EnableHtmlSanitizer in Rich Text Editor, the JS code didn't get executed and also that event is not added in the DOM element too. we have also used the code you have shared and prepared a sample and video illustration for your reference,



Please check the above sample and let us know about the exact issue you are facing.
If possible, please share us with the issue reproducing runnable sample.

Regards,
Vinitha

Loader.
Up arrow icon