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 1mJGrC-0007QY-3d for pgsql-general@arkaria.postgresql.org; Thu, 26 Aug 2021 14:59:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mJGrB-0002Wa-2F for pgsql-general@arkaria.postgresql.org; Thu, 26 Aug 2021 14:59:53 +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 1mJGrA-0002WR-PB for pgsql-general@lists.postgresql.org; Thu, 26 Aug 2021 14:59:52 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJGr5-0000HB-QZ for pgsql-general@lists.postgresql.org; Thu, 26 Aug 2021 14:59:52 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 92E445C013E; Thu, 26 Aug 2021 10:59:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 26 Aug 2021 10:59:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=oudfquPx4Qdbh1sRaUtQSavRoDH4n8C8laZvvzEV3 X8=; b=QIOTqtr2Pl8JJZVeSZ2jsDF47pjeBNiqMhkGbO6cg5QJt1egkOEWjLYnj 8yaIPwGXpgMUoHbQSEDZuJPE3RQQSUMAXMeMmDbo59l6kIKr3wtc357YwR8htODT M3tiQ5CumvE1RZhkTH3UCKu3mZo9p3kT9kD05H1A97HCayT8/npHlFV73ewqyvMa OgnhLUWjQca9bKFn0pwJ4JPgfEcwQqlK83xVXn6ZnIU0vZJjSNSni+KRIIWB/K4V JCouQ6TUZCpJUzOiCbj/UZhqVwYvTffmsqdwuuSNekXlr5/hcDijXLioWWJh2YtM Jg/4nQqwoTCX1UErgo4MQsg8ak4+w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudduuddgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheprfgvthgv rhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdrvghishgvnhhtrhgruhhtsegvnhhtvg hrphhrihhsvggusgdrtghomheqnecuggftrfgrthhtvghrnhepkeehieehvdegueeghfff ueeliedvgfeigffhheevvdegfefgfeetgeejudejjeehnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhdrvghishgvnhhtrhgruhht segvnhhtvghrphhrihhsvggusgdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 26 Aug 2021 10:59:42 -0400 (EDT) Subject: Re: lower() and unaccent() not leakproof To: Daniel Gustafsson Cc: "David G. Johnston" , Christophe Pettus , "pgsql-generallists.postgresql.org" References: <02BDFCCF-BDBB-4658-9717-4D95F9A91561@thebuild.com> From: Peter Eisentraut Message-ID: Date: Thu, 26 Aug 2021 16:59:40 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 26.08.21 10:40, Daniel Gustafsson wrote: >> On 26 Aug 2021, at 09:58, Peter Eisentraut wrote: >> >> On 26.08.21 06:52, David G. Johnston wrote: >>> On Wednesday, August 25, 2021, Christophe Pettus > wrote: >>> lower() and unaccent() (and most string functions) are not marked as >>> leakproof. Is this due to possible locale / character encoding >>> errors they might encounter? >>> I think you are partially correct. Its due to the fact that error messages, regardless of the root cause, result in the printing of the input value in the error message as context, thus exists a leak via a violation of “ It reveals no information about its arguments other than by its return value. ” >> >> I think if you trace the code, you might find that lower() and upper() can't really leak anything. It might be worth taking a careful look and possibly lifting this restriction. > > Wouldn’t the difference in possible error messages in upper/lower be able to > leak whether the input is ascii or wide chars, and/or the collation? Yeah, but there aren't any error messages that relate to the argument string, if you look through the code. There isn't any "could not find lower case equivalent of %s" or anything like that. Once you have found the right collation and locale and server encoding and have allocated some memory, the conversion always succeeds. The collation is not secret, it's determined by parse analysis.