Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 1731865039E for ; Mon, 1 Sep 2008 21:48:44 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 00420-04-7 for ; Mon, 1 Sep 2008 21:48:27 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by postgresql.org (Postfix) with ESMTP id E8A45650334 for ; Mon, 1 Sep 2008 21:30:58 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.1/8.14.1) with ESMTP id m820Uk72086511 for ; Mon, 1 Sep 2008 21:30:46 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.1/8.14.1/Submit) id m820GfsP074960 for pgsql-php@postgresql.org; Mon, 1 Sep 2008 21:16:41 -0300 (ADT) (envelope-from news) From: ljb X-Newsgroups: pgsql.interfaces.php Subject: Re: pg_query_params and SQL injection Date: Tue, 2 Sep 2008 00:16:39 +0000 (UTC) Organization: Hub.Org Networking Services Lines: 17 Message-ID: References: <723113.98907.qm@web52404.mail.re2.yahoo.com> X-Complaints-To: usenet@news.hub.org X-No-Archive: yes User-Agent: slrn/0.9.8.1 (Linux) To: pgsql-php@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200809/2 X-Sequence-Number: 3888 tearinghairout@yahoo.com wrote: > Hi all > I am just doing some playing around with PHP to learn how to avoid SQL injection attacks. > It has been mentioned in a few places that pg_query_params is supposed to protect from sql injection without needing to mess around escaping quotes and things. > > However, I was still able to get it to drop a table by feeding in this input "1; drop table results" to the following statement: > $r = pg_query_params($p, 'select * from results where res_id = $1', array($input)); > > Everyone keeps repeating the same "pg_query_params is safe from SQL injection", but surely someone else must have actually tried it? Where am I going wrong? > > I am using Postgresql 8.3 for OS X on 10.5.2, and MAMP which has PHP Version 5.2.5. I can't duplicate it and don't think it is possible. I get this error: PHP Warning: pg_query_params() Query failed: ERROR: invalid input syntax for integer: "1; drop table results" Take another look or post more of the code you tried.