Re: use-after-free in jsonb_set_lax()

From: Manu <manuelreyesbravo(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: John Naylor <johncnaylorls(at)gmail(dot)com>
Subject: Re: use-after-free in jsonb_set_lax()
Date: 2026-10-15 06:21:43
Message-ID: 179204530357.2958899.15502080119117747086@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi John,

> Please don't copy and paste LLM output into emails.

It wasn't pasted; it's a real build here. The repro and the ASan report
(with my build paths in it) are attached. It runs under an ASan build in
a couple of seconds.

The point, short: on a non-assert build this is not only a crash. The
ASan report (attached) is heap-use-after-free, READ of size 1 at a
freed address, in jsonb_set at jsonfuncs.c:4859 reached from
jsonb_set_lax at 4917. The freed read lands in the value jsonb_set
returns, so the result can carry reused heap, not just wrong data. That
is what seemed worth a line for the back-branches. v1 is clean over the
multi-row cases I ran.

Regards,
Manu

Attachment Content-Type Size
repro_asan.sql.txt text/plain 408 bytes
asan-report.txt text/plain 11.9 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message solai v 2026-10-15 06:29:00 Re: BUG #19670: Silent Integer Overflow in time_pl_interval() Returns Wrong Time Value
Previous Message Staroverov Ilja 2026-10-15 06:08:19 Re: VACUUM/ANALYZE double-count the backend's own pending table stats