From: Justin Waddell <jwaddell@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Cannot use prepared statements with create user command
Date: Wed, 23 Aug 2006 14:09:03 +1000
Message-ID: <925094a20608222109s438a5b41g2886f41e9ddf7417@mail.gmail.com> (raw)
To avoid SQL injection attacks I am keen to use prepared statements
for all JDBC calls. However prepared statements do not work with the
CREATE USER command.
I am using the following command:
CREATE USER ? PASSWORD ? CREATEUSER
and then setting the parameters before executing it. This causes the
following exception:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1525)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1309)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
If a prepared statement is not used, then this command is definitely
open to SQL injection attacks - I dropped a database table by using
the following username:
blah;drop table dummy;--
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: jwaddell@gmail.com
Subject: Re: Cannot use prepared statements with create user command
In-Reply-To: <925094a20608222109s438a5b41g2886f41e9ddf7417@mail.gmail.com>
References: <925094a20608222109s438a5b41g2886f41e9ddf7417@mail.gmail.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