Developer forum

Forum » Templates » Razor SQL Injections

Razor SQL Injections

Nuno Aguiar
Reply

Hi,

 

I've read Mikkel's answer on http://developer.dynamicweb-cms.com/forum/templates/razor-templates-connect-to-database.aspx and was wondering if the  Dynamicweb.Database.SqlEscapeInjection() method was as effective as the SQL command.

 

Sometimes we want to update a table and becomes faster/easier to code with a simple user input sanitation rather than creating a SqlCommand

 

Nuno


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Nuno

You really should stick to Mikkels recommendations. The SqlEscapeInjection() is an alternative though.

Also, Dynamicweb will scan ALL querystring and post parameters for possible SQL attacks.

BR Nicolai

 
Nuno Aguiar
Reply

Hi Nicolai,

 

Ok, we will use Mikkel's process as standard.

 

Just in case we need to use the other one, can you provide us with the regex applied in the SqlEscapeInjection() method? Would come in handy to provide client side validations.

 

Best Regards,

Nuno

 
Nicolai Høeg Pedersen
Reply

Hi Nuno

It is a range of different checks where this is just one of them. And there is a difference if it is a querystring or post.

Actually you do not have to use SqlEscapeInjection() method because Dynamicweb will handle it before it comes to your code. Simply use Input.Request() which will escape for you when appropiate.

Nicolai

 
Nuno Aguiar
Reply

Hi Nicolai,

 

Great, thanks for the feedback. We will take that into consideration.

 

Best Regards,

Nuno

 

You must be logged in to post in the forum