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 1qQaFD-000MSh-0a for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Jul 2023 21:15:59 +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 1qQaF9-001rPh-11 for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Jul 2023 21:15:56 +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 1qQaF8-001rPY-IX for pgsql-hackers@lists.postgresql.org; Mon, 31 Jul 2023 21:15:56 +0000 Received: from mail-oa1-x34.google.com ([2001:4860:4864:20::34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qQaF7-0003h5-8X for pgsql-hackers@postgresql.org; Mon, 31 Jul 2023 21:15:54 +0000 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-1bf0c4489feso15100fac.0 for ; Mon, 31 Jul 2023 14:15:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20221208.gappssmtp.com; s=20221208; t=1690838152; x=1691442952; 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=Z8sL7qI0a+q7aFXE9kgqLLfPaK7onSdN5BA7FYbgiBU=; b=UHuTf3pl9TTWVUuD/u0GjGW5Q+WYkfnFNHI6PNdN9fTZOuTXXUrQXioin+Gp/cB/aj l8p+rkAG8H3z7zgY2g2F6w/EIKa+k3VOATEKLiP2wyB9bm3xO32L4Yrs4If34hRicYXx HK8GzNxIN78FmcnrDnaYK3dYI+ibJzAZLW3pbMpb7jGorSf+swqJJXxOFpRq10UTweTG 6kLYjaeO9rRQRJmIV8jsC48GMpYc1aslH28kJBSCJeyxiyj+26XGIEMrUV2FwyMHNZtO cc5HMXNm/AAqDBnBLLU1qXou9vBPov2JkGpdqjNH81TJS2IpzfMxLvqbtELNjoC0ruAG J+ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690838152; x=1691442952; 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=Z8sL7qI0a+q7aFXE9kgqLLfPaK7onSdN5BA7FYbgiBU=; b=jLn9Ba/bqzY/j1JrvMp9dUAbuNnO0JclDCRS5lYjJNvu64Wo7sSek02Bx+2SCKHypF mKiXXdGAd/QOWxv8SUSLhfVz3hRVeevurAuGmFXEKWiY2xHULlljOBOqvLUHmFt0Ptnj zMirk0pT/pHffvqIZF9JZXjeud75p2BRxqb+8PZtqYcU5NsL+wiwWgpEkiJlUDqifDT0 zLgSTqbQJMOlf/tJEKfSL6vEk8oKE+8nm9PhBPJEAhJetkVyY+QYwZLWiKIttkhGOxY3 1XiMwvJyLLWSCoB++jUjWlJBgxW4hOOd8Dgs/1lVGxLgaVRPDJgO65dSdh37db7j5Gr4 5ChQ== X-Gm-Message-State: ABy/qLbO3we4k/qfVgZOPDHbWxnsT74wmRwYGKIo4lA+hQAZFntD/lZk kjXAO4HnwXyzW+VwphyBSNyQUA== X-Google-Smtp-Source: APBJJlE/w+/yjye7GIhylAogJNc4PS5lXucEx66juInppMUgSN61sxD5rVmkUJAXcRJ/vv7548wMQw== X-Received: by 2002:a05:6870:73c9:b0:1b3:715c:463e with SMTP id a9-20020a05687073c900b001b3715c463emr12333467oan.0.1690838152095; Mon, 31 Jul 2023 14:15:52 -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 z14-20020a63b04e000000b0052c9d1533b6sm8563079pgo.56.2023.07.31.14.15.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 14:15:51 -0700 (PDT) Message-ID: Subject: Re: pgsql: Fix search_path to a safe value during maintenance operations. From: Jeff Davis To: Robert Haas , Joe Conway Cc: Tom Lane , Noah Misch , "pgsql-hackers@postgresql.org" , Nathan Bossart Date: Mon, 31 Jul 2023 14:15:49 -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 16:06 -0400, Robert Haas wrote: > if you > include in your search_path a schema to which some other user can > write, you are pretty much agreeing to execute code provided by that > user. Agreed on all counts here. I don't think it's reasonable for us to try to make such a setup secure, and I don't think users have much need for such a setup anyway. > One thing we might be able to do to prevent that sort of thing is to > have a feature to prevent "accidental" code execution, as in the > "function trust" mechanism proposed previously. Say I trust all users > who can SET ROLE to me and/or who inherit my privileges. Additionally > I can decide to trust users who do neither of those things by some > sort of explicit declaration. If I don't trust a user then if I do > anything that would cause code supplied by that user to get executed, > it just errors out: >=20 > ERROR: role "rhaas" should not execute arbitrary code provided by > role "jconway" > HINT: If this should be allowed, use the TRUST command to permit it. +1, though I'm not sure we need an extensive trust mechanism beyond what we already have with the SET ROLE privilege. > And > we probably also still need to find ways to control search_path in a > lot more widely than we do today. Otherwise, even if stuff is > technically secure, it may just not work. +1. Regards, Jeff Davis