Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 6005A2E002F for ; Sun, 27 Apr 2008 05:48:59 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 67179-10 for ; Sun, 27 Apr 2008 05:48:52 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wf-out-1314.google.com (wf-out-1314.google.com [209.85.200.168]) by developer.postgresql.org (Postfix) with ESMTP id ACB182E002E for ; Sun, 27 Apr 2008 05:48:56 -0300 (ADT) Received: by wf-out-1314.google.com with SMTP id 28so3414665wff.28 for ; Sun, 27 Apr 2008 01:48:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=p/Y/F0mi59/PfFD+DlStogNEuujKgULspSO4rUieYYI=; b=ZohrL7R8uT7lQbeZ2RmwQ8+G5tBiUwyY6KxVsqBD1q4uYksNl20Y1nV4eroWYKqNdXKtj0e96jIwpQR+lRHfcPZ8BiCwVWUasV2t8CV+nv/XtdyNCm+D9VM1ARd0wmj+llSkaDL/C7wIBPRZTUO6hlxAf8W92vcW21deTKofEMQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=qZ5r4NRB9dFrirab25G2Te0Gj5KuLwSVYZoidV/i60UBqFDt+dHP7fYtBNVPcDyxJS1NOoEvuSSAodkoQSYTSGFv+7vN3PvB6vrPo9/MdgBdD7w7IPuGTpwSg4ljkIZKfqt2cyhkxluieS8xt5dGOCC7XaeI/MiAjB8sNMZeIdw= Received: by 10.142.215.5 with SMTP id n5mr1428334wfg.161.1209286135353; Sun, 27 Apr 2008 01:48:55 -0700 (PDT) Received: by 10.142.127.4 with HTTP; Sun, 27 Apr 2008 01:48:55 -0700 (PDT) Message-ID: <5f211bd50804270148i3f658043o8f7f13852859922b@mail.gmail.com> Date: Sun, 27 Apr 2008 10:48:55 +0200 From: "Thomas Mueller" To: "Thomas Kellerer" Subject: Re: Protection from SQL injection Cc: pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5f211bd50804260932l7a63618jca64858271ff269f@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200804/193 X-Sequence-Number: 30732 Hi, > I fail to see how the backend could distinguish between a query sent by a > query tool and a query sent by an "application". The backend could use a different client library (a client library that doesn't allow literals). But in this case two or three client libraries are required. Probably better is to restrict in the database. There would be a user (or role) for the query tool and one for the application. Maybe the SET ALLOW_LITERALS is not such a good idea. What about REVOKE LITERAL_TEXT FROM APP_ROLE. So LITERAL_TEXT and LITERAL_NUMBER would be rights (similar to REVOKE USAGE ON LANGUAGE ... FROM ...). It's an access rights problem. Let's say there is a development database (DEV_DB) and a production (PROD_DB). There are two users / roles on those systems: APP_USER (no literals) and QUERY_TOOL_USER (literals allowed). The passwords are different on each system. Developers know the password for QUERY_TOOL_USER@DEV_DB and APP_USER@DEV_DB, but only APP_USER@PROD_DB. Or developers know all passwords, but the application configuration is rewieved not to use QUERY_TOOL_USER. Regards, Thomas