pgpool: Reject node count larger than MAX_NUM_BACKENDS in parse_wd_node

From: Taiki Koshino <koshino(at)sraoss(dot)co(dot)jp>
To: pgpool-committers(at)lists(dot)postgresql(dot)org
Subject: pgpool: Reject node count larger than MAX_NUM_BACKENDS in parse_wd_node
Date: 2026-09-29 04:43:11
Message-ID: E1xBPgN-00000002gHK-2nQd@gothos.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-committers

Reject node count larger than MAX_NUM_BACKENDS in parse_wd_node_function_json.

parse_wd_node_function_json() in src/watchdog/wd_json_data.c parses a
peer-supplied NodeCount and a NodeIdList array out of a watchdog JSON
message and palloc()s an int array of node_count entries to populate.
The downstream consumer degenerate_backend_set_ex() in
src/main/pool_internal_comms.c declares

int node_id[MAX_NUM_BACKENDS];

(128 ints, 512 bytes) on the stack and copies up to node_count entries
into it. A peer that sets NodeCount above MAX_NUM_BACKENDS therefore
writes past the stack buffer in the failover-command path, which is
reachable from WD_IPC_FAILOVER_COMMAND and wd_authkey is not set.

Bound node_count at the parser, before the palloc, so an out-of-range
value is rejected via ereport(ERROR) and never reaches the downstream
fixed-size stack array.

Reported-by: Emond Papegaaij <emond(dot)papegaaij(at)topicus(dot)nl>
Reported-by: Claude
Author: Tatsuo Ishii <ishii(at)postgresql(dot)org>
CVE-2026-92870
Backpatch-through: v4.3

Branch
------
V4_6_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=6928aca758a52fd30ed9eaf1928e1c5d7139dc89

Modified Files
--------------
src/watchdog/wd_json_data.c | 7 +++++++
1 file changed, 7 insertions(+)

Browse pgpool-committers by date

  From Date Subject
Next Message Taiki Koshino 2026-09-29 04:43:39 pgpool: Add parse_peer_count helper and bound backend_desc array parsin
Previous Message Taiki Koshino 2026-09-29 04:41:29 pgpool: Reject client certificate CN containing embedded NUL byte.