Tell me more ×
IT Security Stack Exchange is a question and answer site for IT security professionals. It's 100% free, no registration required.

What methods are available for testing SQL injection vulnerabilities?

share|improve this question

2 Answers

There are a number of ways of testing an application for vulnerabilities such as SQL Injection. The tests break down into three different methodologies:

Blind Injection:

MySQL example:

http://localhost/test.php?id=sleep(30)

If this SQL statement is interpreted by the database then it will take 30 seconds for the page to load.

Error Messages:

http://localhost/test.php?id='"

If error reporting is enabled and this request is vulnerable to sql injection then the following error will be produced:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"' at line 5

Tautology Based Injection:

http://localhost/test.php?username=' or 1=1 /*&password=1

In this case supplying a Tautology, or a statement that is always true provides a predictable result. In this case the predictable result would be logging in the attacker with the first user in the database, which is commonly the administrator.

There are tools that automate the use of the methods above to detect SQL Injection in a web application. There are free and open source tools such as Wapiti and Skipfish that do this. Sitewatch provides a free service that is a lot better than these open source tools. I can say that because I am a developer for Sitewatch.

share|improve this answer

Its best to not test your site for SQL injection. Its best to just avoid the potential SQL injection. Never forming SQL queries by doing string processing yourself when there's user input. Use bound parameters in all queries (also sanitize all user data if it could be used in any harmful way and put sensible limits on queries). That is the query sql_execute("select user from user_db where id="+input_id) is unsafe (imagine if its input_id = "1 OR 1==1 --"), but stored_procedure = "select user from user_db where id = ? LIMIT 1;", sql_execute_with_param(stored_procedure, input_id); is safe.

Obviously, this is only if you are trying to make your own site safe. If you are trying to find flaws in other applications its another story, and potentially against the FAQ which states this site is not for black hats. But OWASP has a very good article on testing for SQL injection.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.