Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wqrjb-0000bV-24 for pgsql-bugs@arkaria.postgresql.org; Mon, 03 Aug 2026 12:25:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wqrCl-005xuB-0V for pgsql-bugs@arkaria.postgresql.org; Mon, 03 Aug 2026 11:51:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wqmfb-004WWa-1U for pgsql-bugs@lists.postgresql.org; Mon, 03 Aug 2026 07:01:07 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wqmfZ-00000001f51-0kC9 for pgsql-bugs@lists.postgresql.org; Mon, 03 Aug 2026 07:01:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=ixM4OcjlTRRl3/QFelqMt7fnBWT2Y9wyPyf2TiH8TPw=; b=UajCor2FZFOLzG5sKlU91vs/h6 /hd3CphNPR5nPf8fW+h7NlXp56iq/FSd7TobPyzZc9tOkVSYdePyYk5BcLmzhO5+8csr8c8QR9NNr 9adY+qK+Uvh+37XsvP5wkjBusPa1hdIaZVOL+CCi8zPfufZm99tZHCdEAUnMfQUCyrXwsTIwkF4Xb xQYUY3jjDBuo+4gUlKrOgBQ8rWh9YjZZX5TQOW8LeI5qCnUJaLrCRcNirvCSCGmD1BMJJZQJVsJCq W6VKQqXNklzqeyB7LP7C1Ck/NMWXWTQa4FIxM/Tqy0jWnJuM8Y7BV4wN/xWq6V5ARPYJa1luhF5Zw aciw8L6w==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wqmfY-000rky-0X for pgsql-bugs@lists.postgresql.org; Mon, 03 Aug 2026 07:01:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1wqmfX-0000000CCXf-37K1 for pgsql-bugs@lists.postgresql.org; Mon, 03 Aug 2026 07:01:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19603: Vuln47: distance_taxicab and distance_chebyshev silently return 0 instead of NaN when a cube coordin To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: 1217816127@qq.com Reply-To: 1217816127@qq.com, pgsql-bugs@lists.postgresql.org Date: Mon, 03 Aug 2026 07:00:47 +0000 Message-ID: <19603-7b1f783d5bbfe791@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19603 Logged by: Yuelin Wang Email address: 1217816127@qq.com PostgreSQL version: 19beta2 Operating system: Linux (Ubuntu 24.04, x86_64) Description: =20 ### Summary The static helper distance_1D() in contrib/cube/cube.c classifies two intervals as "left of", "right of", or "intersecting" using direct floating point comparisons. When a coordinate is NaN, every comparison evaluates to false, so the interval falls through to the intersecting branch and the function returns 0.0 instead of NaN. distance_taxicab and distance_chebyshev call distance_1D per dimension and sum or max the results, so a single NaN coordinate silently produces a finite, plausible-looking distance instead of propagating NaN as IEEE 754 arithmetic normally would. CWE: CWE-1339. Severity: Low. ### PoC ```sql CREATE EXTENSION cube; SELECT distance_chebyshev('(nan,nan)'::cube, '(1,1)'::cube); SELECT distance_chebyshev('(5,5)'::cube, '(1,nan)'::cube); SELECT distance_taxicab('(nan)'::cube, '(1)'::cube); ``` ### Result Real captured output from the independent verification run: ``` CREATE EXTENSION distance_chebyshev -------------------- 0 (1 row) distance_chebyshev -------------------- 4 (1 row) distance_taxicab ------------------ 0 (1 row) ``` ### Impact A database user who stores or queries cube values containing NaN coordinates can get silently wrong distance results (e.g. 0 instead of NaN) from distance_taxicab and distance_chebyshev, which can corrupt nearest-neighbor search results, ranking, or KNN-index-backed queries that rely on these operators.