From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id D10651FF179 for ; Wed, 15 Oct 2025 16:22:55 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C3E2F1DB2A; Wed, 15 Oct 2025 16:23:13 +0200 (CEST) From: Dominik Csapak To: pmg-devel@lists.proxmox.com Date: Wed, 15 Oct 2025 16:22:58 +0200 Message-ID: <20251015142310.3633830-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251015142310.3633830-1-d.csapak@proxmox.com> References: <20251015142310.3633830-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 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 proxmox 1/1] login: fix userid check for '@quarantine' user tickets 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" when logging into the pmg quarantine via LDAP, the user typically enters a userid like 'foo@bar.com'. When receiving a valid ticket, this contains a userid like 'foo@bar.com@quarantine'. To check if that's correct, use our helper instead of manually checking for equality. That helper also needs fixing: while it should be (optionally) possible to enter the username with 'foo@bar.com@quarantine' (so we have to strip the quarantine part from the expected userid), we also have to strip the '@quarantine' part from the ticket response, since it contains that too. Signed-off-by: Dominik Csapak --- proxmox-login/src/lib.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/proxmox-login/src/lib.rs b/proxmox-login/src/lib.rs index 4b2869a7..c67cd70b 100644 --- a/proxmox-login/src/lib.rs +++ b/proxmox-login/src/lib.rs @@ -58,7 +58,9 @@ fn normalize_url(mut api_url: String) -> String { } fn check_ticket_userid(ticket_userid: &str, expected_userid: &str) -> Result<(), ResponseError> { - if ticket_userid != expected_userid.trim_end_matches("@quarantine") { + if ticket_userid.trim_end_matches("@quarantine") + != expected_userid.trim_end_matches("@quarantine") + { return Err("returned ticket contained unexpected userid".into()); } Ok(()) @@ -186,9 +188,7 @@ impl Login { let response: api::ApiResponse = serde_json::from_slice(body)?; let response = response.data.ok_or("missing response data")?; - if response.username != self.userid { - return Err("ticket response contained unexpected userid".into()); - } + check_ticket_userid(&response.username, &self.userid)?; // if a ticket was provided via a cookie, use it like a normal ticket if let Some(ticket) = cookie_ticket { @@ -380,9 +380,7 @@ impl SecondFactorChallenge { let response: api::ApiResponse = serde_json::from_slice(body)?; let response = response.data.ok_or("missing response data")?; - if response.username != self.userid { - return Err("ticket response contained unexpected userid".into()); - } + check_ticket_userid(&response.username, &self.userid)?; // get the ticket from: // 1. the cookie if possible -> new HttpOnly authentication outside of the browser -- 2.47.3 _______________________________________________ pmg-devel mailing list pmg-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel