From: Dmitry Tkach <dmitry@openratings.com>
To: Csaba Nagy <nagy@ecircle-ag.com>
Cc: Paul Thomas <paul@tmsl.demon.co.uk>
Cc: ". org \" < <pgsql-jdbc@postgresql.org>
Subject: Re: Prepared Statements
Date: Thu, 17 Jul 2003 11:27:23 -0400
Message-ID: <3F16C05B.3030109@openratings.com> (raw)
In-Reply-To: <1058454878.25132.214.camel@coppola.ecircle.de>
References: <200307161624.39340.julien.legoff@laposte.net>
<20030717002329.A26390@bacon>
<3F16B715.4010006@openratings.com>
<1058454878.25132.214.camel@coppola.ecircle.de>
>
>
>In my understanding the prepared statement will properly escape any
>parameter so it can be trusted that the resulting query will not contain
>something you wouldn't expect. Example (< and > are delimiters, ignore
>them):
>
>query: <SELECT * from address_book WHERE name = ?>
>
>input: <joe';delete from address_book where 'true>
>
>result if you just replace the <?> with <'$input'>:
>SELECT * from address_book WHERE name = 'joe';delete from address_book
>where 'true'
>-> results in 2 statements executed
>
Nope. You missed a quote :-)
The resulting query would be:
SELECT * from address_book WHERE name = 'joe'';delete from address_book
where 'true';
This will be a syntax error - not "2 statements executed"... not even
one statement :-)
But that's not the point anyway.
The app that accepts user input the way you describe and just puts
quotes around it is of little use anyway ...
To be useful, it would have to take care about escaping the special
characters on its own - not even to prevent "injection attacs", but just
to be functional in the way that doesn't generate unexpected syntax
errors (or just totally wrong data being entered) just because the
user's input happens to contain a character that has a special meaning
to the parser.
Dima
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: dmitry@openratings.com, nagy@ecircle-ag.com, paul@tmsl.demon.co.uk
Subject: Re: Prepared Statements
In-Reply-To: <3F16C05B.3030109@openratings.com>
References: <200307161624.39340.julien.legoff@laposte.net> <20030717002329.A26390@bacon> <3F16B715.4010006@openratings.com> <1058454878.25132.214.camel@coppola.ecircle.de> <3F16C05B.3030109@openratings.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox