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 1hSUYR-0002vj-4j for pgsql-hackers@arkaria.postgresql.org; Sun, 19 May 2019 22:45:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hSUYN-0008QL-Eo for pgsql-hackers@arkaria.postgresql.org; Sun, 19 May 2019 22:45:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSUYN-0008QD-35 for pgsql-hackers@lists.postgresql.org; Sun, 19 May 2019 22:45:15 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSUYK-0008UT-B6 for pgsql-hackers@postgresql.org; Sun, 19 May 2019 22:45:13 +0000 Received: by mail-wr1-x443.google.com with SMTP id f8so6074092wrt.1 for ; Sun, 19 May 2019 15:45:11 -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=Gblvz4zQJ2ADz4CG6QmMnGQssDQbgkkAbgA0vNy4Joc=; b=GZh3P6wxpsBqRc8x9e3NjsNVL2jpx6uLclZNxSnurD0R66plQXAzNuA1LXXt+C8s5B J+3uCcjqKcmrmuLIsQnw1Aeag6urWkTT2CqxeT861RmvnloySe8xhpWBWzBnrerXgjoR 4Q4UHVoa/4FK4bvQXdPw8IS8MQh2LUpkbtxiNw+doeJz2No2JwSCVwn27jYOf8ZFVoJn JyfyyjI3SZQOnf8KPWtblCum7eszo1xGdT8GEsiVsLII9L1TjttZTkKbtjtIyaAHsL4I v0u2EfiPUNvo1VBbrfr6jyK6WGWmZwesswAPAhVwrsANcq6KoSpuN7DXrOZ8EKrrnbwf +aMA== 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=Gblvz4zQJ2ADz4CG6QmMnGQssDQbgkkAbgA0vNy4Joc=; b=WNcdx87fB5UQ71tFeRZe3fA4ALbMH1NxnwpJuwRtf3ZpV3MAQgI+KdV/PlbNaD+yNH wAhJTBS64v1XbFkzV0G/4TZMMRg2Sf8lg6/GSsgYdsEbW50xoHvuJrlLvkO1MFNnYxyx 4A41IjRPlL25ns9DiCM5999BhRJok3RRqJy6samohLA1A6iwihzUws7MzYs1jDGQhBYm 6a2TISEk2Orj5cqoWcKB1FBH26pkFHQOrf1Q7dkd6iGBcTvyDVypMU/i+lTIwxPt+ZlY ud2yRCfrFsGCZyRVN4czAKITpHhnOqMOfAUYwDba0yMr5dSZm0Qmp6DgPqIPw9+jXp89 EDrw== X-Gm-Message-State: APjAAAVxFWUvHY0htzfsm08S0dYE0XMBHcDjloCTQlyTtTsjWTI637aa CYQeTwtUtKYfsoIkQyBuVyvetg== X-Google-Smtp-Source: APXvYqzkc3F7YuCfRMM/FE1fSWP9yeSVDdPttp+ZZqXQZcdCguAyxMsHIho1nAbJCNeECd0k8SMLfQ== X-Received: by 2002:adf:82b2:: with SMTP id 47mr19066143wrc.76.1558305909839; Sun, 19 May 2019 15:45:09 -0700 (PDT) Received: from localhost (ip-86-49-243-43.net.upcbroadband.cz. [86.49.243.43]) by smtp.gmail.com with ESMTPSA id f11sm11958732wrv.93.2019.05.19.15.45.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 19 May 2019 15:45:00 -0700 (PDT) Date: Mon, 20 May 2019 00:44:59 +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: <20190519224459.7dsdnv5gsfmnm4em@development> References: <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> <20190519173845.tgf7ku3vigwgndn5@development> <2509.1558289694@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <2509.1558289694@sss.pgh.pa.us> User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, May 19, 2019 at 02:14:54PM -0400, Tom Lane wrote: >Tomas Vondra writes: >> On Sun, May 19, 2019 at 10:28:43AM -0400, Tom Lane wrote: >>> 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. > >That would have been true of the original proposal, but not of this >modified one. > Oh, right. It still has the disadvantage that it obfuscates the actual data stored in the pg_stats_ext_data (or whatever would it be called), so e.g. functions would have to do additional checks to make sure it actually is the right statistic type. For example pg_mcv_list_items() could not rely on receiving pg_mcv_list values, as per the signature, but would have to check the value. Of course, I don't expect to have too many such functions, but overall this approach with a single type feels a bit too like EAV to my taste. I think Dean is right we should not expect many more statistic types than what we already have - a histogram, and perhaps one or two more. So I agree with Dean the current design with separate statistic types is not such a big issue. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services