Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kScQU-0006OR-NS for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Oct 2020 08:46:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kScQT-0005ll-LR for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Oct 2020 08:46:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kScQT-0005kn-71 for pgsql-hackers@lists.postgresql.org; Wed, 14 Oct 2020 08:46:25 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kScQP-00069I-9b for pgsql-hackers@lists.postgresql.org; Wed, 14 Oct 2020 08:46:24 +0000 Received: by mail-pf1-x443.google.com with SMTP id 10so1563714pfp.5 for ; Wed, 14 Oct 2020 01:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=e9Mvcpqwb4QiV49hzR/XQ9ulfPPjPXHcOpKqd1mYANE=; b=Kt9mg1DG9v6NORfk/Td27cM3k7PszDtvLe4vTSMgMbot/ocypQqIAxD7RpCVmRE9am 2t9oB+jut+z4Mk1jHSdFwtN7VGlAok4C63Dd0EDDHe/SlQFFB+2fn7NtfNFIkexpa/Uj kaZxMGgFGJ5Hny+EjGtjBEDmHK4t9GTQ2KOPM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=e9Mvcpqwb4QiV49hzR/XQ9ulfPPjPXHcOpKqd1mYANE=; b=XTl/85iMp43wjKib/caVNlIRY0WutNF3mZXlATJe0eNvz83Rz1VDJ0cKpHWHYOFdjQ +fg1n+a615MdEz9xj/5jcVMpXFOLImiMVGpNZsXTiSzWWQGCaE5Q63wVRians9vh7idR CQkeldkcYxTa1HCR8OJ3sorWUoUYNtcHtBwz2iqUNDy5gKmjMZfpB8oxIiYuwnSMLaV3 sfbwsgA6C00UoeG44saZZm8Ta6plCPbwProAocMwA2zQ/EoHq5+ZlcAr5Ha8GNjT1XT8 I0sjc3SRh3cKek3O56j+XAsUUD/zvd6NBFLC1OMsjpbRyg/Sli8ikcCsaOxM8Fl68oFF sCOQ== X-Gm-Message-State: AOAM530c2wrKDw7dY033JA0/vnBX/ddb5BXp+qiLwDQCLE2l9LM7aSWw V4+ZIQ/0FV7SR3jrcy2hHqXk8g== X-Google-Smtp-Source: ABdhPJzYineEi0Py/+CdVNeYcz4uHlh/JzN+Z68pUBgTHHW3Vn7OoowIjd6aAe0MMErEdUTy/jvJnQ== X-Received: by 2002:a65:4642:: with SMTP id k2mr2940153pgr.41.1602665178592; Wed, 14 Oct 2020 01:46:18 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::43]) by smtp.gmail.com with ESMTPSA id hg15sm1990806pjb.39.2020.10.14.01.46.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2020 01:46:17 -0700 (PDT) Date: Wed, 14 Oct 2020 01:46:15 -0700 From: Noah Misch To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Loose ends after CVE-2020-14350 (extension installation hazards) Message-ID: <20201014084615.GA1972206@rfd.leadboat.com> References: <653936.1597431032@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <653936.1597431032@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Aug 14, 2020 at 02:50:32PM -0400, Tom Lane wrote: > However, in itself this can only fix references that are resolved during > execution of the extension script. I don't see a good way to use the > idea to make earthdistance's SQL functions fully secure. It won't do > to write, say, > > CREATE FUNCTION ll_to_earth(float8, float8) > ... > AS 'SELECT @extschema(cube)@.cube(...)'; > > because this will not survive somebody doing "ALTER EXTENSION cube SET > SCHEMA schema3". I don't have a proposal for what to do about that. Another challenge is verifying that the body qualified everything. Via a simple matter of programming, CREATE EXTENSION could verify that CREATE-time code observes schema qualification rules. That would not extend to function bodies. > Admittedly, we already disclaim security if you run queries with a > search_path that contains any untrusted schemas ... but it would be > nice if extensions could be written that (in themselves) are safe > regardless. Yes. Even when safety is not a concern, it's a quality problem for the functions to error out when search_path lacks some schema. As you know, we get recurring reports about that, e.g. https://www.postgresql.org/message-id/flat/16534-69f25077c45f34a5%40postgresql.org > Peter E's proposal for parsing SQL function bodies at > creation time could perhaps fix this for SQL functions, but we still > have the issue for other PLs. Yes. The SQL-specific feature could do enough to let a future version of earthdistance be trusted. > 2. [...] lookup_agg_function() allows > inexact argument type matches for an aggregate's support functions, > so it could be possible to capture a reference if the intended support > function doesn't exactly match the aggregate's declared input and > transition data types. Should CREATE AGGREGATE support "FINALFUNC = foo(sometype)" input to constrain the lookup? (It does accept the syntax, but "sometype" is unused and need not even denote an extant type.) > 3. As Christoph Berg noted, the fixes in some extension update scripts > mean that plpgsql has to be installed while those scripts run. How > much do we care, and if we do, what should we do about it? I propose not caring at all. Since we have dump/reload of "REVOKE USAGE ON LANGUAGE plpgsql FROM PUBLIC", extensions requiring plpgsql are fine. (It could be a problem in a "superuser = false" extension, but core isn't doing those.) Even saddling plpgsql with a pin dependency would be fine. > 4. I noticed while testing that hstore--1.0--1.1.sql is completely > useless nowadays, so it might as well get dropped. It fails with a > syntax error in every still-supported server version, since "=>" is > no longer a legal operator name. There's no way to load hstore 1.0 > into a modern server because of that, either. The chance of this getting reported from the field has been dropping for several years. It's negligible now. Thanks, nm