From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id D06AA1FF0AB for ; Wed, 09 Sep 2026 14:03:18 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A9C20215D3; Wed, 09 Sep 2026 14:03:15 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Subject: [PATCH http-server 1/2] fix #8021: websocket: check length of close payload Date: Wed, 9 Sep 2026 14:03:05 +0200 Message-ID: <20260909120309.432116-1-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1788955382349 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.320 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: LR5TIOEW5MXRMKMEDLMIX2HQBP7A5JO5 X-Message-ID-Hash: LR5TIOEW5MXRMKMEDLMIX2HQBP7A5JO5 X-MailFrom: f.gruenbichler@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: before unpacking the contained status code, otherwise the debug log might print a warning. Signed-off-by: Fabian Grünbichler --- src/PVE/APIServer/AnyEvent.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm index 915d678..12701aa 100644 --- a/src/PVE/APIServer/AnyEvent.pm +++ b/src/PVE/APIServer/AnyEvent.pm @@ -674,8 +674,12 @@ sub websocket_proxy { if ($opcode == 1 || $opcode == 2) { $reqstate->{proxyhdl}->push_write($payload) if $reqstate->{proxyhdl}; } elsif ($opcode == 8) { - my $statuscode = unpack("n", $payload); - $self->dprint("websocket received close. status code: '$statuscode'"); + if ($payload_len < 2) { + $self->dprint("websocket received close with too short payload: $payload_len"); + } else { + my $statuscode = unpack("n", $payload); + $self->dprint("websocket received close. status code: '$statuscode'"); + } if (my $proxyhdl = $reqstate->{proxyhdl}) { $proxyhdl->{block_disconnect} = 1 if length $proxyhdl->{wbuf}; -- 2.47.3