CKEditor security best practices

瘦欲@ 提交于 2019-12-10 14:55:51

问题


I am using http://ckeditor.com/ in a small PHP/MySQL forum I built. My questions:

  1. Is it safe to save user-created HTML like this in the database and then re-display it in my application? What precautions should I take to keep the users of my forum safe from script injection and the like?

    <p>test</p>
    <span style="font-size: 14px;">test</span>
    
  2. Would it be safer to use BBCode instead of HTML? I tried the ckeditor bbcode plugin but it lacks some basic formatting like text alignment ... Does anyone know how to extend the plugin to add text alignment to it?


回答1:


For your first question, there are two main things you need to do:

  1. Safely save the user content to your database so that you are not vulnerable to a SQL injection attack. See this SO question for how best to handle that => Best way to stop SQL Injection in PHP.

  2. Prevent someone from submitting unsafe HTML to your database that would then be re-displayed to your users and make them vulnerable to an XSS attack. There are plenty of questions that deal with that here on SO. Here's one => XSS Prevention in PHP.



来源:https://stackoverflow.com/questions/7225210/ckeditor-security-best-practices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!