From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 1E2AA1FF187 for ; Mon, 22 Sep 2025 15:39:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B00941D06E; Mon, 22 Sep 2025 15:40:08 +0200 (CEST) From: "Max R. Carrara" To: pmg-devel@lists.proxmox.com Date: Mon, 22 Sep 2025 15:39:17 +0200 Message-ID: <20250922133935.353421-1-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1758548363192 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.087 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pmg-devel] [PATCH pmg-api master v1] pmgproxy: fix matching against potentially uninitialized value $ticket X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pmg-devel-bounces@lists.proxmox.com Sender: "pmg-devel" `$ticket` here is undef if a non-empty `Cookie` header is included in the request, but `PMGAuthCookie` isn't actually set. `extract_auth_value()` returns undef, because the match fails. Therefore, check for definedness before matching on `$ticket`. Additional Context: Ran into this during testing; as it didn't appear for all VMs, I figured that some of the VMs' IP addresses belonged to other VMs previously. After digging a little in the Firefox dev tools, it turned out that `PVEAuthCookie` is actually sent as well, confirming my suspicion. Can easily be reproduced via: `curl -k -H 'Cookie: Foo=bar' https://$HOSTNAME:8006/` Signed-off-by: Max R. Carrara --- src/PMG/Service/pmgproxy.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/PMG/Service/pmgproxy.pm b/src/PMG/Service/pmgproxy.pm index c92a3f3..de7a6c5 100644 --- a/src/PMG/Service/pmgproxy.pm +++ b/src/PMG/Service/pmgproxy.pm @@ -226,10 +226,12 @@ sub get_index { my $ticket = PVE::APIServer::Formatter::extract_auth_value($cookie, $server->{cookie_name}); - if ($ticket =~ m/^PMGQUAR:/) { - $username = PMG::Ticket::verify_quarantine_ticket($ticket, 1); - } else { - $username = PMG::Ticket::verify_ticket($ticket, undef, 1); + if (defined($ticket)) { + if ($ticket =~ m/^PMGQUAR:/) { + $username = PMG::Ticket::verify_quarantine_ticket($ticket, 1); + } else { + $username = PMG::Ticket::verify_ticket($ticket, undef, 1); + } } } else { if (defined($args->{ticket})) { -- 2.47.3 _______________________________________________ pmg-devel mailing list pmg-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel