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 1rkS5U-00Cp0w-VH for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Mar 2024 17:08:21 +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 1rkS5T-008adr-Fm for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Mar 2024 17:08:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rkS5T-008aZA-5G for pgsql-bugs@lists.postgresql.org; Wed, 13 Mar 2024 17:08:19 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rkS5L-004JvL-NX for pgsql-bugs@lists.postgresql.org; Wed, 13 Mar 2024 17:08:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2024011501; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=p95SbxL0A2QgWHhYuVCjqfFW6Xav7jI+TxExPNZHxj4=; b=KzBSy YSfpG2p6ScEJpCCdQ4O1mSoichxVmv1bdjjDNHHXYn3N/9v6d42Jp0XiKu91OthmqFwHp3kJY9XYO Pxdao8oboLRFd7kKKtVS7mayqOvXrhvVPVOYZrqQKNxlR7809KhSzqKOvDeSuXRI3uAK72KM+Z/fr tn1Z1MOyma7LmySHOJ1mOefgIgur2uEPM8nzvMKMzTJycupF9ymJgdL94c7Vmv2/ylI84ErpIg/Yj VidDsmmb657biBKy0XYl6r0+bH2Y8uc00V1iTQ61T6S8H2M6F8lhZJlmDAJhXPujqru14n+FG+yei sLmgNcAIlNgOUTXC6Ug31dtioOd+Q==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1rkS5K-004iHB-03; Wed, 13 Mar 2024 13:08:10 -0400 Date: Wed, 13 Mar 2024 13:08:09 -0400 From: Bruce Momjian To: Laurenz Albe Cc: Maxim Boguk , Heikki Linnakangas , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18387: Erroneous permission checks and/or misleading error messages with refresh materialized view Message-ID: References: <18387-12041858d9efb6f6@postgresql.org> <36bb333d-13ec-4f8e-af33-48249ca2fe69@iki.fi> <09970dbb6f95a34d9427c32b09517ea709c77d02.camel@cybertec.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <09970dbb6f95a34d9427c32b09517ea709c77d02.camel@cybertec.at> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 12, 2024 at 01:22:33PM +0100, Laurenz Albe wrote: > On Tue, 2024-03-12 at 12:40 +0200, Maxim Boguk wrote: > > May I suggest a change to always allow superuser run > > REFRESH MATERIALIZED VIEW (may be via set role or similar mechanics)? > > If the query ran with superuser permissions, that would be > a security problem: > > CREATE TABLE log (t text); > > CREATE FUNCTION f() RETURNS integer LANGUAGE sql > AS 'INSERT INTO log VALUES (''x''); SELECT 42'; > > CREATE MATERIALIZED VIEW v AS SELECT f(); > > Now imagine you create a malicious trigger on "log" and > get a superuser to refresh the materialized view. > > > I don't see why it should be a problem if a superuser gets > "permission denied" in such a case. They can also get it if > they call a SECURITY DEFINER function owned by a non-superuser. Can we improve the error that superusers get so they realize how to fix it? -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.