|
SQL injection attacksIf you are taking in user data for any SQL query, it is imperative that you validate every single field that you use. Otherwise your data can be damaged with a SQL injection attack. What Is a SQL Injection? To summarize, a SQL injection attack is when someone uses a field you are taking in as input - say a comment field in a blog, or an email address for a newsletter signup - and replaces that field content with SQL commands. You think you are getting in Lisa@xxxxxx.com and start doing SQL commands with it - but in actuality what you are processing is a full SQL string which does whatever the hacker wants it to do. So let's say you have blog.asp and you are expecting in a variable called comment. You take in that comment variable, and then use it in a SQL script, something like insert into blogtable values ('date', 'comment'). You expect the comment to just be inserted into the table. However, let's say the hacker has put in as their comment the text ');delete table blogtable;. Now the full string of your SQL script turns into this: insert into blogtable values ('date', 'comment');delete table blogtable; So the SQL database merrily inserts a row - and then deletes the entire table. Of course hackers rarely delete tables - instead they use this ability to update your entire system to contain references to their porn sites. If this is confusing, take it step by step. The hacker figures out what input you are accepting. They then keep trying various changes to the input field until they figure out how to get it to 1) not give an error and 2) create a fully valid syntax so that their insert and update requests go through properly. They don't have to do this on their own! There are a slew of scripts out there that they use that do this all in an automated fashion. It tries combo A, then combo B, then combo C, and goes right down the line testing out every possibility against your variable field to see which one works. Your database could be hammered for an hour or two - in the wee hours of the morning - by this script. Once the script figures out its opening, the damage begins.
How the SQL Injection Works A more robust solution is to turn your entire site into using procedures, since procedures do variable checking as part of their nature. ASP Form Creation and Security
All content copyright © 2010 Minerva WebWorks LLC. All rights reserved.
|
|