OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: [KAPDA::#16] - SMF SQL Injection

From: ascii (asciikatamail.com)
Date: Sun Dec 11 2005 - 10:42:22 CST


grudgesecurityfocus.com wrote:
> I'm a developer from over at simplemachines and
> I do not see how this can pose an exploit?

/* tabs are evil */
if (!is_numeric($_REQUEST['start'])) {

  $request = db_query("SELECT COUNT(ID_MEMBER)
   FROM {$db_prefix}members
   WHERE LOWER(SUBSTRING(realName, 1, 1)) < '".
   substr(strtolower($_REQUEST['start']), 0, 1)
   ."' AND is_activated = 1", __FILE__, __LINE__);

  list ($_REQUEST['start']) = mysql_fetch_row($request);
  mysql_free_result($request);
}

me too, this piece of code isn't exploitable

at last you can inject a ' that will issue a
php error (path disclosure, error log filling
but not an usable sql injection)

> The code is entered at this point:
> if (!is_numeric($_REQUEST['start']))

i would prefer ctype_digit or preg_match [09]
cause is_numeric accept also hex, signed and
floats

> substr(strtolower($_REQUEST['start']), 0, 1)
> I simply cannot see how you could possibly
> exploit SQL from this?

it's impossible imho, but don't relay on magic quotes
or this type of stuff, put a beautiful
mysql_real_escape_string on each string passed to the db
and cast integers (int)intval($_GET['id'])

seems KAPDA Researchers researched this 'vuln' too fast : )

ascii - http://www.ush.it