Ethical Hacking

Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package.
Computer Forensics Training at InfoSec Institute

Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors.




Network Security Security-Basics
[Top] [All Lists]

Re: PHP filter function against SQL injections

Subject: Re: PHP filter function against SQL injections
Date: Fri, 09 Feb 2007 15:21:10 -0500
2. union injection ??

A very key testcase.  Union injection requires no special characters if the 
parameters were assumed to be integers.  

You should be using mysql_real_escape_string(), btw.  The documentation 
claims that mysql_real_escape_string() is completely effective; what are 
you willing to bet on that?

That have been at least two vulnerabilities already in this function
- see
 
http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statements.html
 
and
 http://software.newsforge.com/article.pl?sid=06/06/01/213223&tid=78

(One is from January 2006, one from June, so I doubt they are the same hole.)

When you deal in character-set issues on the Internet, you have to
rely on multiple devices and layers all being correct; history shows
that's a risky assumption.

The "industrial strength" to protect against SQL injection is to

a) consider the allowable inputs carefully and filter the input
and
b) use BIND variables (or generally, the prepare and execute methods)

See http://ca3.php.net/mysqli for an overview of the mysqli_stmt class and 
the methods

bind_param - binds variables to a prepared statement
execute - executes a prepared statement
fetch - fetches result from a prepared statement into bound variables
prepare - prepares a SQL query

and others.

Building SQL by concatenation is inherently vulnerable, just don't do it.


--
Henry Troup
htroup@acm.org



<Prev in Thread] Current Thread [Next in Thread>