Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSPlt-0003xz-Pb for pgsql-hackers@arkaria.postgresql.org; Sun, 19 May 2019 17:38:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hSPls-0000JZ-6i for pgsql-hackers@arkaria.postgresql.org; Sun, 19 May 2019 17:38:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSPlr-0000J1-UK for pgsql-hackers@lists.postgresql.org; Sun, 19 May 2019 17:38:51 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSPlp-0005ZP-B2 for pgsql-hackers@postgresql.org; Sun, 19 May 2019 17:38:51 +0000 Received: by mail-wm1-x344.google.com with SMTP id j187so10786886wmj.1 for ; Sun, 19 May 2019 10:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=NMRGrVzGNS9uzDUIeqdE4yWGqvYobdVSlkGMXOmLvq4=; b=hX8i7xpx3CA1pxYwYVW5B4ga2JARSYajT9BalrlRL6PWnqlD0fUoVo2zqqI6i9swls dVI+7AKlR80S+0bO5j15HT7Fd67MQ/xYswsEF/28ojHkhqmgTcl9Yegt6DPQb7VO9Ki4 lxDgSrQnjmWRXwPJJGq55OKaFd9QpNS3qOGQSvG2PvnXOs63bUI+xQppUuB7VKBtmiL+ LeYce9T0kl97eO83r6AHXsMyfeEqruq291DUtpZtxGWbc8+3p4awxXJn3ndfjB7SMb+I vUkhEZSanFUVyMj5TU5H8z+/ear6xjofsO17Fmw5hyz1fZpnfTLXD5bAJX9j/t26EP4E wO7g== 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=NMRGrVzGNS9uzDUIeqdE4yWGqvYobdVSlkGMXOmLvq4=; b=ZrIJqgQoRmc7yWix7aZJN1NDtOOxOfHS0U4ZUijni83Lw+aH4CfQM4CtxuGbq+Gb5P zbPd6jSbvckm6eepwTtuZLyVzpaCRfe17BENXF5FUegxJJfEe9oZH2UzUQsOjyAm7U5n 6wCpzUBtktt+zJhDN2lCHOilZvqwQcDbxnpEvJ8gTFpCL5MSf9AbhBewPqrAELLvD2Tw 9Ol5OhGgC3M5cLedzYjnHVXP7Gx0v3Th0g8vYmnMVlBSRTW4EUt4ZK1V1tdOsdXOEFG9 CcepSVgqj1pI/ietAdF3P9SjrOUDcGq/SAmcgHXL5FEkLFX7APGk/B0Tm2CQf0smlJFe Eizg== X-Gm-Message-State: APjAAAVhlJK2LwEUUi3ozpr0Hw2CleB2rMjbh3QH9vPxOxYMjQtzDLAl 4vsfm0NxVdeJZWz/QfggQ8MQcA== X-Google-Smtp-Source: APXvYqwa5CmIIpKOmENc1GAIVOS8dudlcpEB/xmVd+aOVIonUiMwz9rZwtzRxBep4URiVsj1Sd7c6A== X-Received: by 2002:a1c:eb18:: with SMTP id j24mr8744213wmh.32.1558287527544; Sun, 19 May 2019 10:38:47 -0700 (PDT) Received: from localhost (ip-86-49-243-43.net.upcbroadband.cz. [86.49.243.43]) by smtp.gmail.com with ESMTPSA id a22sm10832560wma.41.2019.05.19.10.38.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 19 May 2019 10:38:46 -0700 (PDT) Date: Sun, 19 May 2019 19:38:45 +0200 From: Tomas Vondra To: Tom Lane Cc: Dean Rasheed , Stephen Frost , Andres Freund , PostgreSQL Hackers Subject: Re: Multivariate MCV stats can leak data to unprivileged users Message-ID: <20190519173845.tgf7ku3vigwgndn5@development> References: <4E0E0C14-C476-446A-835F-CC3558709DA9@anarazel.de> <20190518190042.2y33h4toxk4fxv5t@development> <568.1558208711@sss.pgh.pa.us> <20190518232812.qpnjmydlx3uzzsj7@development> <20866.1558223060@sss.pgh.pa.us> <20190518234841.GE6197@tamriel.snowman.net> <23229.1558275148@sss.pgh.pa.us> <23772.1558276123@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <23772.1558276123@sss.pgh.pa.us> User-Agent: NeoMutt/20180716-1444-295967-dirty List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, May 19, 2019 at 10:28:43AM -0400, Tom Lane wrote: >I wrote: >> I wonder ... another way we could potentially do this is > >> create table pg_statistic_ext_data( >> stxoid oid, -- OID of owning pg_statistic_ext entry >> stxkind char, -- what kind of data >> stxdata bytea -- the data, in some format or other >> ); > >> The advantage of this way is that we'd not have to rejigger the >> catalog's rowtype every time we think of a new kind of extended >> stats. The disadvantage is that manual inspection of the contents >> of an entry would become much harder, for lack of any convenient >> output function. > >No, wait, scratch that. We could fold the three existing types >pg_ndistinct, pg_dependencies, pg_mcv_list into one new type, say >"pg_stats_ext_data", where the actual storage would need to have an >ID field (so we'd waste a byte or two duplicating the externally >visible stxkind field inside stxdata). The output function for this >type is just a switch over the existing code. The big advantage of >this way compared to the current approach is that adding a new >ext-stats type requires *zero* work with adding new catalog entries. >Just add another switch case in pg_stats_ext_data_out() and you're >done. > The annoying thing is that this undoes the protections provided by special data types generated only in internally. It's not possible to generate e.g. pg_mcv_list values in user code (except for C code, at which points all bets are off anyway). By abandoning this and reverting to bytea anyone could craft a bytea and claim it's a statistic value. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services