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 1xHClb-00000002sVr-497J for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Oct 2026 04:08:31 +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 1xHCla-00000006qbC-36Su for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Oct 2026 04:08:30 +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 1xHCla-00000006qb4-23ih for pgsql-bugs@lists.postgresql.org; Thu, 15 Oct 2026 04:08:30 +0000 Received: from mail-dy1-x1334.google.com ([2607:f8b0:4864:20::1334]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xHClY-00000002BCW-0dze for pgsql-bugs@lists.postgresql.org; Thu, 15 Oct 2026 04:08:30 +0000 Received: by mail-dy1-x1334.google.com with SMTP id 5a478bee46e88-33c30fcf33fso590023eec.1 for ; Wed, 14 Oct 2026 21:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792037304; x=1792642104; darn=lists.postgresql.org; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Np25U04OEf4EcnDon35ungks34LCG2EZympC8iRUwQk=; b=NzcBTbB1BJd9irq0w2kU7rgnPe34hjXNjZp+GEko6v7lpkX5Dz+nEqUX3AtMtsDYe1 X8368rlKsXV5zhcXbKJtrptDg1qd2InsS+7tg1/2AGa6pLPTyoRH7fI1aCxPgAYvx1rt KmVR/VDbInDEwCSZAfBxdN4lRCAweoKXawlGU9s60d0BEu7NE//1DV3Ps48GY35dsLpF PRFepMagFoTYq/RRwLrK6oBLRC4SvXbqnHEe40lOCKBsUegEz/EDI2tXSAeIWQK7GzqY PVdMGxcN1kfwGYE91e2eE4VZCnGZYyUJn24OQf0JOdejXYQlXUfyIBgWIAwQGaEFlnE5 PLiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792037304; x=1792642104; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Np25U04OEf4EcnDon35ungks34LCG2EZympC8iRUwQk=; b=ORTlx6zM45NrJ2r2/PrxB6vWSjg2y87sjrRxVowGcQpC3Ol98jf+PS0RoDZQ9sNxA0 dgJDqLjWK4lQqOkEQEBlgNsJg+MzZhaeD79bMCHaNn0zMsRgDu4O/4MNpFngeL3gjjpk yC/PQxUb4Ns/Gv4HJv1MVJMI5CcOLCaRydGMrf1L0MTxEhpzS7AwwPf3G6GBsAXnt8vA udRnuQrAKIx1KEYMtxvp2PvbuNws7rbgPbygztWoRLhmRpbGBHfVJthAcHUwPMU83fRd 2w9Pi8eOX6LoILtsIdQpErB/VVOJUU5Vg06GE98MQyQIqAhtzn+x8OSmGFyKPvgKmwS8 Kmcw== X-Gm-Message-State: AFq9FYJRJbySLL1bZXe9v/C/ZCuuybjfCWnzrC00vqpWnroRm5MAHcMI CTgSM4tDTr8qd6x2QcD+4kq81F8TN+P0GyGWvS2gyjSM4+W9IuwmgafF88z/Bm+X X-Gm-Gg: AYBFou35oCUbLezwOGKG5XqTTjoSHMaTVQeLnhNG115ufdhuoyrB8RwU7pbPTJB41ZR uaOkMWHyZsbZKFu0wzPFZEd6+kBwZIyG6Sjzce7kkmx9QWOFeI8Rp//yBRVXHdoqCr7QWKOJScp XyM6a7IF9EU0NSjIxE5j44tult+wAdCRUdU9GEX+0Es7bnYSowjaOGAt5RcsGZi+WMjTo/6TCTp KkuTQ4P4Q0JyKPJz8Vj3FNA5xEzut8LfLWAEgeUTod7osYs4y3elLYe/kE4l8eEs8nfvMVV+dKW 3Bf+sbuXKUTw+qRfg63Uq/DLPwAeF7QEmpluu0tXVVM+FP3Zf5DXirRGtqWnwPMJytEntNPpM8O KPrbL+UHpbxppd4hSNs/AvtbMDTWkWvUF7zowdfBr4sU5HWuVXugLYRE3pbuus2TvEdoGEfEPOI TXvRRyBVoaqPnlS7WtJmvcrClw8tf+OPW57SICojDnVkzLXCLvCugMw2cSMcDw6jiJeFR4xTA9o jYJL7/H63xsEnyYmDWIssPzxk46n/QSosgKaOjlVQKdjX3Oa5HI5GRr9SNPX1aoXKIAOMQ47lH0 nPmqr0ws0k5tVcIoxE7+XrQ= X-Received: by 2002:a05:7022:170a:b0:143:8212:a43 with SMTP id a92af1059eb24-16a5b97d796mr34759904c88.1.1792037303328; Wed, 14 Oct 2026 21:08:23 -0700 (PDT) Received: from 192.168.1.8 ([2803:3c90:cee:ea00:5c3c:7e70:29e3:7a55]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-169a620bdafsm68263179c88.23.2026.10.14.21.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2026 21:08:22 -0700 (PDT) From: Manu To: pgsql-bugs@lists.postgresql.org Cc: John Naylor Subject: Re: use-after-free in jsonb_set_lax() Date: Thu, 15 Oct 2026 01:08:19 -0300 Message-ID: <179203729994.745011.10874872479146524148@gmail.com> In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi John, > I didn't find any other places in the code base with a similar bug, > but of course I can't be certain. I swept for siblings and found none. Of the 444 writes to fcinfo->args[] in the backend, all go into a frame the function built itself or an executor/planner frame, except 15 into a caller-supplied frame; jsonb_set_lax is the only SQL-callable one among those. Const args are written once at expression init in the expected places (ExecInitFunc, the JSON constructors). Same on 14-17. A differential multi-row vs per-row fuzz over the jsonb family (132k cases, cassert and ASan) only ever fires in jsonb_set_lax, and is clean with v1. One note on severity, in case it affects the classification: the read-after-free reaches the output, not just control flow. Under ASan the thread's repro does not crash; it silently returns {"a": null} instead of {}, since the freed null stays in the per-tuple keeper block. The 3-argument form jsonb_set_lax(col, path, NULL) over two rows returns bytes of freed memory inside the result value (on a cassert build); on a non-assert build that is reused heap, so it looks able to disclose memory contents, not only crash or return wrong data. Allocating ~5 kB per row turns it into a clean heap-use-after-free at the !PG_ARGISNULL(2) shortcut. v1 is clean on all of it. Regards, Manu