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 1kKmW3-0001rW-7y for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Sep 2020 17:55:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kKmW0-00012j-TJ for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Sep 2020 17:55:44 +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 1kKmW0-00011f-J6 for pgsql-hackers@lists.postgresql.org; Tue, 22 Sep 2020 17:55:44 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kKmVw-0004H2-JC for pgsql-hackers@postgresql.org; Tue, 22 Sep 2020 17:55:43 +0000 Received: by mail-pg1-x542.google.com with SMTP id y14so2519350pgf.12 for ; Tue, 22 Sep 2020 10:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=NldYYVR3HCA6KNC3l75rSkG/aYbQcF3keDN92ehjgy4=; b=tGeK3UOCkUg8Zqg2dHbcBRJyBeuiF4bKh47wMfG9RzEJzzVgnG5mB/Mbc5vX97lKwM 51iY4VSiHXyaRugB6AQtPkzM+gGMAB46JdE7m7x+e3nBBTsP7mAfpVGGMnscdYV3RKno /djFIfh0oaTHgyi+1isj0qM8uH/CJMzvde3Y+kiFAnuNyrE0cKrYWg3SEdCNiAcXmpvT d8/ujxaLw/fRpIHV33W0MpHdkmOIjdgRQgH3nK6HyookR8CLwjDIKT/DekgS9ADpIiCX 9CRcmNTFrjPBymNutz4Mujnx8vtv7KbjSEIo1AgG7dmaT92I6B1ipZbj2YDk9mxodTlu GeNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=NldYYVR3HCA6KNC3l75rSkG/aYbQcF3keDN92ehjgy4=; b=g4rjAdkYurIWny66EyQo+kO0NfbQsde6yWx37ujsgF6Xzi7wpyKzFnhi2TCG28yE3s UZ6MCNKcf+HpUpZHI+IbQoAi+7ZcMSOnoYf/zvOfN6q3aRp9v/PXv/t1J8X3+CKdfp9+ bCvH/tpHJtcSqaN6ywODLe4ZT1msZ9kdU9UdYgcdHIyY8MdcDIee/qIEpW415AEhOCZJ 6d+P/LfcR14sm3SXz4QYmKLU9lb4TzN1zjHtg18MlZ7GB53rXmZuA/mvc1Fuu/7fhO3z qpH4IF+SUorpEWQj2P6fzFea5Nv7T74OgUhE0aQQWGh2iV+WwkVXC3CioaTJ7gk0HRpA cmSg== X-Gm-Message-State: AOAM531If1EbaMXx2E1Ct8ivBaTAS44MTgZCwlk8ypwnunWtqyJuje5R G7jWSEq6GNf5AwrU4sipoYh2AxvAHjmT0hlowfRjQwTRGmAAQzG44kdBMQNlOcHN4UjHKqJis6o dbi5NYO+ur4k7elRiHvDVdpfaWZSAmmqL5g2JB7RIx2FsjCgBjiOG9i9Fp62mPv/v7chbz1Mevc ehHF9s7KreK+M4v+DPn5jJ6cIV9HYdzBAXovyu X-Google-Smtp-Source: ABdhPJx0qqQfwYxv/5Nebk0abSAP+UIE2LXWpHTKhcyWanisZOTmF3G9UD08ze6TXkcRU2vVF1OObg== X-Received: by 2002:a17:902:8d8f:b029:d0:cc02:8527 with SMTP id v15-20020a1709028d8fb02900d0cc028527mr5851544plo.33.1600797336975; Tue, 22 Sep 2020 10:55:36 -0700 (PDT) Received: from [192.168.0.29] (24-113-193-150.wavecable.com. [24.113.193.150]) by smtp.gmail.com with ESMTPSA id i16sm3375881pjv.0.2020.09.22.10.55.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Sep 2020 10:55:36 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: new heapcheck contrib module From: Mark Dilger In-Reply-To: Date: Tue, 22 Sep 2020 10:55:35 -0700 Cc: Amul Sul , Dilip Kumar , Peter Geoghegan , Andres Freund , PostgreSQL-development Content-Transfer-Encoding: quoted-printable Message-Id: <107F3C9D-2598-4E77-A4D0-0084BD3CBA30@enterprisedb.com> References: <12ED3DA8-25F0-4B68-937D-D907CFBF08E7@enterprisedb.com> <20200420194210.sevnpi4lyghoanxi@alap3.anarazel.de> <23E60C3C-C20A-4508-84AC-E0CEA59E784A@enterprisedb.com> <5F743835-3399-419C-8324-2D424237E999@enterprisedb.com> <885D2EC9-7D06-4903-A17D-72C184A1E1C5@enterprisedb.com> <5CC85F28-F210-47AC-8DA8-EC4E82AF3FD5@enterprisedb.com> <0C0349EB-DD85-4DA8-82C7-DF70AB714592@enterprisedb.com> <9DF93B83-FE46-4EC4-A99D-77A60729FD2D@enterprisedb.com> <50F6468F-5A5E-412A-86EC-DF24B549D733@enterprisedb.com> <7D603B53-8078-4AF0-851B-803FF4416501@enterprisedb.com> To: Robert Haas X-Mailer: Apple Mail (2.3608.120.23.2.1) X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Sep 21, 2020, at 2:09 PM, Robert Haas = wrote: >=20 > I think there should be a call to pg_class_aclcheck() here, just like > the one in pg_prewarm, so that if the superuser does choose to grant > access, users given access can check tables they anyway have > permission to access, but not others. Maybe put that in > check_relation_relkind_and_relam() and rename it. Might want to look > at the pg_surgery precedent, too.=20 In the presence of corruption, verify_heapam() reports to the user (in = other words, leaks) metadata about the corrupted rows. Reasoning about = the attack vectors this creates is hard, but a conservative approach is = to assume that an attacker can cause corruption in order to benefit from = the leakage, and make sure the leakage does not violate any reasonable = security expectations. Basing the security decision on whether the user has access to read the = table seems insufficient, as it ignores row level security. Perhaps = that is ok if row level security is not enabled for the table or if the = user has been granted BYPASSRLS. There is another problem, though. = There is no grantable privilege to read dead rows. In the case of = corruption, verify_heapam() may well report metadata about dead rows. pg_surgery also appears to leak information about dead rows. Owners of = tables can probe whether supplied TIDs refer to dead rows. If a table = containing sensitive information has rows deleted prior to ownership = being transferred, the new owner of the table could probe each page of = deleted data to determine something of the content that was there. = Information about the number of deleted rows is already available = through the pg_stat_* views, but those views don't give such a = fine-grained approach to figuring out how large each deleted row was. = For a table with fixed content options, the content can sometimes be = completely inferred from the length of the row. (Consider a table with = a single text column containing either "approved" or "denied".) But pg_surgery is understood to be a collection of sharp tools only to = be used under fairly exceptional conditions. amcheck, on the other = hand, is something that feels safer and more reasonable to use on a = regular basis, perhaps from a cron job executed by a less trusted user. = Forcing the user to be superuser makes it clearer that this feeling of = safety is not justified. I am inclined to just restrict verify_heapam() to superusers and be = done. What do you think? =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company