PlanetGallery 'gallery_admin.php'任意文件上传漏洞

QQ空间 新浪微博 微信 QQ facebook twitter
漏洞ID 1194040 漏洞类型 输入验证
发布时间 2006-08-15 更新时间 2006-09-06
CVE编号 CVE-2006-3676 CNNVD-ID CNNVD-200607-383
漏洞平台 N/A CVSS评分 5.1
|漏洞来源
https://www.securityfocus.com/bid/19537
https://cxsecurity.com/issue/WLB-2006070105
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200607-383
|漏洞详情
PlanetGallery是一个商业PHP脚本,用于发布图库、显示图片描述等。PlanetGallery在匹配上传文件的名字时存在漏洞,远程攻击者可能利用此漏洞上传可执行的脚本文件从而在服务器上执行任意命令。PlanetGallery的admin/gallery_admin.php文件中存在错误的正则表达式:193$allow_file_types='gif|jpg|jpeg|png|bmp';[...]197if(preg_match('#\.'.$allow_file_types.'?#i',$_FILES['grafik']['name'][$i])){[...]每个$_FILES['grafik']['name'][$i]变量都包含有上传文件的文件名。仅带有$allow_file_types中所提供的文件名扩展的图形是允许的,但正则表达式还匹配了类似于example.png.php的文件,Webserver将这类文件解释为PHP脚本。这就允许攻击者上传并执行任意PHP脚本。
|漏洞EXP
Advisory: Remote command execution in planetGallery

An admin of planetGallery is allowed to create new galleries and upload
images. Because of a vulnerable regular expression, he may also upload
PHP scripts and thereby execute arbitrary commands with the privileges
of PHP.

Details
=======

Product: planetGallery
Affected Versions: <= 22.05.2006
Fixed Versions: 14.07.2006
Vulnerability Type: Remote command execution
Security-Risk: low
Vendor-URL: http://www.planetc.de
Vendor-Status: informed, fixed version released
Advisory-URL: http://www.redteam-pentesting.de/advisories/rt-sa-2006-006.txt
Advisory-Status: public
CVE: CVE-2006-3676
CVE-URL: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-3676

Introduction
============

PlanetGallery is a commercial PHP script which is used to publish image
galleries, show image descriptions and send picture postcards generated
from the galleries.

More Details
============

The faulty regular expression is in admin/gallery_admin.php:

193   $allow_file_types = 'gif|jpg|jpeg|png|bmp';
[...]
197   if (preg_match('#.'.$allow_file_types.'?#i',
          $_FILES['grafik']['name'][$i])) {
[...]

Each variable $_FILES['grafik']['name'][$i] contains the filename of an
uploaded file. Only images with filename extensions supplied in
$allow_file_types are allowed, but the regular expression also matches
files like 'example.png.php'. Webservers interprete this as a PHP script.

Proof of Concept
================

Create a gallery and upload a PHP script named 'evil.png.php'
containing '<?php phpinfo(); ?>'.

Now, access

http://example.com/planetGalleryPath/images/1/evil.png.php

You should see the phpinfo page.

Workaround
==========

Change line 193 of admin/admin_gallery.php to:

$allow_file_types = '(gif|jpg|jpeg|png|bmp)';

And line 197 to:

if (preg_match('#.'.$allow_file_types.'$#i',
          $_FILES['grafik']['name'][$i])) {

Fix
===

Update to the newest version 14.07.2006.

Security Risk
=============

The attacker has to be admin of planetGallery to exploit this
vulnerability. If your admin directory is protected by a .htaccess file
(as the author strictly recommends), the risk is considered low,
otherwise everybody can impersonate the admin and exploit this
vulnerability.  PlanetGallery is not a multiuser gallery CMS, so the
admin of planetGallery is probably the maintainer of the website who
will have access to the system anyway. RedTeam therefore rates the risk
of this vulnerability as low.

History
=======

2006-07-13 Discovery of vulnerability
2006-07-13 Vendor is informed
2006-07-14 Vendor releases fixed version
2006-07-20 Advisory is released

References
==========

[1] http://www.planetc.de/download/planetgallery/planetgallery.html

RedTeam
=======

RedTeam Pentesting is offering individual penetration tests, short
pentests, performed by a team of specialised IT-security experts.
Hereby, security weaknesses in company networks are uncovered and can be
fixed immediately.

As there are only few experts in this field, RedTeam wants to share its
knowledge and enhance the public knowledge with research in security
related areas. The results are made available as public security
advisories.

More information about RedTeam can be found at
http://www.redteam-pentesting.de.

-- 
RedTeam Pentesting               Tel.: +49-241-963 1300
Dennewartstr. 25-27              Fax : +49-241-963 1304
52068 Aachen           http://www.redteam-pentesting.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)

iQEVAwUARL9TrNG/HXWsgFSuAQLxVAgAghmx82XVNtBWqyopWaKziTDIiM913Q/o
ywIp6OGo8/cWcUU60qTxmk3+di57rGw0XHQAlxbsQRZbb4ODVGT1EAQl8SNeZQq4
OgjXwiiES1ptJ/CTtwIK4nr+snIBhZ2me3PvffpTNOaRCw4y33a8vxTGxJZrt5e9
hByxUlXSycNvnDNNa5L09+4mdH4VqEjz2ad2c6zxfd0DqEUwLo1PF3N/fJc5HAzQ
QEi/o8TXQN7s/VNWvzVlb+QkJ7PbE3vQQj3R2j532mpi70rUW55F9Fibaq+WwlL/
H8FMhFWC40GUXLxNqx/WVD52GuHEmfbDwdY7JnueGUR4enS/Im5a8A==
=Zp/C
-----END PGP SIGNATURE-----
|受影响的产品
WikiWebWeaver WikiWebWeaver 1 beta 2
|参考资料

来源:BID
名称:19091
链接:http://www.securityfocus.com/bid/19091
来源:SECUNIA
名称:21099
链接:http://secunia.com/advisories/21099
来源:XF
名称:planetgallery-galleryadmin-file-upload(27858)
链接:http://xforce.iss.net/xforce/xfdb/27858
来源:BUGTRAQ
名称:20060720Advisory:RemotecommandexecutioninplanetGallery
链接:http://www.securityfocus.com/archive/1/archive/1/440643/100/0/threaded
来源:MISC
链接:http://www.redteam-pentesting.de/advisories/rt-sa-2006-006.txt
来源:OSVDB
名称:27417
链接:http://www.osvdb.org/27417
来源:SREASON
名称:1268
链接:http://securityreason.com/securityalert/1268
来源:FULLDISC
名称:20060720Advisory:RemotecommandexecutioninplanetGallery
链接:http://archives.neohapsis.com/archives/fulldisclosure/2006-07/0434.html