Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 966186500B4 for ; Wed, 30 Jul 2008 18:19: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 44011-06 for ; Wed, 30 Jul 2008 18:19:37 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from oxford.xeocode.com (87-127-95-198.no-dns-yet.enta.net [87.127.95.198]) by postgresql.org (Postfix) with ESMTP id E626764FFE4 for ; Wed, 30 Jul 2008 18:19:40 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.69) (envelope-from ) id 1KOJ57-000366-Dd; Wed, 30 Jul 2008 22:19:37 +0100 To: "Tom Lane" Cc: Subject: Re: Should creating a new base type require superuser status? In-Reply-To: <19715.1217447413@sss.pgh.pa.us> (Tom Lane's message of "Wed\, 30 Jul 2008 15\:50\:13 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX.hackers" 25148) References: <19715.1217447413@sss.pgh.pa.us> From: Gregory Stark Organization: EnterpriseDB Date: Wed, 30 Jul 2008 22:19:36 +0100 Message-ID: <87sktrgjdj.fsf@oxford.xeocode.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.1 tagged_above=0 required=5 tests=RDNS_DYNAMIC=0.1 X-Spam-Level: X-Archive-Number: 200807/1447 X-Sequence-Number: 121707 "Tom Lane" writes: > If you're not clear on why CREATE TYPE in the hands of a bad guy is > dangerous, here are a couple of reasons: > > * By specifying type representation details (len/byval/align) that are > different from what the type's functions expect, you could trivially > crash the backend, and less trivially use a pass-by-reference I/O > function to read out the contents of backend memory. I know when I was first starting out it was a big source of frustration that you have to get those arguments right.. Until I figured out what they all meant and how to use them I was constantly crashing the server. It seems to me we should be able to do better. To have some kind of struct in the C code associated with the input/output functions from which the create type command picks up these parameters. As a consequence we could perhaps aim to make creating new types safe rather than just deal with the fact that it's not safe currently? It would be nice if non-superusers could create types which used an existing set of input/output functions but defined new semantics. > * The just-added ability to specify a new type's type category and > "preferred" status could allow subverting the behavior of existing > queries that expect ambiguous operators to be resolved in a particular > way. A new preferred type could "capture" such queries and thereby > provide a trojan-horse vector for executing functions as some other > user. Would it be enough to only require super-user to create a preferred type? -- Gregory Stark EnterpriseDB http://www.enterprisedb.com Ask me about EnterpriseDB's Slony Replication support!