From: Taiki Koshino <koshino@sraoss.co.jp>
To: pgpool-committers@lists.postgresql.org
Subject: pgpool: Add parse_peer_count helper and bound backend_desc array parsin
Date: Tue, 29 Sep 2026 04:44:17 +0000
Message-ID: <E1xBPhR-00000002h2I-15aW@gothos.postgresql.org> (raw)
Add parse_peer_count helper and bound backend_desc array parsing.
The wd_json_data.c parsers consume JSON payloads supplied by watchdog
peers (any TCP host that can reach wd_port; auth defeated by the
default-empty wd_authkey) and write the parsed contents into
fixed-size arrays inside palloc'd POOL_CONFIG / BackendDesc /
WdNodeInfo storage. get_pool_config_from_json() in particular copied
value->u.array.length verbatim into config->backend_desc->num_backends
without any upper bound, so a peer-supplied "backend_desc" array of
more than MAX_NUM_BACKENDS (128) entries drove the loop past the
embedded BackendInfo backend_info[MAX_NUM_BACKENDS] array, writing
attacker-controlled port and hostname bytes into adjacent heap. The
sibling parser get_pg_backend_node_status_from_json() already clamps
the same way, so this is a per-handler omission, not a structural
limit; sibling wd_nodes parsing in the same function has the same
bug and will be migrated in a follow-up patch.
Introduce a static helper
static int
parse_peer_count(const json_value *jv, const char *field,
int max_count);
that validates the value is a JSON array, reads its length, and
rejects with ereport(ERROR, ...) when the count is negative or
exceeds the caller-supplied bound. The longjmp out of the parser
matches the existing exit channel for json_get_*_value_for_key on
malformed input, so callers do not need new error-path handling.
Migrate the backend_desc loop in get_pool_config_from_json() to use
the helper, capped at MAX_NUM_BACKENDS. Replace the per-element
strncpy(... sizeof(field) - 1) with strlcpy(... sizeof(field)) so
the destination is guaranteed NUL-terminated when the peer-supplied
hostname is exactly MAX_DB_HOST_NAMELEN (254) bytes.
Reported-by: Emond Papegaaij <emond.papegaaij@topicus.nl>
Reported-by: Claude
Author: Bo Peng <pengbo@sraoss.co.jp>
CVE-2026-92869
Backpatch-through: v4.3
Branch
------
V4_3_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=c50825fbdbe9bbcd8ec07594006611d1e908b...
Modified Files
--------------
src/watchdog/wd_json_data.c | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgpool-committers@postgresql.org
Cc: koshino@sraoss.co.jp
Subject: Re: pgpool: Add parse_peer_count helper and bound backend_desc array parsin
In-Reply-To: <E1xBPhR-00000002h2I-15aW@gothos.postgresql.org>
References: <E1xBPhR-00000002h2I-15aW@gothos.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox