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:44:17
Message-ID: E1xBPhR-00000002h2O-1AWZ@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_3_STABLE

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

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:47:05 pgpool: Bound wd_nodes JSON array parsing in get_pool_config_from_json.
Previous Message Taiki Koshino 2026-09-29 04:43:57 pgpool: Fix operator precedence in parse_wd_node_function_json NodeIdLi