Re: OT: Preventing sql injection attack

2008-02-23 Thread Nathan Maves
Again I think it has been said but what about post-pending the % in this case on the java side; String param = theString + "%"; then using the prepared statement parameter by using #value# On Fri, Feb 22, 2008 at 2:42 PM, Koka Kiknadze <[EMAIL PROTECTED]> wrote: > Think you can limit how many

Re: OT: Preventing sql injection attack

2008-02-22 Thread Koka Kiknadze
Think you can limit how many symbols the user can enter to some reasonable value. If you can limit it, say to 20, you can use something like Select * from Select * from table where column LIKE '$value$%' i.e. malicious user will have to use 20 closing par

Re: OT: Preventing sql injection attack

2008-02-22 Thread Zoran Avtarovski
Good point. I might have a look at the Prepared statement source and use that as a guide for implementing a utlity class to cover my ass. Z. >> I haven't implemented it yet, but I can't see a reason why it wouldn't > work. > > I can not see either, but, to speed up such searches one usually inde

Re: OT: Preventing sql injection attack

2008-02-22 Thread Koka Kiknadze
> I haven't implemented it yet, but I can't see a reason why it wouldn't work. I can not see either, but, to speed up such searches one usually indexes search column. While index will work well for Column LIKE 'bla%', I doubt it will be of any use with ANY_FUNCTION(Column...)...

Re: OT: Preventing sql injection attack

2008-02-22 Thread Zoran Avtarovski
The solution was staring me in the face the whole time. I just do a substring query to the length of the letters typed already: Select column from table where SUBSTRING(column, 1, #term_length#) = #term# I haven't implemented it yet, but I can't see a reason why it wouldn't work. Z. > OK, th

Re: Re : OT: Preventing sql injection attack

2008-02-22 Thread Zoran Avtarovski
That's right. But in the case of an auto complete query you want to search words starting with your argument which needs to look like: select from table where login = 'fre%' By escaping any single quotes in java covers most attacks but it's a shame there's no SQL function for STARTS_WITH(#value#).

Re: Re : OT: Preventing sql injection attack

2008-02-21 Thread Larry Meadors
wrote: > Hi all, > > Aren't PreparedStatements supposed to take care of ovoiding SQL Injection > already ? > > I thought so. Maybe not all cases ?? > > Gilles > > - Message d'origine > De : Larry Meadors <[EMAIL PROTECTED]> >

Re : OT: Preventing sql injection attack

2008-02-21 Thread Gilles Schlienger
n 53s Objet : Re: OT: Preventing sql injection attack OK, then another option...add the % to the user provided input. Larry On Wed, Feb 20, 2008 at 10:23 PM, Zoran Avtarovski <[EMAIL PROTECTED]> wrote: > Thanks Larry, > > But no joy. The db is MySQL

Re: OT: Preventing sql injection attack

2008-02-20 Thread Larry Meadors
OK, then another option...add the % to the user provided input. Larry On Wed, Feb 20, 2008 at 10:23 PM, Zoran Avtarovski <[EMAIL PROTECTED]> wrote: > Thanks Larry, > > But no joy. The db is MySQL 5. To provide more details we are already > escaping single quotes with two single quotes in the b

Re: OT: Preventing sql injection attack

2008-02-20 Thread Zoran Avtarovski
Thanks Larry, But no joy. The db is MySQL 5. To provide more details we are already escaping single quotes with two single quotes in the business logic ie stringSql.replaceAll("'", "''") Bit I was hoping there was a more elegant solution, like the one you suggested - which is not working for me.

Re: OT: Preventing sql injection attack

2008-02-20 Thread Larry Meadors
This should work: select * from table where column LIKE #value# || '%' Larry On Wed, Feb 20, 2008 at 9:40 PM, Zoran Avtarovski <[EMAIL PROTECTED]> wrote: > We have a web application with an ajax autocomplete text box. The problem is > that currently the query statement for the ajax query is : >

OT: Preventing sql injection attack

2008-02-20 Thread Zoran Avtarovski
We have a web application with an ajax autocomplete text box. The problem is that currently the query statement for the ajax query is : Select * from table where column LIKE '$value$%' Which is susceptible to sql injection attacks. One solution is to have a separate connection pool with read-onl