X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 69397528D5 for ; Wed, 10 Aug 2005 14:14:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64123-05 for ; Wed, 10 Aug 2005 17:14:31 +0000 (GMT) Received: from www.cotse.net (smtp.cotse.net [68.166.125.227]) by svr1.postgresql.org (Postfix) with ESMTP id C0CC152930 for ; Wed, 10 Aug 2005 14:14:30 -0300 (ADT) Received: from localhost (localhost[127.0.0.1]) (authenticated bits=0) by smtp (5.7.4/5.7.4) with ESMTP id j7AHET08096415 for ; Wed, 10 Aug 2005 13:14:29 -0400 (EDT) (envelope-from rick@cotse.net) Message-ID: <42FA35F6.4060900@cotse.net> Date: Wed, 10 Aug 2005 10:14:30 -0700 From: Rick Roman User-Agent: Mozilla Thunderbird 1.0.6-1.1.fc3 (X11/20050720) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: Preventing sql injection References: <42FA330D.7020908@cotse.net> <20050810171108.GF7871@alvh.no-ip.org> In-Reply-To: <20050810171108.GF7871@alvh.no-ip.org> Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.637 tagged_above=0 required=5 tests=AWL, HTML_30_40, HTML_MESSAGE, HTML_TITLE_EMPTY, MIME_HTML_ONLY X-Spam-Level: X-Archive-Number: 200508/132 X-Sequence-Number: 18451 Alvaro Herrera wrote:
On Wed, Aug 10, 2005 at 10:02:05AM -0700, Rick Roman wrote:
  
I have a web application that will allow users to submit comments. The 
database activity consists of a single insert statement into a comments 
table. I want to lock down this operation against sql injection attacks. 
Can someone point me to a discussion of general principles? I've seen 
reference to V3 extended-query protocol. Where is this invoked? Other 
suggestions?
    

What language are you using?

The general principle is that you have to look user input for certain
chars, such as ' and \, and escape them somehow.

There's another way, which is using new features of the v3 protocol.
One easy way to do that is using PQexecParams() instead of PQexec(), if
you are dealing with C programs.

  
I am using PG 7.3, Java through the OBJ Object/relational bridge.