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 1oabV7-0007Bx-Ue for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Sep 2022 11:33:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oabV6-0007x5-3C for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Sep 2022 11:33:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oabV5-0007wv-Ol for pgsql-hackers@lists.postgresql.org; Tue, 20 Sep 2022 11:33:15 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oabV3-0006XO-DQ for pgsql-hackers@lists.postgresql.org; Tue, 20 Sep 2022 11:33:14 +0000 Received: by mail-wm1-x331.google.com with SMTP id d12-20020a05600c3acc00b003b4c12e47f3so1439860wms.4 for ; Tue, 20 Sep 2022 04:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=CcfXi532aK4RQeG40r/QAAmXI7CAH13CUZZ2Npr+JUs=; b=Lh1WrvZ4vsJH5IL1mXXaIW9+kemaAzAZ4j0aMIXO+JpHwHQWBwlr+Ogig2zyGbhIE3 LVmcOzpF8y4giP2FJviYPZSFjfceUrjaY7+oThMF755jXENdnrcCQwCRiS9Sa9ztqRfD MtrCe/Q61Co6M4/p0V3s9VjTn5x4OSYb24k9nrnm+BSjE2TMWYHId6TFnqvmjNX9ZsiY RT/r+s1+7B5Gar3n7D6qHPeWsHTmrKoeeE9DIC8LEg9JrrXt+FJm2Rwb/nMfKc5SwbY0 BIsTgDi8p0tcR/tePVf+YggeB4GTLL52z8x8k0EcDRki4kd1EHjvaZY0pyea92GWyzhJ DYGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=CcfXi532aK4RQeG40r/QAAmXI7CAH13CUZZ2Npr+JUs=; b=1Loh0JDB3PWIpRq0DgHiVZkFz/yUlzBYA+4RCXO1jrm0PwzGDZiQbVKP8UzAUVhq7X StN976AF/QUIdYY5KWFy/08cESGkg1Rkw0rqNwXk5mVjrJM/kEut2a69HmKCTfv8g1V5 BSpoNEBmVo53oy45quNvYevr1ScR9VM05k9z8wANWM9WwM73yGGo4qKDkHTvAiL8u8KT tBX3UD9NMzTz0yu3ZgjWmztVoHwYAOoY6izcd5yius8PrwwFWN3mHLg05SNzNIDnPhQH /SxWTW9h9ltbqxob6rGLZO4k0zJhfl2CTrhlQlWbFlH4Ed2zXAvxatqMAf92KC+IkUpw d6XQ== X-Gm-Message-State: ACrzQf0uMbX8mlNeOn7Qt0004Jxso0o04iF03d6ZXQxz8KoE7Grv9TIH tsgfYxRVN+/CtjfF3yMqwZ8= X-Google-Smtp-Source: AMsMyM7sJFFh/Ok8qhTlbeBDzqavvdBuW7t8H1xSZqKoyLpWHhrcVnkV6z2K8VTA5SNOk/f88KIltw== X-Received: by 2002:a05:600c:1da8:b0:3b4:8fd6:5132 with SMTP id p40-20020a05600c1da800b003b48fd65132mr2015494wms.99.1663673591728; Tue, 20 Sep 2022 04:33:11 -0700 (PDT) Received: from [10.95.85.122] ([54.239.6.188]) by smtp.gmail.com with ESMTPSA id l16-20020a05600c1d1000b003a601a1c2f7sm19137248wms.19.2022.09.20.04.33.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Sep 2022 04:33:11 -0700 (PDT) Message-ID: Date: Tue, 20 Sep 2022 13:33:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: Patch proposal: make use of regular expressions for the username in pg_hba.conf To: Michael Paquier , Tom Lane Cc: Jacob Champion , PostgreSQL Hackers References: <4177827.1662684400@sss.pgh.pa.us> <572017.1663646973@sss.pgh.pa.us> Content-Language: en-US From: "Drouvot, Bertrand" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 9/20/22 6:30 AM, Michael Paquier wrote: > On Tue, Sep 20, 2022 at 12:09:33AM -0400, Tom Lane wrote: >> You have to assume that somebody (a) has a role or DB name starting >> with slash, (b) has an explicit reference to that name in their >> pg_hba.conf, (c) doesn't read the release notes, and (d) doesn't >> notice that things are misbehaving until after some hacker manages >> to break into their installation on the strength of the misbehaving >> entry. OK, I'll grant that the probability of (c) is depressingly >> close to unity; but each of the other steps seems quite low probability. >> All four of them happening in one installation is something I doubt >> will happen. > > It is the kind of things that could blow up as a CVE and some bad PR > for the project, so I cannot get excited about enforcing this new rule > in an authentication file (aka before a role is authenticated) while > we are talking about 3~4 code paths (?) that would need an extra check > to make sure that no instances have such object names. I also have the feeling that having (a), (b) and (d) is low probability. That said, If the user "/john" already exists and has a hba entry then this entry will still match with the patch. Problem is that all the users that contain "john" would also now match. But things get worst if say /a is an existing user and hba entry as the entry would match any users that contains "a" with the patch. I assume (maybe i should not) that if objects starting with / already exist there is very good reason(s) behind. Then I don't think that preventing their creation in the DDL would help (quite the contrary for the ones that really need them). It looks to me that adding a GUC (off by default) to enable/disable the regexp usage in the hba could be a fair compromise. It won't block any creation starting with a / and won't open more doors (if such objects exist) by default. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com