TUCoPS :: Web :: Apps :: b06-3741.htm

Remote command execution in planetGallery
Advisory: Remote command execution in planetGallery
Advisory: Remote command execution in planetGallery



--nextPart1525202.J3iXeuLQbY
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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
=46ixed 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 ''.

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])) {


=46ix
==
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. 

=2D- 
RedTeam Pentesting               Tel.: +49-241-963 1300
Dennewartstr. 25-27              Fax : +49-241-963 1304
52068 Aachen http://www.redteam-pentesting.de 

--nextPart1525202.J3iXeuLQbY
Content-Type: application/pgp-signature

-----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-----

--nextPart1525202.J3iXeuLQbY--



TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2024 AOH