skip to navigation. Skip to the content.
> Advisories > rt-sa-2006-006 vertical divider

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.


Product: planetGallery
Affected Versions: <= 22.05.2006
Fixed Versions: 14.07.2006
Vulnerability Type: Remote command execution
Security-Risk: low
Vendor-Status: informed, fixed version released
Advisory-Status: public
CVE: CVE-2006-3676


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

You should see the phpinfo page.


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


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.


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
2009-05-08 Updated Advisory URL




RedTeam Pentesting offers 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

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

More information about RedTeam can be found at