February 17, 2013 at 10:55 pm
Comments posted to this topic are about the item Stored Procedures and SQL Injection
K. Brian Kelley
@kbriankelley
February 18, 2013 at 1:15 am
Not only are SQL Injection attacks still going on but also cross site scripting, response splitting and other nasties.
Let us suppose that your code is SQL Injection attack proof. Some enters Dave';WAITFOR('00:00:15'); into a form field and that is precisely what gets entered into the DB. The WAITFOR doesn't get treated as a SQL Statement but now you have a data quality problem.
OK, coding to look for strange syntax is quite a job but I've seen fields that, in theory, are populated from web form drop down boxes that have had this rubbish in them!!!
Cross site scripting is when enter JavaScript tags into a DB field and when the contents of these fields is rendered on the web page the JavaScript fires.
Then you have HTTP Response Splitting where some bright spark has worked out that injecting carriage returns and line feeds into the HTTP response fools the web server into to accepting more than it should from any single request.
At one time is was easy to spot illegitimate mechanical activity on a web stie by the HTTP_USER_AGENT. Now even the most basic mechanical attack will know to spoof a valid HTTP_USER_AGENT and probably rotate IP addresses to avoid rate alerts (too much traffic coming from one customer for it to be genuine).
From the malicious attack perspective the game has moved on.
SQL Injection attacks are the middle aged man with the high BMI in the Sunday pub football league compared to what else is out there in the European super league.
If SQL Injection attacks are still suceeding on your web site then you're way behind the curve.
February 18, 2013 at 7:06 am
Once upon a time, we had some old code that did not account for SQL Injection attacks. And then it happend.
People could not understand why the titles on our external web pages were changing or being deleted.
These pages were database driven through the use of an administative front-end for the users.
I put a few insert and update triggers on a few tables, and what do you know, a couple days later we find out someone is passing SQL statements into a field that for some reason was aimed at changing the titles on our web pages.
These pages were changed to use stored procedures.
Now, if only everyone was on board for doing this on our Intranet as well....
February 18, 2013 at 9:12 am
David, I would agree with you that SQL injection attacks should be old news. The problem is they aren't. For instance, the discovery of serious SQL injection vulnerabilities for Ruby on Rails was reported last month (Jan 2013). Therefore, it behooves us to continue to remind folks of what can be done and why they should care.
K. Brian Kelley
@kbriankelley
February 18, 2013 at 9:29 am
Just a thought but what about aliasing the columns returned by the stored procedure to give another level of protection? The real column names are hidden and the naming convention can't be extrapolated.
February 18, 2013 at 9:30 am
And the other thing to keep in mind is that if we don't occasionally mention SQL injection attacks and how to prevent them, we run the risk of developers in the future repeating the mistakes of the past.
February 18, 2013 at 9:36 am
K. Brian Kelley (2/18/2013)
David, I would agree with you that SQL injection attacks should be old news. The problem is they aren't.
Boy do I know it! What is telling is that the majority of the SQL Dialect is for SQL Server and MySQL.
February 18, 2013 at 9:38 am
Marie, you could certainly do that, but if the app uses the stored procedure, then the attacker can use it to do what the stored procedure is capable of. The attacker still can't get to the table in question, so whether or not the parameters equal the columns, there's not really a risk. There is probably greater risk of developers and DBAs getting things confused because the names are different.
K. Brian Kelley
@kbriankelley
February 18, 2013 at 10:03 am
SQL Injection attacks are very present and as the article mentions they are still around because developers either by lack of knowledge or experience are still programming to allow these loops. What drives me crazy is that some companies don't believe it's worth the effort the extra time and training required to prevent these type of attacks. I used to be a developer and in my case was lack of knowledge and experience in addtion to lack of training and our company suffered a sql attack. I was very upset and emberrased that this happened to us. Great article.
February 18, 2013 at 11:23 am
This made me laugh
February 18, 2013 at 3:56 pm
And this one:
February 19, 2013 at 8:30 am
Thanks Brian. This article is extremely informative. I hate permissions in SQL but your approach is spot on for making it understandable.
February 19, 2013 at 10:31 am
Using stored procedures is a requirement for PCI compliance. It is one of the requirements that slows down or stops all manner of nasties (well delineated in earlier posts). If your web site accepts credit cards, this is one of the many requirements.
February 19, 2013 at 10:48 am
Dave Vroman (2/19/2013)
Using stored procedures is a requirement for PCI compliance. It is one of the requirements that slows down or stops all manner of nasties (well delineated in earlier posts). If your web site accepts credit cards, this is one of the many requirements.
I recently went through the Payment Card Industry (PCI) Data Security Standard V2.0 documents in detail and never saw anything that stated that you are required to use stored procedures.
Can you point to a specific PCI standards document that states this requirement?
February 19, 2013 at 10:58 am
It totally depends on the level of PCI compliance. I don't remember where it was and I am no longer at that company. It was not specifically spelled out in the compliance papers, but it was required by the company that was testing for compliance.
Viewing 15 posts - 1 through 15 (of 23 total)
You must be logged in to reply to this topic. Login to reply