November 13, 2003

URL Hacking

One of the side affects mentioned yesterday with the GET method is that the values are appended to the url. Sometimes malicious individuals attempt to append other information to the url.

www.anticlue.net\portal\index.php?id=7&type=blog;drop sysinfo;

This would attempt to drop the sysinfo table from the db.

In order to prevent hacks such as these. Try validating the values.

For example in CF, use the <cfqueryparam> tag.

Select * from tbl where
type = <cfqueryparam value="#url.type#" type="CF_SQL_VARCHAR">
AND ID = <cfquerypara value="#url.ID# type="CF_SQL_INTEGER">


In PHP, try to search the string for the ; and return only the validated info.

function cleanURL($urlparam)
{
$urlLength = strpos($urlparam, ";") - 1;
$urlparam = substr($urlparam, 0, $urlLength);
$urlparam = EscapeShellCmd($urlparam);
return $urlparam;
}

Posted by Elyse at November 13, 2003 9:39 PM