huajian197 发表于 2011-12-9 13:58:53

Hex 发表于 2011-12-8 21:11 static/image/common/back.gif
2.0 版本的我没有试过 XSS,我知道的 1.7.3 是没问题的。
不排除是BUG。

我看了一下核心代码原来是2.0比1.7.3多用了一个过滤的方法,在system\core\Security.php的562行,代码如下
        /*
       * Remove Evil HTML Attributes (like evenhandlers and style)
       *
       * It removes the evil attribute and either:
       *         - Everything up until a space
       *                For example, everything between the pipes:
       *                <a |style=document.write('hello');alert('world');| class=link>
       *         - Everything inside the quotes
       *                For example, everything between the pipes:
       *                <a |style="document.write('hello'); alert('world');"| class="link">
       *
       * @param string $str The string to check
       * @param boolean $is_image TRUE if this is an image
       * @return string The string with the evil attributes removed
       */
        protected function _remove_evil_attributes($str, $is_image)
        {
                // All javascript event handlers (e.g. onload, onclick, onmouseover), style, and xmlns
                $evil_attributes = array('on\w*', 'style', 'xmlns');
                if ($is_image === TRUE)
                {
                        /*
                       * Adobe Photoshop puts XML metadata into JFIF images,
                       * including namespacing, so we have to allow this for images.
                       */
                        unset($evil_attributes);
                }
               
                do {
                        $str = preg_replace(
                                "#<(/?[^><]+?)([^A-Za-z\-])(".implode('|', $evil_attributes).")(\s*=\s*)([\"][^>]*?[\"]|[\'][^>]*?[\']|[^>]*?)([\s><])([><]*)#i",
                                "<$1$6",
                                $str, -1, $count
                        );
                } while ($count);
               
                return $str;
        }

Hex 发表于 2011-12-9 14:09:58

huajian197 发表于 2011-12-9 13:58 static/image/common/back.gif
我看了一下核心代码原来是2.0比1.7.3多用了一个过滤的方法,在system\core\Security.php的562行,代码如 ...

你可以通过扩展安全类来达到关闭这个过滤的效果。

huajian197 发表于 2011-12-9 15:46:47

Hex 发表于 2011-12-9 14:09 static/image/common/back.gif
你可以通过扩展安全类来达到关闭这个过滤的效果。

hex,这个算是BUG吗?能不能反馈给CI总部?

Hex 发表于 2011-12-9 16:10:59

huajian197 发表于 2011-12-9 15:46 static/image/common/back.gif
hex,这个算是BUG吗?能不能反馈给CI总部?

呵呵,谁都可以提交BUG,在git平台上。

不过我觉得既然有这个函数,那就是为了加强安全过滤。
误伤总比被攻击好。

看项目需求吧。

dpuppet 发表于 2011-12-16 20:14:26

过滤的严重了,因为style中用expression可以执行script,所以我感觉你自己override下这个函数,只把expression 过滤了就行了

指尖的殤魂 发表于 2012-5-4 16:07:16

2.1也有
string '<span16px;">文字内容</span>' (length=33)
页: 1 [2]
查看完整版本: CI的XSS过滤功能不好使啊,大家过来看看!