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 1x4i6q-007KdS-0H for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Sep 2026 16:58:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x4i6o-007pTa-3D for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Sep 2026 16:58:47 +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 1x4i6o-007pTS-2N for pgsql-bugs@lists.postgresql.org; Thu, 10 Sep 2026 16:58:46 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x4i6n-00000004zVd-0X8t for pgsql-bugs@lists.postgresql.org; Thu, 10 Sep 2026 16:58:45 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 68AGwd5s914105; Thu, 10 Sep 2026 12:58:39 -0400 From: Tom Lane To: Andrey Rachitskiy cc: 1950233439@qq.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19671: IPv4 CIDR Prefix Integer Overflow Bypasses Validation in inet/cidr Casts In-reply-to: References: <19671-9b75c5d8b03fd33b@postgresql.org> Comments: In-reply-to Andrey Rachitskiy message dated "Thu, 10 Sep 2026 17:42:08 +0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <914103.1789059519.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 10 Sep 2026 12:58:39 -0400 Message-ID: <914104.1789059519@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrey Rachitskiy writes: > =D1=87=D1=82, 10 =D1=81=D0=B5=D0=BD=D1=82. 2026=E2=80=AF=D0=B3. =D0=B2 1= 7:11, PG Bug reporting form > : >> In `src/backend/utils/adt/inet_net_pton.c`, both `inet_cidr_pton_ipv4()= ` >> (lines 177=E2=80=93188) and `inet_net_pton_ipv4()` (lines 296=E2=80=933= 08) accumulate the >> CIDR prefix length digit-by-digit with no per-digit overflow guard, >> allowing >> a 32-bit signed `int bits` to wrap silently on inputs such as `42949672= 97` >> (2=C2=B3=C2=B2+1 =E2=86=92 1). > I've already encountered this problem, I just never got around to making= a > report. > Fix in attachment. In a post-scarcity world, I might be interested in fixing edge-case problems like this (and the adjacent bug reports), but as things are it's a waste of extremely limited developer time. The argument that not rejecting garbage input somehow has security consequences is laughable --- if an attacker has control over data you intend to use for security-critical purposes, they hardly need to resort to putting in syntactically-invalid values to cause trouble. I don't foresee real-world users putting in this sort of data in the first place, which explains why nobody ever noticed until they could put AI to work on finding this kind of case. regards, tom lane