Re: [INTERFACES] New code for JDBC driver

From: "George Koras" <gkoras(at)cres(dot)gr>
To: "Barry Lind" <barry(at)xythos(dot)com>, "Arsalan Zaidi" <azaidi(at)directi(dot)com>
Cc: "PostgreSQL jdbc list" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: [INTERFACES] New code for JDBC driver
Date: 2001-07-05 08:32:00
Message-ID: 005101c1052d$0a519330$1a49e98f@cres.gr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces pgsql-jdbc

Similar problems can arise even if the end user has no bad intentions. In
the example Arsanal mentioned, what if Sinead O'Connor is a user? Wouldn't
this result in the following query?

update users set name='Sinead O'Connor

which gives the error:

ERROR: parser: parse error at or near "connor"

So I guess a solution would be to escape *quotes* and not *semicolons out of
quotes*, which is the solution I use in my programs and on which comments
are invited . This also prevents the malicious use Arsanal is talking about,
doesn't it?

However the PreparedStatement solution (which I haven't tried) seems to be
more elegant.

This thing seems pretty elementary. Isn't it covered in a FAQ somewhere?

----- Original Message -----
From: Barry Lind <barry(at)xythos(dot)com>
To: Arsalan Zaidi <azaidi(at)directi(dot)com>
Cc: PostgreSQL jdbc list <pgsql-jdbc(at)postgresql(dot)org>
Sent: Tuesday, July 03, 2001 6:18 PM
Subject: Re: [INTERFACES] New code for JDBC driver

>
> Now to your situation. The obvious solution is to use prepared
> statements in your middle tier having the client provide the values from
> the text fields to be bound into the query.
>
> > "update users set name='"+name+"'"
>
> So the client sends you the 'name' value and the middle tier uses a
> preparedstatement to bind that value to the update.

>
> Arsalan Zaidi wrote:
>
> > I agree that it probably is. Unfortunately, as I mentioned in my
previous
> > post,no one is going to be entering in SQL queries directly through our
> > interface. We're not doing it and if someone is, he's up to no good.
e.g.
> >
> > "update users set name='"+name+"'"
> >
> > If there's a text box in which you enter your name for the first query,
I
> > can some fun if I enter in
> >
> > Arsalan';update funds set money = 100000 where userid =10
> >

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Cedar Cox 2001-07-05 08:34:43 Re: non-us datestyle
Previous Message Sudheer Palapparambil 2001-07-05 06:44:32 PL/PGSQL

Browse pgsql-jdbc by date

  From Date Subject
Next Message Gunnar Rønning 2001-07-05 10:13:05 Re: Re: [INTERFACES] New code for JDBC driver
Previous Message Tom Lane 2001-07-05 00:54:28 Re: Metadata for tables, schema, and numeric