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.98.2) (envelope-from ) id 1x9CPn-00000001oNZ-0sZS for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Sep 2026 02:08:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x9CPm-00000002cu9-0mgB for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Sep 2026 02:08:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x9CPl-00000002cu0-3mHy for pgsql-hackers@lists.postgresql.org; Wed, 23 Sep 2026 02:08:53 +0000 Received: from mail-pz2-x10.google.com ([2607:f8b0:4864:3b::10]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x9CPg-00000000ngh-4BG9 for pgsql-hackers@postgresql.org; Wed, 23 Sep 2026 02:08:51 +0000 Received: by mail-pz2-x10.google.com with SMTP id d2e1a72fcca58-86868f7707dso219798b3a.2 for ; Tue, 22 Sep 2026 19:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790129326; x=1790734126; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=OuVYJxhk60+uKI8xBF4zCFXdY0ZPVQdrY+Z8CGoMqFE=; b=aPGE4S9DcUsOr7jFGhCK62dO+HxcUvJcwdIuc27cUvAoLmiAGfQw1+4ZKLR8MECYGt JBt/ia8vsn6OYT+qaJnc+p2993fWae7B8fvQ3ERO4MDUDQV6HVOmeD2bRhTFOCVm+otm Ww9E2hNbIO8nCkdGtfnIVwrTBNKIuX0bTXB7qI+BK+2GcQBvYL7YrKGu9zjXESW0VpQh mBcLM6UycujtULA4Lgd5ZeTWFXAtwD8VhQqsutKipZSPieXjRG/5X9DyahMgypIkKkso GbI9Y2awLb/zk15Qsd+Zc3Iuq1zmXhZY441VtuS4qoka90jC/gMId7ApAe65FbKZCRJ2 f2dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790129326; x=1790734126; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=OuVYJxhk60+uKI8xBF4zCFXdY0ZPVQdrY+Z8CGoMqFE=; b=Lv2LZMgJ923Ac3Km4Nr45OgAP4S4DBHyzpaIP+pTM6YJ07RjoyEenKjQLx297RyJNL QfotdLr2B46Eqi/wLEEVoPtAAmEfvvbRqoEf5np+IglnR0+mYYPIRASsYa7a68m6DjWJ RuujTrIkNSCYuXUmx7jOUV3Fjgd1bNOHeyH0/2VxKqm59r6LD0vOM10KDEoXgny9Oy5N QxkqWmKwMOdOngHsMO/OdIYar16WIJ7JIMVJZJW/Zbkr3aIdtm2jIh8p1K/8j9EFTPK7 7JeFHMGaDUt03K5dn51HZTjSZbWfQVy0eJLtfsPwvk6lhGnWZgVQpuSFDKbzUL1X8L4H r7XQ== X-Gm-Message-State: AFuF++lxZXpRJv+IGYG6lVwJj4Pd0izXKRnVlWb+dSj3bVNOOfVcyH47 IAQvbm8K5hlNRfAnvMOUQNUeQBBDyLdbFIIRa2/KoBqfSNGVrxOZWM6z X-Gm-Gg: AYBFou0L0Y5zzWXCPcHfNa6AjwAT6gtJAPiwC1krdHdjbWQgvN4IRzZuxz5fnu701qv tXGQKWLAiorA+SofZV4GZRRyFuBluKUy5ncMVGiKUe6obg583bH3fsF5llDEjyNdBSKP8/pyTtv BdylzEe+F+8yR1OMlzrygYlh0MPZEXuyi7Hf3pUs0he/R6NArAaHq9uUla/RNLjsbRRouF36G7s WDzdaNNSoAwauc35O12ujozZMHFPpMH6j5CVydNrfLHQtSm9/7jBSrpJu5EO02kp6qXAZmCKjsq qVmuBhwINXEAB2yMA2NzY9gAzw0nvu+1/THIXvsD4JJK+CpuqFB4BxfEpPsI4HwmTofqUxg5XIz p7VqixvYIFBvoKcgi+sOqeYcdQ21GPPcisNrNGlK8NAR9bu0lFjLN3IGC1MCP8WJAz5RQmarO/u 3f0kCg+3A0F4FQ9sTeo5Pu7stAlw3iYSCEgPq5T5Y4BMX2cpCuvRKiJIcThSqKeXKqdo6bZmWTq UVlzu4= X-Received: by 2002:a05:6a00:928c:b0:878:34d7:697b with SMTP id d2e1a72fcca58-87d1bfb2a9fmr1218000b3a.41.1790129325601; Tue, 22 Sep 2026 19:08:45 -0700 (PDT) Received: from smtpclient.apple ([185.135.79.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-87d1cec2d34sm514040b3a.14.2026.09.22.19.08.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Sep 2026 19:08:45 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.700.51.1.1\)) Subject: Re: Adding a range check on the sequence index from the publisher. From: Chao Li In-Reply-To: Date: Wed, 23 Sep 2026 10:08:10 +0800 Cc: PostgreSQL-development , Amit Kapila Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Masahiko Sawada X-Mailer: Apple Mail (2.3864.700.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Sep 23, 2026, at 04:27, Masahiko Sawada = wrote: >=20 > On Mon, Sep 21, 2026 at 10:00=E2=80=AFPM Chao Li = wrote: >>=20 >>=20 >>=20 >>> On Sep 22, 2026, at 03:51, Masahiko Sawada = wrote: >>>=20 >>> Hi all, >>> (CCing Amit as the committer of this feature) >>>=20 >>> This was originally reported to pgsql-security by Anthropic OSS >>> program but the security team considered it as a non-vuln bug since >>> it's a v19-beta code, and I'm reporting here on behalf of them as = it's >>> permitted now. >>>=20 >>> The reported problem is in sequencesync.c; the sequence >>> synchronization worker uses an integer that came back from the >>> publisher as a list subscript without checking it, and then writes >>> through the resulting pointer. >>>=20 >>> While it's not a problem in normal cases where the publisher is a >>> normal PostgreSQL, it could lead to out-of-bounds writes when the >>> publisher is a malicious server looking like a publisher. >>>=20 >>> Other fields that we get through get_and_validate_seq_info() could >>> also get the wrong value but they just show the wrong values rather >>> than OOB writes. So I think we need a safeguard only for seqidx. >>>=20 >>> I've attached the patch to fix it. Feedback is very welcome. >>>=20 >>> Regards, >>>=20 >>> -- >>> Masahiko Sawada >>> Amazon Web Services: https://aws.amazon.com >>> >>=20 >> If the concern here is a malicious publisher, does it also make sense = to replace Assert(!isnull) with a runtime check and fail if seqidx is = NULL? >=20 > I don't think we need it from a security perspective. Even if a > malicious publisher returns NULL as seqidx, a garbage value is stored > to *seqidx and will fail the new range check. >=20 If a malicious publisher returns NULL for seqidx, the resulting *seqidx = will likely be 0. Since 0 passes the range check, the first sequence = could be silently selected, which might be incorrect. On second thought, however, a malicious publisher could directly return = a valid but incorrect seqidx, and we do not seem to have a way to = protect against that. =46rom this perspective, checking isnull would not = help much. But from another perspective, an Assert is normally used for an internal = invariant. Here, however, seqidx is received from external, so a runtime = check seems more reasonable. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/