Codeignight在保存编辑器内容时XSS挖的坑

前台编辑说,后台的ueditor编辑器咋不能居中了,我第一反应是前台的样式过度渲染了编辑内容的元素样式。

前端的反馈是没有,说看源代码里压根就没有设置style

<p xss=removed >...</p>

我觉得是ueditor编辑器的过滤设置,于是调了半天ueditor的配置ueditor.config

,xssFilterRules: false

//input xss过滤
,inputXssFilter: false

//output xss过滤
,outputXssFilter: false

,
allowDivTransToP: false

甚至连ueditor.all也动了

switch (node.tagName) {
    case 'style': // 删除这项
    case 'script':
        ....
}

还是无果,于是把关注点放在ci本身,直接在提交前调试文本内容是否有被过滤。

果然 到控制器内文本内容已经被修改了

$this->input->post('editorValue'); //
从CI内置的方法走默认会被过滤掉,当然我的xss全局配置是已经打开的
$config['csrf_protection'] = TRUE;//application/config/config.php

所以上面的代码要修改成

$this->input->post('editorValue',FALSE)

CI文档上还有如下说明

如果希望返回 POST 所有元素并将它们通过 XSS 过滤器进行过滤, 可以将第一个参数设为 NULL ,第二个参数设为 TRUE

$this->input->post(NULL, TRUE); // returns all POST items with XSS filter
$this->input->post(NULL, FALSE); // returns all POST items without XSS filter

 

posted @ 2018-08-23 11:50  zhujingxiu  阅读(143)  评论(0编辑  收藏  举报