Posted by admin on June 23, 2008 | No Comments
A relatively new trend in SQL injection started developing late last year: Numerous web sites were defaced by including malicious HTML <script> tags in text that was stored in SQL databases — and that text was/is used to generate web pages dynamically.
According to Microsoft’s Security Vulnerability Research & Defense web site, such “attacks began to accelerate in the first quarter of 2008 and are continuing to affect vulnerable web applications.”

What surprised me most, however, was that Microsoft listed the following three commonalities among the web sites that were especially prone to this kind of SQL injection:
- The web sites use Classic ASP code
- The back-end is powered by a SQL Server database
- The web site’s code generates dynamic SQL queries, using URI query strings
Wow! Why was I surprised? Well, for the better part of the last four years or so, I’ve been painstakingly upgrading a legacy web application, running on Classic ASP (but also some C#.NET). Those upgrades included, among a ton of other security-related issues, the conversion of all in-line SQL queries to Stored Procedures.
During that time, I’ve also hired a third-party security company to make sure (every six (6) months) that no new vulnerabilities were added to the web application by me and my developers. Yes, it was painful at first, but it was well worth the effort.
Enter the scary part: As pointed out on the web site I’ve mentioned above, “these attacks have been accelerating through the year.” The researchers at Microsoft then point out that there are two significant factors involved in that:
1) There is a malicious tool that is in the wild that automates this. In a nutshell, the tool uses search engines to find sites that are vulnerable to SQL injection.
2) One or more malicious bots are now launching SQL injection attacks to spread the bot further. (SecureWorks discusses such an example in this article.)
What’s the solution? Since the enemy never sleeps, it looks as though web developers and database administrators won’t be able to rest on their laurels for long.
- Use Stored Procedures to send information to the database
- Verify that the most obvious malicious user input gets caught before it gets passed to any Stored Procedures
- Review the server logs for suspicious URI query strings
- If you find or suspect any exploits, inspect the various database tables that could have infected data
- Periodically review additional information about SQL Injection for your specific development environment
That’s all for now. If anyone has specific tips to combat this kind of web application threat, please lte me know.