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 1pbrl2-0004yf-V7 for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Mar 2023 23:39:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pbrl1-0006uy-PC for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Mar 2023 23:39:11 +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 1pbrl1-0006uo-Bh for pgsql-hackers@lists.postgresql.org; Mon, 13 Mar 2023 23:39:11 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pbrkx-0001yn-CQ for pgsql-hackers@postgresql.org; Mon, 13 Mar 2023 23:39:10 +0000 Received: by mail-pl1-x629.google.com with SMTP id v21so4630154ple.9 for ; Mon, 13 Mar 2023 16:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20210112.gappssmtp.com; s=20210112; t=1678750746; h=mime-version:user-agent:content-transfer-encoding:date:to:from :subject:message-id:from:to:cc:subject:date:message-id:reply-to; bh=O9kK/7o8lsdNyQ067pa7EEVbtGEo+R8Huwd2Son3Edc=; b=ZvdGiy+WSZx39rQivL3S0js+NtTLRLunAfGVhcQIgpHBN+k59Q9j5cioRVxaq8g9Sf XzwsYanlnJYQQtDY/6tpVs4CzyBgObsdAYKZZDhBnpBeTr7Me8nw2aEymGRA5V96MlPE huWWVKL7L4rPzY25cnXaxm7J9hvtphNZK8xeRDdl1IGE86op3/7/SgEbizdUYWOocK4c XlY1421M8pDeh5+MDc3K/Mjgq7oB68bZdkg36cKIbXQ+6MeGnwqBMc93QzD50rWIoBiL bEECqoHa/KlmIpG3HPmvpUqnX8otyxHE8/p/jvpPOJpgwzCgkItr3pKHdfU98UOPZlrS E0rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678750746; h=mime-version:user-agent:content-transfer-encoding:date:to:from :subject:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=O9kK/7o8lsdNyQ067pa7EEVbtGEo+R8Huwd2Son3Edc=; b=I6ZCEqVINUmHQHhnVamiXlNAPyCuRHCJ6/qTWY54Uq9vH5XeqBMktF40a40ql4aEyF 7P8nlAOriNYoIyrqfrb1uJJk7QnOOAySVA8jhWPj+z+HWPJYCbX5xy5CL/XdF6NJ15KV wMJQWdY+t0YKbNEzMJybHpHDTRT8hPuvaVVAMsdJmhHy5rvQjoUpfOxxina6HZLaTzus dzgTGTSzFNabpr6qXTNLmNfk13DhuyaBsPKjSiteunHBmneiTD2U6yK7zyoWBwwoEkSo y1nOM5vnahtnGLFGpKWkxktfXbLZkaVebLA+wMk01Adi7gT+aK+tV3fkzT7fCS/sDUOZ uxOw== X-Gm-Message-State: AO0yUKX03bXXCa6Y3PU3sV9z7vLj+xQ1qz4g3RGq53HMcks8F7Bh8J0I MNodF/oHRksI5kxxxp5BpTjk8CIKBLZjECd2+SA= X-Google-Smtp-Source: AK7set/67I0GSjDAI3OzwsvOZYO4POxEPYKHopXyjjmAX89fajk3jtg+MubQq9YFW3sANixlt9UH1Q== X-Received: by 2002:a17:90b:4c50:b0:234:d3a:2a38 with SMTP id np16-20020a17090b4c5000b002340d3a2a38mr36781015pjb.43.1678750746107; Mon, 13 Mar 2023 16:39:06 -0700 (PDT) Received: from jeff-laptop.lan (c-73-231-146-4.hsd1.ca.comcast.net. [73.231.146.4]) by smtp.gmail.com with ESMTPSA id 6-20020a170902c24600b00198f36a8941sm362876plg.221.2023.03.13.16.39.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Mar 2023 16:39:05 -0700 (PDT) Message-ID: Subject: ICU 54 and earlier are too dangerous From: Jeff Davis To: pgsql-hackers@postgresql.org Date: Mon, 13 Mar 2023 16:39:04 -0700 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk In ICU 54 and earlier, if ucol_open() is unable to find a matching locale, it will fall back to the *environment*. Using ICU 54: initdb -D data -N --locale=3D"en_US.UTF-8" pg_ctl -D data -l logfile start psql postgres -c "create collation asdf(provider=3Dicu, locale=3D'asdf')" # returns true psql postgres -c "select 'abc' collate asdf < 'ABC' collate asdf" psql postgres -c "alter system set lc_messages=3D'C'" pg_ctl -D data -l logfile restart # returns false and warns about collation version mismatch psql postgres -c "select 'abc' collate asdf < 'ABC' collate asdf" This was fixed in ICU 55 to fall back to the root locale instead[1], which is stable, has a collator version, and is not dependent on the environment. As far as I can tell, 55 and later never fall back to the environment when opening a collator (unless you explicitly pass NULL to ucol_open(), which is documented). It would be nice if we could detect when this fallback-to-environment happens, so that we could just refuse to create the bogus collation. But I didn't find a good way. There are non-error return codes from ucol_open() that seem promising[2], but they aren't actually very useful to distinguish the fallback-to-environment case as far as I can tell. Unless someone has a better idea, I think we need to bump the minimum required ICU version to 55. That would solve the issue in v16 and later, but those using old versions of ICU and old versions of postgres would still be vulnerable to these kinds of typos. Regards, Jeff Davis [1] https://icu.unicode.org/download/55m1 [2] https://unicode-org.github.io/icu-docs/apidoc/dev/icu4c/utypes_8h.html#a334= 3c1c8a8377277046774691c98d78c