Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B01A9475D4B for ; Wed, 1 Jan 2003 14:22:51 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 0888C4758C9 for ; Wed, 1 Jan 2003 14:22:51 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h01JMnd0007478; Wed, 1 Jan 2003 14:22:49 -0500 (EST) To: ljb Cc: pgsql-interfaces@postgresql.org Subject: Re: Is PQfn() insecure or not? In-reply-to: References: Comments: In-reply-to ljb message dated "Wed, 01 Jan 2003 00:40:31 +0000" Date: Wed, 01 Jan 2003 14:22:49 -0500 Message-ID: <7477.1041448969@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/1 X-Sequence-Number: 3501 ljb writes: > "Programmer's Guide, Client Interfaces, libpq, The Fast-Path Interface" > describes PQfn() and has this alarming remark: > "This is a trapdoor into system internals and can be a potential > security hole." > Sure this isn't true. PQfn() just lets a frontend call a function which is > also accessible (if maybe not useful) via a SELECT statement, correct? The insecure part is not the function call per se (*); it's the fact that the frontend feeds raw internal-format values to the backend for the function's parameters. It'd be fairly trivial to cause a backend crash by feeding bogus data. Not sure whether it's possible to do anything worse than that. One thing we should think about during the planned protocol redesign for 7.4 is whether to change fastpath to pass and return external-format values. This would slow it down marginally, but would make it far safer and more convenient to use ... (*) Actually, I just noticed that the fastpath code fails to check whether the user has permission to call this function, so as of 7.3 that could be considered a security hole. It's an easily fixable one, though. regards, tom lane