Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Stored Procedures and SQL Injection Expand / Collapse
Author
Message
Posted Sunday, February 17, 2013 10:55 PM


Keeper of the Duck

Keeper of the Duck

Group: Moderators
Last Login: Yesterday @ 8:57 AM
Points: 6,634, Visits: 1,872
Comments posted to this topic are about the item Stored Procedures and SQL Injection

K. Brian Kelley, CISA, MCSE, Security+, MVP - SQL Server
Regular Columnist (Security), SQLServerCentral.com
Author of Introduction to SQL Server: Basic Skills for Any SQL Server User
| Professional Development blog | Technical Blog | LinkedIn | Twitter
Post #1421035
Posted Monday, February 18, 2013 1:15 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 10:44 AM
Points: 2,902, Visits: 1,817
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
Post #1421062
Posted Monday, February 18, 2013 7:06 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, August 18, 2014 10:09 PM
Points: 72, Visits: 686
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....



Post #1421203
Posted Monday, February 18, 2013 9:12 AM


Keeper of the Duck

Keeper of the Duck

Group: Moderators
Last Login: Yesterday @ 8:57 AM
Points: 6,634, Visits: 1,872
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, CISA, MCSE, Security+, MVP - SQL Server
Regular Columnist (Security), SQLServerCentral.com
Author of Introduction to SQL Server: Basic Skills for Any SQL Server User
| Professional Development blog | Technical Blog | LinkedIn | Twitter
Post #1421258
Posted Monday, February 18, 2013 9:29 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, September 12, 2014 7:24 AM
Points: 272, Visits: 612
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.
Post #1421271
Posted Monday, February 18, 2013 9:30 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, September 12, 2014 8:38 AM
Points: 3,675, Visits: 72,434
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
Post #1421272
Posted Monday, February 18, 2013 9:36 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 10:44 AM
Points: 2,902, Visits: 1,817
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
Post #1421278
Posted Monday, February 18, 2013 9:38 AM


Keeper of the Duck

Keeper of the Duck

Group: Moderators
Last Login: Yesterday @ 8:57 AM
Points: 6,634, Visits: 1,872
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, CISA, MCSE, Security+, MVP - SQL Server
Regular Columnist (Security), SQLServerCentral.com
Author of Introduction to SQL Server: Basic Skills for Any SQL Server User
| Professional Development blog | Technical Blog | LinkedIn | Twitter
Post #1421280
Posted Monday, February 18, 2013 10:03 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, September 8, 2014 9:14 AM
Points: 163, Visits: 471
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.
Post #1421286
Posted Monday, February 18, 2013 11:23 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, September 12, 2014 3:38 AM
Points: 338, Visits: 1,426
This made me laugh
Post #1421310
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse