Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1utEUf-003CeM-9q for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Sep 2025 00:03:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1utEUe-001R39-GJ for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Sep 2025 00:03:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1utEUe-001R31-3B for pgsql-hackers@lists.postgresql.org; Tue, 02 Sep 2025 00:03:24 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1utEUa-0005K7-2r for pgsql-hackers@postgresql.org; Tue, 02 Sep 2025 00:03:23 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-55f691c9febso3645014e87.0 for ; Mon, 01 Sep 2025 17:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756771396; x=1757376196; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=u07OmZgI+YcaBdPLGtfSym6xR2EIxOI4QBaM599sG6I=; b=NyWmmhRWUgu91M1q4yXykzeNPcdbmye2MCUbPN1IZDm1/IJ1cpO0MFdCHymMrfuF5l CeAWCE2SKQVqmusAWRhsMqIqLW7yRYHDrjg52TPjdY4k8N2YFHDEWvVmgUkM5Q5508XA ++NLXuyNQ77jHTyACMWE7Y60+H2BX3SpkdS1+gggV7bfp3ycU2S99z8hiEND04Xgh+NQ n630/u7UVrFTlsJ9KBBoy6EGATYkbhSSc3g6GHpJbYN5OxKe+qFMHHVzTYmoM7sABULP TJYHprvoHmJc379oa2Ss4wIdP3HVCvNPJnK8tym2OECeqHh2ZiMaWeUGn4pe+/8gUOpR YXng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756771396; x=1757376196; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u07OmZgI+YcaBdPLGtfSym6xR2EIxOI4QBaM599sG6I=; b=Lp6eQ0OX+jg3l7uu8iy12dCVQZGSsulmgcRkwR9Id8ztd/roPbTRcPfCmQ6CLWAjYb JFIICgkU8OlJcuGNlXKcgeI1JyBmujNZ7BTP0z/wyLoWWxbAfgCcY5ICSIMdDFKt/98L fzHJ+b7QHUjxub1KX7ZWwELuLfyu0S4NrYMPTGhHQX5pwoRHW5OoAAVGLQjTqu0DyhfB OWA1TGQkEiNH6Il98xnRUChNNbOAc2J8MrSeDvJKLhz0Otq/EV3PjjFYkGmYxfxqJVg7 lWoLKbAo45ku7szkKETaIwb6xbZ8AkL9qyXYJT3ds4/iIOwDqV8Hdq3enOCfXiAE+5ff 85ig== X-Forwarded-Encrypted: i=1; AJvYcCXYTAeVc699eqp1X16I4F9nBwLrDi7KDs2aPPNTXs1nV7KJkMRih7yIRC5wo0FD83wi0b8vxkdr49w9zH/j@postgresql.org X-Gm-Message-State: AOJu0YyFLI4bjxvctoGJEpGet1CvW6riHvCJwrkOvbTZd4MI5ONjuXiA wgq5FRWiHMJ+X1I9UxN9hFMDGzNpiWnoEXWwsEIBz46hdbAM5mVOnhi9SlvUVKKaB5v/LcOIfsY Pbj2kc03krAnUfEpD0KDR/+WIEwyPIME= X-Gm-Gg: ASbGnculXhOdly8ct6gTUjfXqhv+102PdeHGjjuP80AsjJmzwi5vKbCe6njYCJESfOW pKPNaKWCY01IAqDgUEItKzCZIaqVfWNaBgswrePvyqPSJk4VRJmy06UrZo0jpx1KfBinnFg0IMV dxf4LzdzkFa9YTZGFJoQ0NcXZvb6fnVMCgpSPICy/CO8CDMNRCivEBpBSgEdTKkCIQ+fcWOfh6D D0nTct5dihuz5asoQZDH5ZdwDIfn7HT/JyI+cuZKkokehEKiao= X-Google-Smtp-Source: AGHT+IHOoebhEvuvHU1TTCn7txmksXsk43iqycy75hvFhLqQy3tb/6UTaqzCkTsIpjvyoH2CBjjcxVyvEgbKzcfFb5k= X-Received: by 2002:a05:6512:32cb:b0:55f:3bca:b161 with SMTP id 2adb3069b0e04-55f708db526mr2767505e87.27.1756771396003; Mon, 01 Sep 2025 17:03:16 -0700 (PDT) MIME-Version: 1.0 References: <585e996c-a5c6-4e61-acc4-d92b7a1458ea@vondra.me> In-Reply-To: From: Julien Rouhaud Date: Tue, 2 Sep 2025 08:03:04 +0800 X-Gm-Features: Ac12FXwyIISxHUXA6F2xiSK8PDAvf4lX8yxD944ImfjkdglZmJ7RD9E4pVXp3Jo Message-ID: Subject: Re: Extension security improvement: Add support for extensions with an owned schema To: Robert Haas Cc: Jelte Fennema-Nio , Artem Gavrilov , Jelte Fennema-Nio , Tomas Vondra , "David G. Johnston" , Jeff Davis , PostgreSQL-development Content-Type: multipart/alternative; boundary="00000000000002aaa3063dc637a0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000002aaa3063dc637a0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 12 Aug 2025, 03:24 Robert Haas, wrote: > On Mon, Aug 11, 2025 at 1:55=E2=80=AFPM Robert Haas wrote: > > [ some review ] > > Another thing that's occurring to me here is that nothing prevents > other objects from making their way into the owned schema. Sure, if we > create a new schema with nobody having any permissions, then only the > creating role or some role that has its privileges can add anything in > there. But that could happen by accident, or privileges could later be > granted and somebody could add something into the extension schema > after that. I wonder whether we should lock this down tighter somehow > and altogether forbid creating objects in that schema except from an > extension create/upgrade script for the owning extension. > I think that it would be too strict. One not too uncommon scenario is an extension in a dedicated schema that creates additional objects dynamically, for instance creating new partitions using triggers on one of the extension table. Such objects are not part of the extension and yet are in control of the extension. As an example powa already relies on that a lot (it creates new tables if you register a new extension dynamically), and I'm about to add a feature that create/drops s a bunch of inherited tables via a trigger when a remote server is added / removed. I'm sure that there are a lot of other extensions doing something similar. > --00000000000002aaa3063dc637a0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, 12 Aug 2025, 03:24 Robert Haas, = <robertmhaas@gmail.com> = wrote:
On Mon, A= ug 11, 2025 at 1:55=E2=80=AFPM Robert Haas <robertmhaas@gmail.com= > wrote:
> [ some review ]

Another thing that's occurring to me here is that nothing prevents
other objects from making their way into the owned schema. Sure, if we
create a new schema with nobody having any permissions, then only the
creating role or some role that has its privileges can add anything in
there. But that could happen by accident, or privileges could later be
granted and somebody could add something into the extension schema
after that. I wonder whether we should lock this down tighter somehow
and altogether forbid creating objects in that schema except from an
extension create/upgrade script for the owning extension.
<= /div>

I think that it wo= uld be too strict. One not too uncommon scenario is an extension in a dedic= ated schema that creates additional objects dynamically, for instance creat= ing new partitions using triggers on one of the extension table.=C2=A0 Such= objects are not part of the extension and yet are in control of the extens= ion.

As an example powa = already relies on that a lot (it creates new tables if you register a new e= xtension dynamically), and I'm about to add a feature that create/drops= s a bunch of inherited tables via a trigger when a remote server is added = / removed. I'm sure that there are a lot of other extensions doing some= thing similar.=C2=A0
--00000000000002aaa3063dc637a0--