Tools to Fight SQL Injection

By Larry Seltzer  |  Posted 2008-06-25 Print this article Print

The Microsoft Source Code Analyzer for SQL Injection tool is a static code analysis tool, built on the .NET Framework version 3.0, which analyzes your ASP code for SQL injection vulnerabilities, both first order and second order vulnerabilities.

First order is the type my own sites would be vulnerable to: using user input directly to construct SQL statements. Second order is where those statements are constructed based on data from the database. See Preventing SQL Injections in ASP for more on this distinction. As a programming matter, by the way, the general solution to SQL injection is called parameterized queries, a topic also covered in this article.

A second tool is UrlScan version 3.0 Beta, the latest in a long line of UrlScan versions that have prevented many a common attack. UrlScan is a runtime filtering tool that looks at HTTP requests sent through IIS. It scans for malicious ones and can be set to block whatever you want to block. This can be handy when you read about specific attack patterns being committed.

SQL injections are often performed through HTTP GET commands, in which case UrlScan should be able to detect them (for instance by setting a rule to drop any request that contains the string "INSERT INTO "). Microsoft has a page with UrlScan rules for common security scenarios, including SQL injection, which can help.

Finally, there is a third-party tool, Scrawlr from HP. This tool crawls Web sites, analyzing parameters of pages for SQL injection vulnerabilities. Unlike the Microsoft Source Code Analyzer for SQL Injection tool, it doesn't require source code. Even if you have source code, this provides a different perspective and a useful comparison.

Preventing successful SQL injection attacks has to begin with proper programming techniques, and there's only so much Microsoft can do about that. They have provided the programming systems you need to do the job right. Scrawlr and UrlScan are good tools to have and are worth running, at least for a while, but if they are your main defense you can't feel good about it.

SQL injection is a great example of how security is everyone's job. Ten years ago very few people appreciated that this level of programming could be the target of a massive attack, but systems are so complex these days that every level is suspect. Don't take anything for granted.

Security Center Editor Larry Seltzer has worked in and written about the computer industry since 1983.

For insights on security coverage around the Web, take a look at Security Center Editor Larry Seltzer's blog Cheap Hack

Larry Seltzer has been writing software for and English about computers ever since—,much to his own amazement—,he graduated from the University of Pennsylvania in 1983.

He was one of the authors of NPL and NPL-R, fourth-generation languages for microcomputers by the now-defunct DeskTop Software Corporation. (Larry is sad to find absolutely no hits on any of these +products on Google.) His work at Desktop Software included programming the UCSD p-System, a virtual machine-based operating system with portable binaries that pre-dated Java by more than 10 years.

For several years, he wrote corporate software for Mathematica Policy Research (they're still in business!) and Chase Econometrics (not so lucky) before being forcibly thrown into the consulting market. He bummed around the Philadelphia consulting and contract-programming scenes for a year or two before taking a job at NSTL (National Software Testing Labs) developing product tests and managing contract testing for the computer industry, governments and publication.

In 1991 Larry moved to Massachusetts to become Technical Director of PC Week Labs (now eWeek Labs). He moved within Ziff Davis to New York in 1994 to run testing at Windows Sources. In 1995, he became Technical Director for Internet product testing at PC Magazine and stayed there till 1998.

Since then, he has been writing for numerous other publications, including Fortune Small Business, Windows 2000 Magazine (now Windows and .NET Magazine), ZDNet and Sam Whitmore's Media Survey.

Submit a Comment

Loading Comments...
Manage your Newsletters: Login   Register My Newsletters

Rocket Fuel