Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...SQL Parameter Sanitizing - Best Practices?SQL Parameter Sanitizing - Best Practices?
Previous
 
Next
New Post
11/15/2010 7:50 PM
 
I'm trying to figure out the best practice for sanitizing SQL Parameters being passed to stored procedures. The MS Application Bocks (Microsoft.ApplicationBlocks.Data.dll) :: SqlHelper.ExecuteReader does not sanitize parameters before passing on to stored procedures.

Should it?


 
New Post
11/16/2010 1:20 AM
 
First, it's not clear what you mean by sanitizing sql parameters.

If you're talking about making sure that they are correct type and/or length, then you will get an exception thrown if the parameters don't match with the correct Sql types of the stored procedure at the database side.

If you're talking about making sure the parameters can't fall victim to sql injection attacks, then you don't need to worry.  I don't know of any sql injection attacks where you can run arbitary Sql inside a Sql procedure by using parameterised queries, unless the developer has done something a bit silly inside the procedure itself (like accepting a sql statement as a parameter).

The best defense against Sql injection is using stored procedures and parameterized queries - you don't need to do anything at the application block level to improve this IMO.
 
New Post
11/16/2010 3:30 PM
 
I'm concerned about SQL Injection....we have a module that has a search feature, and while it's using parameterized queries and stored procedures, it's building the SQL with concatenation. There is probably a better way to do it, but it's a fairly complex search query and I just want to "sanitize" the search terms picked up from the browser.

Once we get into the area of concatenation, the SQL is no longer "protected". 

I'm guessing one quick a dirty way to fix this is an SQL Function (but SQL sucks at string manipulation).
 
New Post
11/16/2010 4:31 PM
 
There is a core InputFilter (NoSQL) that can be used to filter for common sql injection, but it's a blacklist filter so may not be perfect (it's essentially legacy code from dnn 1.x). I highly recommend you recode your dynamic sql from using concatenation to instead using a parameterised approach that utilises NULL values and Or checks - see http://weblogs.asp.net/sukumarraju/archive/2009/12/05/dynamic-search-using-stored-procedure.aspx for an example.

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
11/16/2010 5:02 PM
 
Thanks, we'll check that out.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...SQL Parameter Sanitizing - Best Practices?SQL Parameter Sanitizing - Best Practices?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out