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 1rfNDO-00HGQu-Mt for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Feb 2024 16:55:31 +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 1rfNDN-00CZu1-Ck for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Feb 2024 16:55:29 +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 1rfNDN-00CZtj-3k for pgsql-hackers@lists.postgresql.org; Wed, 28 Feb 2024 16:55:29 +0000 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rfNDJ-001qpu-PS for pgsql-hackers@postgresql.org; Wed, 28 Feb 2024 16:55:28 +0000 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-60938caa800so11244147b3.1 for ; Wed, 28 Feb 2024 08:55:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709139326; x=1709744126; darn=postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Cvpk0e/UJUkCPu9kVzr0T8LyCss656cxwKQBaWOYJfs=; b=j4J0fblHA1IpJ5fb/zjeIJodpmt6VmDlzDMFeDO7R9RHctYvqiWohcKWQKI+gNckZh P/3dXr9njcvr4TNkTMvFGuzWCGgkt1Vboxbp7nthbf0ba67oLuquF3YkOgg0cE935tnE lH8bRO5WlsbtuZT3skn6G+VsPi+XNhck7auRX1+RAbcHEs2lMLD7faSSGHnQ/Mo1V85Q fdBcdrm9z2ROzZjXONcY9xlyH1Ara7NerXV84ekG9pz8QPa4j3nHz7Ao/POWxUkGysfo XPeLeYDUDjyxTHdjXmiq4DI1h2Q6eiq0hG/MxbJVuD/8dqSWPNkjF74RFdXn6tLWG8we vVcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709139326; x=1709744126; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Cvpk0e/UJUkCPu9kVzr0T8LyCss656cxwKQBaWOYJfs=; b=f9padthe7RqrEQ4jXDovHiT6TnfWZxBKR2kkL35Ge3Ht1dGxdbjOzEjcHMYpHyiPZZ yy+kciWQ+kwKqlpG0p9tKNOaub87HRi588QPimIv7mkfDGSEriJPTCLoybclmtYV0FMp CH0TEY6AHOAZsNwpYQN6mfqhnDxTUociZbs1lQPUWoad9C/NKiWMcCdyRM4ybDfCL+MU uGfGwKzOM6GhesGBx8jxh6WFYOhJ2nz/41rDTUybzMBhL+l++2Hc14CdXqDBshcRXMab Owb9xsIUIISHQcoYLiK7BxWM16Z55sbFXYCMj1Oykrb5wyomZLCCWKYTDTCAPz1Cqdul EWFg== X-Gm-Message-State: AOJu0Yx9zZrOFQV+tpXHCXVv1khwJSF6WYR6bgEFMPA770g9NY2vRsqF bsQWb/j+BXQB9ImiXPscrQRTOwqE5xKd0uDkRm35U9rjKCUa80iu X-Google-Smtp-Source: AGHT+IG6vLbBvq+URIo9mZ4vKLE9Uz5W4I09TU5TcP2u16HxGBGV6ck9RAsw+iRiJRMiVIa1Fhn5vA== X-Received: by 2002:a81:8901:0:b0:608:dc8e:ab6d with SMTP id z1-20020a818901000000b00608dc8eab6dmr5962368ywf.37.1709139326097; Wed, 28 Feb 2024 08:55:26 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id u6-20020a818406000000b0060959ca8289sm85346ywf.4.2024.02.28.08.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 08:55:25 -0800 (PST) Date: Wed, 28 Feb 2024 10:55:23 -0600 From: Nathan Bossart To: Jeff Davis Cc: pgsql-hackers@postgresql.org, Joe Conway , Robert Haas Subject: Re: MAINTAIN privilege -- what do we need to un-revert it? Message-ID: <20240228165523.GA2435539@nathanxps13> References: <20240214190226.GA373350@nathanxps13> <4d497d82e4516037dc1082d5a62d199ea00d62e7.camel@j-davis.com> <20240223213055.GA1805646@nathanxps13> <196d1c86d43a147e777bb74159774f255dbe73e3.camel@j-davis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <196d1c86d43a147e777bb74159774f255dbe73e3.camel@j-davis.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Feb 27, 2024 at 04:22:34PM -0800, Jeff Davis wrote: > Do we need a documentation update here? If so, where would be a good > place? I'm afraid I don't have a better idea than adding a short note in each affected commands's page. > On Fri, 2024-02-23 at 15:30 -0600, Nathan Bossart wrote: >> I wonder if it's worth using PGC_S_INTERACTIVE or introducing a new >> value >> for these. > > Did you have a particular concern about PGC_S_SESSION? My only concern is that it could obscure the source of the search_path change, which in turn might cause confusion when things fail. > If it's less than PGC_S_SESSION, it won't work, because the caller's > SET command will override it, and the same manipulation is possible. > > And I don't think we want it higher than PGC_S_SESSION, otherwise the > function can't set its own search_path, if needed. Yeah, we would have to make it equivalent in priority to PGC_S_SESSION, which would likely require a bunch of special logic. I don't know if this is worth it, and this seems like something that could pretty easily be added in the future if it became necessary. >> > +#define GUC_SAFE_SEARCH_PATH "pg_catalog, pg_temp" >> >> Is including pg_temp actually safe?  I worry that a user could use >> their >> temporary schema to inject objects that would take the place of >> non-schema-qualified stuff in functions. > > pg_temp cannot (currently) be excluded. If it is omitted from the > string, it will be placed *first* in the search_path, which is more > dangerous. > > pg_temp does not take part in function or operator resolution, which > makes it safer than it first appears. There are potentially some risks > around tables, but it's not typical to access a table in a function > called as part of an index expression. > > If we determine that pg_temp is actually unsafe to include, we need to > do something like what I proposed here: > > https://www.postgresql.org/message-id/a6865db287596c9c6ea12bdd9de87216cb5e7902.camel@j-davis.com I don't doubt anything you've said, but I can't help but think that we might as well handle the pg_temp risk, too. Furthermore, I see that we use "" as a safe search_path for autovacuum and fe_utils/connect.h. Is there any way to unite these? IIUC it might be possible to combine the autovacuum and maintenance command cases (i.e., "!pg_temp"), but we might need to keep pg_temp for the frontend case. I think it's worth trying to add comments about why this setting is safe for some cases but not others, too. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com