vsloathe

Hi all.

So I need to code to impress in a project I have coming up. My code's going to be scrutinized and I want this party to like what I'm putting down, so I want to go beyond my standard method of scrubbing inputs in the working part of my code and actually do some of the sexier methods to prevent SQL injection. I don't even know where to start, so can anyone point me in the right direction?

Thanks,
-V

perkiset

Hmmm... more sophisticated and sexy than scrubbing...

the only thing I can think of is pure input isolation ie., what comes from the user is *never* passed on to hte DB - you take the user's intentions and recreate things from scratch or something... but I don't know what else beyond that except for a telemetry page that looks like "# of queries, # of potential attacks, last 10 queries" and such... have it automatically update so it looks all sexynshyt...

vsloathe

Appreciate the input Perk.

Yes, upon further research I've come to the conclusion that the only impressive route I might be able to take is create my own little scrubbing class whose methods clean my various forms of input, whatever they may be.

nutballs

thats what I was going to suggest. I have a function that I pass 2 parameters to, Type and Value.
i have all kinds of cleaners in there. +integer to force a positive integer such as ID columns. date, float/double, and about a dozen more.

But i don't validate per se, I force correct. So, if someone passes 'abc' to +integer, it gets set to 0.

this is aside from my validation function, which of course runs first, pointing out big a fishhead you are for trying to out-leet me. Applause

Dragonlaird

quote author=vsloathe link=topic=579.msg3851#msg3851 date=1193150021


so I want to go beyond my standard method of scrubbing inputs in the working part of my code and actually do some of the sexier methods to prevent SQL injection.



No sure if it will help since I don't code in

PHP

  but in my native tongue (

ASP

 /

ASP

 

.NET

 Applause I developed a complete DB handling class which deals with all comms to/from any DB and constructs all SQL statements pre-cleaned etc.

It has various functions to allow the developer to construct SQL statements that are DB-specific and also use pre-scrubbed values etc.

Since it's all done server-side, the client form can accept anything you like and the resulting server-side SQL is constructed to save exactly what is entered without any possible SQL injections creeping in.

Is this the sort of thing you were meaning or is this a little too heavy-weight for what you had in mind?

vsloathe

quote author=Dragonlaird link=topic=579.msg3860#msg3860 date=1193204760

quote author=vsloathe link=topic=579.msg3851#msg3851 date=1193150021


so I want to go beyond my standard method of scrubbing inputs in the working part of my code and actually do some of the sexier methods to prevent SQL injection.



No sure if it will help since I don't code in

PHP

  but in my native tongue (

ASP

 /

ASP

 

.NET

 Applause I developed a complete DB handling class which deals with all comms to/from any DB and constructs all SQL statements pre-cleaned etc.

It has various functions to allow the developer to construct SQL statements that are DB-specific and also use pre-scrubbed values etc.

Since it's all done server-side, the client form can accept anything you like and the resulting server-side SQL is constructed to save exactly what is entered without any possible SQL injections creeping in.

Is this the sort of thing you were meaning or is this a little too heavy-weight for what you had in mind?


That's pretty much exactly it. Thanks for the idea.

nop_90

quote author=perkiset link=topic=579.msg3852#msg3852 date=1193157032

the only thing I can think of is pure input isolation ie., what comes from the user is *never* passed on to hte DB - you take the user's intentions and recreate things from scratch or something... but I don't know what else beyond that except for a telemetry page that looks like "# of queries, # of potential attacks, last 10 queries" and such... have it automatically update so it looks all sexynshyt...

Actually yep.
Just came to me.
Probably the number 1 reason to use something like sqlobject for

python

  or similar shit for

PHP

 , ROR etc
Not counting all the other advantages.

Almost make sql injection impossible.

Indica

quote author=Dragonlaird link=topic=579.msg3860#msg3860 date=1193204760

I developed a complete DB handling class which deals with all comms to/from any DB and constructs all SQL statements pre-cleaned etc.


you mind sharing that class?  Applause

Dragonlaird

quote author=Indica link=topic=579.msg3867#msg3867 date=1193339729


you mind sharing that class?  Applause



Normally I would be more than happy to share my code but apart from the fact this is in

ASP

 

.NET

  (and the older version in

ASP

 Applause, I use it in my commercial sites and as such I can't release my commercial code for obvious reasons, plus some of the contracts with customers don't allow me to release the code.

Sowwy...


Perkiset's Place Home   Politics @ Perkiset's