Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 84550633151 for ; Wed, 18 Feb 2009 07:23:20 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 41824-04 for ; Wed, 18 Feb 2009 07:23:13 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from proxy2.bredband.net (proxy2.bredband.net [195.54.101.72]) by mail.postgresql.org (Postfix) with ESMTP id 43F86632D60 for ; Wed, 18 Feb 2009 07:23:12 -0400 (AST) Received: from ironport.bredband.com (195.54.101.120) by proxy2.bredband.net (7.3.127) id 4983021B005FD4C8 for pgsql-hackers@postgresql.org; Wed, 18 Feb 2009 12:23:08 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkcBAG9+m0lStoUM/2dsb2JhbAAI1C+EEwY X-IronPort-AV: E=Sophos;i="4.38,229,1233529200"; d="scan'208";a="488103570" Received: from 1-1-2-48a.rny.sth.bostream.se (HELO [192.168.0.199]) ([82.182.133.12]) by ironport1.bredband.com with ESMTP; 18 Feb 2009 12:23:08 +0100 Message-ID: <499BEF9B.40903@tada.se> Date: Wed, 18 Feb 2009 12:23:07 +0100 From: Thomas Hallgren User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: Kris Jurka CC: Tom Lane , pljava-dev@pgfoundry.org, pgsql-hackers@postgresql.org, Alvaro Herrera Subject: Re: [Pljava-dev] Re: Should creating a new base type require superuser status? References: <19715.1217447413@sss.pgh.pa.us> <20080730220753.GG3977@alvh.no-ip.org> <23846.1217539394@sss.pgh.pa.us> <48937589.10304@tada.se> <23725.1217626961@sss.pgh.pa.us> <48940239.8080401@tada.se> <4111.1217693570@sss.pgh.pa.us> <499BA58F.8000706@tada.se> <499BBA18.2000309@ejurka.com> In-Reply-To: <499BBA18.2000309@ejurka.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 200902/927 X-Sequence-Number: 134217 Kris Jurka wrote: > Thomas Hallgren wrote: >> Kris Jurka wrote: >>> >>> 3) By value: pljava does not correctly handle passed by value types >>> correctly, allowing access to random memory. >>> >> This is simply not true. There's no way a Java developer can access >> random memory through PL/Java. > > No, the point is that the Java developer can provide some data which > can convince postgresql to fetch random data for the user. > > Consider the attached type which is simply an int4 equivalent. > Depending on how you define it as passed by value or passed by > reference it will or will not work (attached). > > This looks like it works: > > > jurka=# select '1'::intbyref, '2'::intbyval; > intbyref | intbyval > ----------+---------- > 1 | 2 > (1 row) > > But it doesn't really: > > jurka=# create table inttest (a intbyref, b intbyval); > CREATE TABLE > jurka=# insert into inttest values ('1', '2'); > INSERT 0 1 > jurka=# select * from inttest; > a | b > ---+------------ > 1 | 2139062143 > (1 row) It seems the pointer is confused for the actual value which means that writing the value back will corrupt the pointer. That's bad of course but I would classify this as a bug rather then a general security problem. PL/Java is designed to do handle all types securely and completely hide the concept of 'by value' or 'by reference' from the Java developer since such concepts are meaningless in Java. - thomas