Skip to content

Commit 44e60b5

Browse files
Disable CTAP2 pre-flight requests for hybrid transport
1 parent 6dab92f commit 44e60b5

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

libwebauthn/src/transport/cable/channel.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ impl<'d> Channel for CableChannel<'d> {
104104
fn get_state_sender(&self) -> &mpsc::Sender<UxUpdate> {
105105
&self.tx
106106
}
107+
108+
fn supports_preflight() -> bool {
109+
// Disable pre-flight requests, as hybrid transport authenticators do not support silent requests.
110+
false
111+
}
107112
}
108113

109114
impl<'d> Ctap2AuthTokenStore for CableChannel<'d> {

libwebauthn/src/transport/channel.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ pub trait Channel: Send + Sync + Display + Ctap2AuthTokenStore {
4747

4848
async fn cbor_send(&mut self, request: &CborRequest, timeout: Duration) -> Result<(), Error>;
4949
async fn cbor_recv(&mut self, timeout: Duration) -> Result<CborResponse, Error>;
50+
51+
/// Allows channels to disable support for pre-flight requests
52+
fn supports_preflight() -> bool {
53+
true
54+
}
5055
}
5156

5257
#[derive(Debug, Clone, PartialEq, Eq)]

libwebauthn/src/webauthn.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ where
125125
let get_info_response = self.ctap2_get_info().await?;
126126
let mut ctap2_request =
127127
Ctap2MakeCredentialRequest::from_webauthn_request(op, &get_info_response)?;
128-
if let Some(exclude_list) = &op.exclude {
129-
let filtered_exclude_list =
130-
ctap2_preflight(self, exclude_list, &op.hash, &op.relying_party.id).await;
131-
ctap2_request.exclude = Some(filtered_exclude_list);
128+
if Self::supports_preflight() {
129+
if let Some(exclude_list) = &op.exclude {
130+
let filtered_exclude_list =
131+
ctap2_preflight(self, exclude_list, &op.hash, &op.relying_party.id).await;
132+
ctap2_request.exclude = Some(filtered_exclude_list);
133+
}
132134
}
133135
let response = loop {
134136
let uv_auth_used =
@@ -183,21 +185,24 @@ where
183185
let get_info_response = self.ctap2_get_info().await?;
184186
let mut ctap2_request =
185187
Ctap2GetAssertionRequest::from_webauthn_request(op, &get_info_response)?;
186-
let filtered_allow_list =
187-
ctap2_preflight(self, &op.allow, &op.hash, &op.relying_party_id).await;
188-
if filtered_allow_list.is_empty() && !op.allow.is_empty() {
189-
// We filtered out everything in preflight, meaning none of the allowed
190-
// credentials are present on this device. So we error out here
191-
// But the spec requires some form of user interaction, so we run a
192-
// dummy request, ignore the result and error out.
193-
warn!("Preflight removed all credentials from the allow-list. Sending dummy request and erroring out.");
194-
let dummy_request = Ctap2MakeCredentialRequest::dummy();
195-
self.send_state_update(UxUpdate::PresenceRequired).await;
196-
let _ = self.ctap2_make_credential(&dummy_request, op.timeout).await;
197-
return Err(Error::Ctap(CtapError::NoCredentials));
188+
189+
if Self::supports_preflight() {
190+
let filtered_allow_list =
191+
ctap2_preflight(self, &op.allow, &op.hash, &op.relying_party_id).await;
192+
if filtered_allow_list.is_empty() && !op.allow.is_empty() {
193+
// We filtered out everything in preflight, meaning none of the allowed
194+
// credentials are present on this device. So we error out here
195+
// But the spec requires some form of user interaction, so we run a
196+
// dummy request, ignore the result and error out.
197+
warn!("Preflight removed all credentials from the allow-list. Sending dummy request and erroring out.");
198+
let dummy_request = Ctap2MakeCredentialRequest::dummy();
199+
self.send_state_update(UxUpdate::PresenceRequired).await;
200+
let _ = self.ctap2_make_credential(&dummy_request, op.timeout).await;
201+
return Err(Error::Ctap(CtapError::NoCredentials));
202+
}
203+
ctap2_request.allow = filtered_allow_list;
198204
}
199205

200-
ctap2_request.allow = filtered_allow_list;
201206
let response = loop {
202207
let uv_auth_used =
203208
user_verification(self, op.user_verification, &mut ctap2_request, op.timeout)

0 commit comments

Comments
 (0)