From 4b4d8fb47b06c6b0e43d231969e0cbf9e44cfc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 19 Nov 2021 14:13:27 +0100 Subject: [PATCH] tfa: handle incompatible challenge data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit by returning default data, in case the challenge data is not parseable. this allows a new challenge to be started for the userid in question without manual cleanup. currently this can be triggered if an ongoing challenge created with webauthn-rs 0.2.5 is stored in /run and attempted to be read post-upgrade. Reported-by: Wolfgang Bumiller Signed-off-by: Fabian Grünbichler --- pve-rs/src/tfa.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pve-rs/src/tfa.rs b/pve-rs/src/tfa.rs index e06f51e..ecc5eb0 100644 --- a/pve-rs/src/tfa.rs +++ b/pve-rs/src/tfa.rs @@ -859,13 +859,17 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess { let inner = if data.is_empty() { Default::default() } else { - serde_json::from_slice(&data).map_err(|err| { - format_err!( - "failed to parse challenge data for user {}: {}", - userid, - err - ) - })? + match serde_json::from_slice(&data) { + Ok(inner) => inner, + Err(err) => { + eprintln!( + "failed to parse challenge data for user {}: {}", + userid, + err + ); + Default::default() + }, + } }; Ok(UserChallengeData {