Skip to content

Prevent panic in bitwarden-fido crate #346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion crates/bitwarden-fido/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@

#[error("No Fido2 credentials found")]
NoFido2CredentialsFound,

#[error("Invalid counter")]
InvalidCounter,
}

impl TryFrom<CipherViewContainer> for Passkey {
Expand All @@ -107,7 +110,10 @@
}

fn try_from_credential_full_view(value: Fido2CredentialFullView) -> Result<Passkey, Fido2Error> {
let counter: u32 = value.counter.parse().expect("Invalid counter");
let counter: u32 = value
.counter
.parse()
.map_err(|_| Fido2Error::InvalidCounter)?;

Check warning on line 116 in crates/bitwarden-fido/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-fido/src/lib.rs#L113-L116

Added lines #L113 - L116 were not covered by tests
let counter = (counter != 0).then_some(counter);
let key_value = URL_SAFE_NO_PAD.decode(value.key_value)?;
let user_handle = value
Expand Down
Loading