Skip to content
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

Add support for WebAuthn PRF extension #337

Merged
merged 42 commits into from
Jul 25, 2024

Conversation

emlun
Copy link
Contributor

@emlun emlun commented Jun 13, 2024

@jschanck jschanck self-requested a review June 14, 2024 23:02
Copy link
Collaborator

@jschanck jschanck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, Emil! My only question is whether we need to do a better job of filtering the allow-list before calling AuthenticationExtensionsPRFInputs::calculate. The spec says

If evalByCredential is present and contains an entry whose key is the base64url encoding of the credential ID that will be returned, let ev be the value of that entry.

The use of the definite article in "the credential ID that will be returned" makes me think that we should filter down to an allow-list of length 1. Wdyt?

src/ctap2/attestation.rs Show resolved Hide resolved
src/ctap2/attestation.rs Outdated Show resolved Hide resolved
src/ctap2/commands/get_assertion.rs Outdated Show resolved Hide resolved
src/ctap2/mod.rs Outdated Show resolved Hide resolved
src/ctap2/commands/get_assertion.rs Outdated Show resolved Hide resolved
src/ctap2/server.rs Outdated Show resolved Hide resolved
src/ctap2/commands/get_assertion.rs Outdated Show resolved Hide resolved
src/ctap2/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@msirringhaus msirringhaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked too deeply at 'the meat' of the PR, but only added a few nitpicks.

src/crypto/mod.rs Outdated Show resolved Hide resolved
src/ctap2/attestation.rs Outdated Show resolved Hide resolved
src/ctap2/commands/get_assertion.rs Outdated Show resolved Hide resolved
src/ctap2/server.rs Show resolved Hide resolved
src/ctap2/attestation.rs Outdated Show resolved Hide resolved
@emlun
Copy link
Contributor Author

emlun commented Jul 8, 2024

Thanks @jschanck and @msirringhaus for the reviews! I believe I've addressed them all now, and I also noticed a few more things while self-reviewing the new code. While awaiting your re-reviews I'll proceed with testing re-integrating these changes into the Firefox branch.

@emlun emlun requested review from jschanck and msirringhaus July 8, 2024 16:05
emlun added 10 commits July 10, 2024 16:07
This is prescribed by the [CTAP spec][ctap]:

>**Client extension processing**
>1. [...]
>2. If present in a get():
>  1. Verify that salt1 is a 32-byte ArrayBuffer.
>  2. If salt2 is present, verify that it is a 32-byte ArrayBuffer.
>  [...]

[ctap]: https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-hmac-secret-extension
This is needed because the PRF extension should return an empty extension output
`prf: {}` when the extension is processed but no eligible authenticator is
found. Thus we need to differentiate these cases so that
`GetAssertion::finalize_result` can match on `PrfUnmatched` and generate the
empty output.
@emlun
Copy link
Contributor Author

emlun commented Jul 10, 2024

I force-pushed a bit because 8bdbc3d made the crypto_dummy tests fail, and I also took the opportunity to split up 1aa54f0 into a series of smaller change units: fd8e062, 5cebc5b and 9036264.

In addition to that I also added 978725b in order to correctly return an empty PRF extension output when the authenticator is not eligible, and added a little more debug output to failure cases.

@jschanck
Copy link
Collaborator

Great! This looks like it's ready to go. Do you want me to merge the serialize_map! patch first? I haven't checked whether there are conflicts.

@emlun
Copy link
Contributor Author

emlun commented Jul 19, 2024

Great! This looks like it's ready to go. Do you want me to merge the serialize_map! patch first? I haven't checked whether there are conflicts.

Please do! I'll update this PR to make use of it here too.

My local branch also has a few more refactorizations and some additions to the examples. While fiddling with the examples I also found that the (pre-existing) can_skip_user_verification logic seems to be a bit strange, but I might be missing something there.

But maybe we'll take all separate from this PR? This one is probably big enough as it is already. 😆

@jschanck
Copy link
Collaborator

Please do! I'll update this PR to make use of it here too.

Sounds good!

My local branch also has a few more refactorizations and some additions to the examples. While fiddling with the examples I also found that the (pre-existing) can_skip_user_verification logic seems to be a bit strange, but I might be missing something there.

But maybe we'll take all separate from this PR? This one is probably big enough as it is already. 😆

Yes, please submit a separate PR.

Thanks again for your help with this!

@emlun
Copy link
Contributor Author

emlun commented Jul 19, 2024

Alright, I've merged the serialize_map! changes and added a couple of tests that were now missing. Anything else that needs resolution?

I saw you rebase-merged #338 so at first I tried to rebase this on top of that, but the conflicts were frankly too much work to deal with, and it would have made the history not make sense anymore either, so I decided against it and just merged instead. Is that okay?

@jschanck
Copy link
Collaborator

We don't have merge commits enabled in this repo. I'm not too worried about the history---it's always available here in this PR if anyone needs it.

@jschanck jschanck merged commit c3defd3 into mozilla:ctap2-2021 Jul 25, 2024
8 checks passed
@Be-ing
Copy link

Be-ing commented Jul 25, 2024

Thank you! I'm looking forward to passwordless login to the Bitwarden browser extension in Firefox!

@emlun emlun deleted the prf-extension branch July 26, 2024 16:08
@ThomasSteinbinder
Copy link

Hey, I know this is not the right place for this question... but when can we expect this feature to be available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants