From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 0AC4E7F31C for ; Fri, 12 Nov 2021 09:58:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F2E29164AE for ; Fri, 12 Nov 2021 09:58:15 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 4D12B164A4 for ; Fri, 12 Nov 2021 09:58:15 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 227C6436AE for ; Fri, 12 Nov 2021 09:58:15 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Fri, 12 Nov 2021 09:58:14 +0100 Message-Id: <20211112085814.1643605-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211112085814.1643605-1-d.csapak@proxmox.com> References: <20211112085814.1643605-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.221 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [mod.rs] Subject: [pve-devel] [PATCH proxmox-perl-rs 2/2] pve-rs/tfa: ignore and discard incomplete u2f entries X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Nov 2021 08:58:46 -0000 it can happen that we have leftover entries with non-completed challenges. since a user cannot continue here in a sensible way, ignore and discard them Signed-off-by: Dominik Csapak --- pve-rs/src/tfa/mod.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pve-rs/src/tfa/mod.rs b/pve-rs/src/tfa/mod.rs index 44cec74..d91278d 100644 --- a/pve-rs/src/tfa/mod.rs +++ b/pve-rs/src/tfa/mod.rs @@ -490,10 +490,13 @@ fn decode_old_entry(ty: &[u8], data: &[u8], user: &str) -> Result user_data.u2f.push(proxmox_tfa_api::TfaEntry::from_parts( - info, - decode_old_u2f_entry(value)?, - )), + b"u2f" => { + if let Some(entry) = decode_old_u2f_entry(value)? { + user_data + .u2f + .push(proxmox_tfa_api::TfaEntry::from_parts(info, entry)) + } + } b"oath" => user_data.totp.extend( decode_old_oath_entry(value, user)? .into_iter() @@ -513,12 +516,17 @@ fn decode_old_entry(ty: &[u8], data: &[u8], user: &str) -> Result Result { +fn decode_old_u2f_entry(data: JsonValue) -> Result, Error> { let mut obj = match data { JsonValue::Object(obj) => obj, _ => bail!("bad json type for u2f registration"), }; + // discard old partial u2f registrations + if obj.get("challenge").is_some() { + return Ok(None); + } + let reg = proxmox_tfa::u2f::Registration { key: proxmox_tfa::u2f::RegisteredKey { key_handle: base64::decode_config( @@ -538,7 +546,7 @@ fn decode_old_u2f_entry(data: JsonValue) -> Result