CountForCriteria injection problem

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

CountForCriteria injection problem

Post by heinscott » Fri Sep 10, 2010 9:30 am

I have a small problem...
McAfee secure scan is telling me that my site has the possibility of an injection attack. I have an email signup in my footer that I want to use to sign people up to our list IF they are not on any other email list already... Here is the code that causes the error....

Code: Select all

string email = UserEmail.Text;
if (!emailList.IsMember(email) && EmailListUserDataSource.CountForCriteria("Email = '" + email + "'") == 0 && email.Contains("@"))
{
    emailList.ProcessSignupRequest(email);
}
Any ideas how I can make accomplish the same thing in a safe manner?
Thanks for the help!

Scott

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: CountForCriteria injection problem

Post by AbleMods » Sat Sep 11, 2010 10:20 pm

You could hit the database directly and use SQL parameters with the query. But that's kind of a hassle.

But the bigger question is.....how is McAfee seeing your server-side code? That code isn't visible from the client side.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: CountForCriteria injection problem

Post by jmestep » Sun Sep 12, 2010 11:43 am

You could try using some Replace functions in your criteria. I think this article would help:
http://msdn.microsoft.com/en-us/library/ms161953.aspx
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: CountForCriteria injection problem

Post by jmestep » Mon Sep 13, 2010 6:36 am

I just remembered this:
Able has a method that should take care of that- StringHelper.SafeSqlString(criteria here)
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Re: CountForCriteria injection problem

Post by heinscott » Mon Sep 13, 2010 10:57 am

Thanks! I will try that SafeSqlString method.

Scott

Post Reply