Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Stored Procedures and SQL Injection


Stored Procedures and SQL Injection

Author
Message
K. Brian Kelley
K. Brian Kelley
Keeper of the Duck
Keeper of the Duck (6.8K reputation)

Group: Moderators
Points: 6826 Visits: 1917
Comments posted to this topic are about the item Stored Procedures and SQL Injection

K. Brian Kelley
@‌kbriankelley
David.Poole
David.Poole
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3698 Visits: 3120
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.

LinkedIn Profile

Newbie on www.simple-talk.com
Question Guy
Question Guy
SSC Journeyman
SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)

Group: General Forum Members
Points: 90 Visits: 763
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....
K. Brian Kelley
K. Brian Kelley
Keeper of the Duck
Keeper of the Duck (6.8K reputation)

Group: Moderators
Points: 6826 Visits: 1917
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
JustMarie
JustMarie
SSC-Addicted
SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)

Group: General Forum Members
Points: 495 Visits: 1120
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.
mtassin
mtassin
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4109 Visits: 72512
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.



--Mark Tassin
MCITP - SQL Server DBA
Proud member of the Anti-RBAR alliance.
For help with Performance click this link
For tips on how to post your problems
David.Poole
David.Poole
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3698 Visits: 3120
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.

LinkedIn Profile

Newbie on www.simple-talk.com
K. Brian Kelley
K. Brian Kelley
Keeper of the Duck
Keeper of the Duck (6.8K reputation)

Group: Moderators
Points: 6826 Visits: 1917
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
HildaJ
HildaJ
SSC-Enthusiastic
SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)

Group: General Forum Members
Points: 177 Visits: 571
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.
Jonathan AC Roberts
Jonathan AC Roberts
SSC-Addicted
SSC-Addicted (430 reputation)SSC-Addicted (430 reputation)SSC-Addicted (430 reputation)SSC-Addicted (430 reputation)SSC-Addicted (430 reputation)SSC-Addicted (430 reputation)SSC-Addicted (430 reputation)SSC-Addicted (430 reputation)

Group: General Forum Members
Points: 430 Visits: 1836
This made me laugh

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search