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 6625B52930 for ; Wed, 10 Aug 2005 14:10:55 -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 37429-05 for ; Wed, 10 Aug 2005 17:10:52 +0000 (GMT) Received: from alvh.no-ip.org (200-85-218-206.bk4-dsl.surnet.cl [200.85.218.206]) by svr1.postgresql.org (Postfix) with ESMTP id D57A3528D5 for ; Wed, 10 Aug 2005 14:10:51 -0300 (ADT) Received: by alvh.no-ip.org (Postfix, from userid 1000) id 430A5C2D450; Wed, 10 Aug 2005 13:11:08 -0400 (CLT) Date: Wed, 10 Aug 2005 13:11:08 -0400 From: Alvaro Herrera To: Rick Roman Cc: pgsql-admin@postgresql.org Subject: Re: Preventing sql injection Message-ID: <20050810171108.GF7871@alvh.no-ip.org> Mail-Followup-To: Rick Roman , pgsql-admin@postgresql.org References: <42FA330D.7020908@cotse.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42FA330D.7020908@cotse.net> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.796 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200508/131 X-Sequence-Number: 18450 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. -- Alvaro Herrera () "In a specialized industrial society, it would be a disaster to have kids running around loose." (Paul Graham)