From: SecuriTeam <support@securiteam.com.>
To: [email protected]
Date: 22 Mar 2005 17:39:17 +0200
Subject: [UNIX] Subdreamer SQL Injection
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20050322164121.30F5D57F8@mail.tyumen.ru.>
X-Virus-Scanned: antivirus-gw at tyumen.ru
The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion
The SecuriTeam alerts list - Free, Accurate, Independent.
Get your security news from a reliable source.
http://www.securiteam.com/mailinglist.html
- - - - - - - - -
Subdreamer SQL Injection
------------------------------------------------------------------------
SUMMARY
"Powered by PHP and MySQL, <> Subdreamer provides the ability to create
dynamic websites while giving full control over every section of the site.
A powerful content management system with an amazing skin engine which
provides users with unique and cool looking skins."
Due to flaws in the way the program filters incoming data the Subdreamer
program can be made to include arbitrary SQL statement into its existing
statement.
DETAILS
Insufficient filtering of user input data can lead to SQL injection
vulnerability, if the magic_quotes_gpc has been set to zero, this is due
to the fact that some global arrays are not driven through addslashes()
function.
Vulnerable code in script includes/core.php:
if(!get_magic_quotes_gpc()) // add slashes if gpc is off
{
$_POST = AddSlashesArray($_POST);
$_GET = AddSlashesArray($_GET);
$_COOKIE = AddSlashesArray($_COOKIE);
--[/script includes/core.php]--
As you can see the script's functions variables are defined as "global",
not from global POST or GET arrays. This can lead to inadequate filtering
if register_global has been set to one.
Vulnerable code in script includes/core.php:
if(function_exists('ini_get'))
{
$globalsoption = ini_get('register_globals');
}
else
{
$globalsoption = get_cfg_var('register_globals');
}
if($globalsoption != 1)
{
@extract($HTTP_SERVER_VARS, EXTR_SKIP);
@extract($HTTP_COOKIE_VARS, EXTR_SKIP);
@extract($HTTP_POST_FILES, EXTR_SKIP);
@extract($HTTP_POST_VARS, EXTR_SKIP);
@extract($HTTP_GET_VARS, EXTR_SKIP);
@extract($HTTP_ENV_VARS, EXTR_SKIP);
@extract($HTTP_SESSION_VARS, EXTR_SKIP);
}
In this case an attacker can cause an SQL injection attack through the
variables that are defined as global in the function.
Example:
If we look into the vulnerable script
plugins/p17_image_gallery/imagegallery.php:
function p17_DisplayImages($sectionid, $start)
{
global $DB;
global $categoryid;
global $p17_imageid;
[...]
if(isset($p17_imageid))
{
$image = $DB->query_first("SELECT * FROM p17_images WHERE imageid =
'$p17_imageid'");
[...]
<td style="padding-top: 20px;" align="center"><img
src="plugins/p17_image_gallery/images/'.$image['filename'].'" /></td>
You can notice that if we use the following URL we can cause an SQL
injection vulnerability.
http://example/index.php?categoryid=3&p17_sectionid=1&p17_imageid=[SQL
attack code]
ADDITIONAL INFORMATION
The information has been provided by <mailto:foster@ghc.ru.> GHC team.
This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: [email protected]
In order to subscribe to the mailing list, simply forward this email to: [email protected]
DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.