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 1qQbHQ-000PRp-Ew for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Jul 2023 22:22: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 1qQbHN-0022Y4-DQ for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Jul 2023 22:22:18 +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 1qQbHN-0022Xv-0p for pgsql-hackers@lists.postgresql.org; Mon, 31 Jul 2023 22:22:18 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qQbHH-0004fY-Fa for pgsql-hackers@postgresql.org; Mon, 31 Jul 2023 22:22:17 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bbc64f9a91so42535995ad.0 for ; Mon, 31 Jul 2023 15:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20221208.gappssmtp.com; s=20221208; t=1690842129; x=1691446929; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=KCIkvDwA39z8ja98xIXq1aYl7BrDDZ6H069FR/GKbzc=; b=VdKLkX+ntFBNVClscoJj6uFRbfKrKwdOBLDZoLnNgOj9ZmGxfn7aChTS0SmRzDnCL/ otBstcp0cGC18LZQ3pyjr5+UTSH/MkT1iqNPudLR80dLQPGXdsstumsllIzMLLiu08Iy IM5UAsNehQ5b8yi2wreNN0DbADHKw9FKf1lkCOOCgChYhsmJy7nTEn+WSfbDHTGebIxa dDfaFc5vkw9WfquKSpjc+lJ82DPFXHSPOiSUIfPt8XoFD4jC5TL37hF4NnkvXJSPWhaT rPaALRip97B1z9FwvCnUhj8o1uK9w9REt0Yef/0BGlQ1ZX7sC8H0STndOoTQIVctfpTW kq8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690842129; x=1691446929; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=KCIkvDwA39z8ja98xIXq1aYl7BrDDZ6H069FR/GKbzc=; b=F/7aZlooVuSr46RZ6RwFIlpY2OAvFzgGTJRZZvXixvD86gewwRlHCl5/xh4PaKbjjK 56IYLCY0K6wqgyI7x/FGUvdDqMPVLLa3gZEq5Kp4BRR/L/tYfW7nAvPwoWm3mCdIygII 6ZPwEgsXYNm4vxMudSndNSZX25VoiLZr9noTYa232ENunzUMxDZreIvWRvEMjq8Zf2eO UlsgwHiOBUYJvHjc55iiW8s6sYZU+G3jTFWuMgip/M+Cbp9rCviP+DvTPs1jvGnvlqNa B7oMz16VyVZ3hhF/HXb0+x1CljTIT3fFaFA8bIel4iY9QUwOTGzFE+RX+oLZZ/cEXWNd QuVA== X-Gm-Message-State: ABy/qLbRq5JMBNWIQ9qJ+Qt5GNmx7VZN3Ddo9RZwgWR7jTIe4n7YWtAC EDNzre7feUb3c+a59a3z2+xlNth0ZLaqcYhVxE0= X-Google-Smtp-Source: APBJJlG5xZCInlSomxGRmPHG3rcP3m8HH+XXcBfDJ5wxYe1FdakU7rSxA7gLpIakNms10lD/aKKl8Q== X-Received: by 2002:a17:903:32c4:b0:1bb:9b29:20d9 with SMTP id i4-20020a17090332c400b001bb9b2920d9mr13133606plr.20.1690842129599; Mon, 31 Jul 2023 15:22:09 -0700 (PDT) Received: from jeff-laptop.lan (c-73-170-46-202.hsd1.ca.comcast.net. [73.170.46.202]) by smtp.gmail.com with ESMTPSA id g1-20020a170902fe0100b001bbc9e36d55sm9025592plj.268.2023.07.31.15.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 15:22:09 -0700 (PDT) Message-ID: Subject: Re: pgsql: Fix search_path to a safe value during maintenance operations. From: Jeff Davis To: Joe Conway , Robert Haas Cc: Tom Lane , Noah Misch , "pgsql-hackers@postgresql.org" , Nathan Bossart Date: Mon, 31 Jul 2023 15:22:07 -0700 In-Reply-To: References: <89a415b86d5421941e4281ba5bf6288934078624.camel@j-davis.com> <573014.1686375211@sss.pgh.pa.us> <20230612170510.GA201972@gust.leadboat.com> <20230613182920.GA259321@gust.leadboat.com> <1799839.1686687804@sss.pgh.pa.us> <4df537f5a0d8c0ceac3eec3809d1144880b8e76d.camel@j-davis.com> <578fb4be80247570e6a05924908765a0b345971e.camel@j-davis.com> <43bbc9f7318057f51552d5986830908cb018dadf.camel@j-davis.com> <1659699.1688086436@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2023-07-31 at 13:17 -0400, Joe Conway wrote: > But the analysis of the issue needs to go one step further. Even if > the=20 > search_path does not change from the originally intended one, a newly > created function can shadow the intended one based on argument > coercion=20 > rules. There are quite a few issues going down this path: * The set of objects in each schema can change. Argument coercion is a particularly subtle one, but there are other ways that it could find the wrong object. The temp namespace also has some subtle issues. * Schema USAGE privileges may vary over time or from caller to caller, affecting which items in the search path are searched at all. The same goes if theres an object access hook in place. * $user should be resolved to a specific schema (or perhaps not in some cases?) * There are other GUCs and environment that can affect function behavior. Is it worth trying to lock those down? I agree that each of these is some potential problem, but these are much smaller problems than allowing the caller to have complete control over the search_path. Regards, Jeff Davis