Date: Thu, 02 Jun 2005 09:47:45 +0200
From: "=?ISO-8859-1?Q?Bernhard_M=FCller?=" <bmu@sec-consult.com.>
To: [email protected]Subject: SEC-CONSULT SA20050602-2 :: Exhibit Engine Blind SQL Injection
X-Enigmail-Version: 0.91.0.0
X-Virus-Scanned: antivirus-gw at tyumen.ru
This is a MIME-formatted message. If you see this text it means that your
E-mail software does not support MIME-formatted messages.
--=_lexx-1037-1117698174-0001-2
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
SEC-CONSULT Security Advisory 20050602-2
title: Exhibit Engine Blind SQL Injection
program: Exhibit Engine
vulnerable version: 1.22, 1.54 RC4
homepage: http://photography-on-the.net/ee/http://photography-on-the.net/ee/beta/
found: 2005-06-01
by: sk0L / SEC-CONSULT / www.sec-consult.com
vendor description:
---------------
the Exhibit engine is a PHP/MySQL application for smooth and versatile
online photograph
display. it's especially designed to give detailed technical info on
each photo, with text
descriptions and gear info, but all that technical data is not required.
vulnerabilty overview:
---------------
SQL injection is possible on various POST parameters in the script
list.php. although
there is no way to get any output from UNION statements, there is at
least one possibility
to read arbitrary database entries via blind SQL injection.
proof of concept:
---------------
here's the relevant code section from list.php:
---- code -----
$resultcount = mysql_query(
"
SELECT
ee_photo.ee_photo_id
FROM
[...]
WHERE
ee_photo.ee_photo_for_www = 'yes'
AND $search_row LIKE '$wildcard1$keyword$wildcard2'
AND ...
"
);
if (!$resultcount) {
$queryname = "resultcount";
include("db_error.php");
}
$total = mysql_num_rows($resultcount);
$how_many = count($count_total);
if ($offset>$how_many)
{$offset = $how_many;
}
$fetchlist = mysql_query(
"
SELECT
$q0,$q1,...,$q43
FROM
ee_photo,
[...]
ee_order_to_exhibition
WHERE
ee_photo.ee_photo_for_www = 'yes'
[...]
AND ee_exhibition.ee_exhibition_pass = '$pass'
ORDER
by $sort_row $order
LIMIT
$offset,$perpage
"
);
---- /code ----
we can inject SQL into the variables $search_row, $sort_row, $order and
$perpage without the need to escape any quotes. unfortunately, UNIONs can
be put into $rearch_row only, and as $search_row is used in both queries
with a different number of columns, this will inevitably produce an error.
we can use blind sql injection, though:
* set $offset=1
* put injection string into $search_row, e.g.:
search_row=ee_photo.ee_photo_exif_iso%3D1+AND+1%3D2+UNION+SELECT+user+FROM+mysql.user+WHERE+user+LIKE+0x254125+/*+
* if we get 1 (TRUE), offset will be set to 1, FALSE will set it to 0.
* now we still have to produce an error in the second query by
specifying some insane $order or $sort_row. the last part of the
SQL error message will be echoed by Exhibit, so we get the value of
$offset.
it should be relatively easy to code an exploit for this (sorry but i
don't have
the time atm).
vulnerable versions:
---------------
Exhibit Engine v1.22 is definitely vulnerable. 1.54 RC4 seems to be
vulnerable
too, although exploitation may differ slightly.
it is very likely that the vulnerability exists in most other versions of
Exhibit Engine.
vendor status:
---------------
vendor notified: 2005-06-01
vendor response: immediately
workaround found: 2005-06-02
Pekka Saarinen has published a workaround for all current versions of
Exhibit Engine. It is available at:
http://photography-on-the.net/forum/showthread.php?p=579692
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bernhard Mueller / www.sec-consult.com /
SGT ::: dfa, tke, bfi, mei, flo, walter|bruder :::
~ ___ ___
~ | |=|_.' .'| .'| .'|=|`. .'|
~ `. | .' | .' .' .' | | `. .' |
==== `.|=|`. | |=|.: | | | | | | ======
~ ___ | `.| | |'. `. | | .' | | ___
~ `._|=|___||___| |_| `.|=|.' |___|=|_.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
--=_lexx-1037-1117698174-0001-2
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature
MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIJuzCC
AzgwggKhoAMCAQICAw6SlDANBgkqhk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