Advisory: Remote command execution in planetGallery

2006-07-24T00:00:00
ID SECURITYVULNS:DOC:13582
Type securityvulns
Reporter Securityvulns
Modified 2006-07-24T00:00:00

Description

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