Bug 232836 - [WebAuthn] challenge does not get passed to -[_WKWebAuthenticationPanel getAssertionWithChallenge:origin:options:completionHandler:]
Summary: [WebAuthn] challenge does not get passed to -[_WKWebAuthenticationPanel getAs...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P1 Normal
Assignee: pascoe@apple.com
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-11-08 12:44 PST by pascoe@apple.com
Modified: 2021-11-09 16:38 PST (History)
5 users (show)

See Also:


Attachments
Patch (14.00 KB, patch)
2021-11-08 12:54 PST, pascoe@apple.com
no flags Details | Formatted Diff | Diff
Patch (24.70 KB, patch)
2021-11-09 16:17 PST, Per Arne Vollan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description pascoe@apple.com 2021-11-08 12:44:22 PST
rdar://85163927
Comment 1 pascoe@apple.com 2021-11-08 12:44:54 PST
-[_WKWebAuthenticationPanel getAssertionWithChallenge:origin:options:completionHandler:] receives an empty challenge, causing _WKWebAuthenticationPanel to immediately close when using the new UNIFIED_ASC_AUTH_UI. 

This is likely because it’s not encoded/decoded by PublicKeyCredentialRequestOptions. Before this field was not used after xpc, but with the new UNIFIED_ASC_AUTH_UI it is.
Comment 2 pascoe@apple.com 2021-11-08 12:54:03 PST
Created attachment 443592 [details]
Patch
Comment 3 Brent Fulgham 2021-11-08 13:00:54 PST
Comment on attachment 443592 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=443592&action=review

> Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h:79
> +    BufferSource challenge; // challenge becomes challengeVector once it is passed to UIProcess.

I don't understand this. Do we meed to keep it as a Vector<uint8_t> in the UIProcess? Or do we only need that format when passing it into an API? Is this BufferSource just something given to us in an argument? Perhaps we should. convert directly to Vector when given this value, and not retain two copies (a BufferSource version, and a Vector<uint8_t> version).
Comment 4 pascoe@apple.com 2021-11-08 13:14:15 PST
(In reply to Brent Fulgham from comment #3)
> Comment on attachment 443592 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=443592&action=review
> 
> > Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h:79
> > +    BufferSource challenge; // challenge becomes challengeVector once it is passed to UIProcess.
> 
> I don't understand this. Do we meed to keep it as a Vector<uint8_t> in the
> UIProcess? Or do we only need that format when passing it into an API? Is
> this BufferSource just something given to us in an argument? Perhaps we
> should. convert directly to Vector when given this value, and not retain two
> copies (a BufferSource version, and a Vector<uint8_t> version).

Yeah, the buffer source is from JS, directly from the IDL. Here, I'm copying what PublicKeyCredentialCreationOptions.h:55 does with id -> idVector. I don't know that we can directly create this as an vector as I'm not too familiar with the way it gets deserialized from the idl definition.
Comment 5 Brent Fulgham 2021-11-08 14:48:02 PST
Comment on attachment 443592 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=443592&action=review

> Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h:150
> +    encoder.encodeFixedLengthData(challenge.data(), challenge.length(), 1);

So PublicKeyCredentialCreationOptions encodes the challenge (but not the challengeVector)...

> Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h:202
> +        return std::nullopt;

... and decodes the challengeVector (but not the challenge).

> Source/WebCore/Modules/webauthn/PublicKeyCredentialRequestOptions.h:63
> +    encoder.encodeFixedLengthData(challenge.data(), challenge.length(), 1);

And PublicKeyCredentialRequestOptions now encodes the challenge (but not the challengeVector)

> Source/WebCore/Modules/webauthn/PublicKeyCredentialRequestOptions.h:95
> +        return std::nullopt;

... and we decode the challengeVector (but not the challenge)

I think this is really hard to understand.
Comment 6 Brent Fulgham 2021-11-08 14:58:15 PST
Comment on attachment 443592 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=443592&action=review

>>> Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h:79
>>> +    BufferSource challenge; // challenge becomes challengeVector once it is passed to UIProcess.
>> 
>> I don't understand this. Do we meed to keep it as a Vector<uint8_t> in the UIProcess? Or do we only need that format when passing it into an API? Is this BufferSource just something given to us in an argument? Perhaps we should. convert directly to Vector when given this value, and not retain two copies (a BufferSource version, and a Vector<uint8_t> version).
> 
> Yeah, the buffer source is from JS, directly from the IDL. Here, I'm copying what PublicKeyCredentialCreationOptions.h:55 does with id -> idVector. I don't know that we can directly create this as an vector as I'm not too familiar with the way it gets deserialized from the idl definition.

I really feel like we should have a clean way to serialize BufferSource across IPC. Let me check with Chris.
Comment 7 Brent Fulgham 2021-11-08 15:05:21 PST
Comment on attachment 443592 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=443592&action=review

We should use an IPC::DataReference to hold/serialize the BufferSource contents. r- to make this change, as it will reduce the number of copies made during serialization. We should also do a follow-up patch to fix the bits of Jiewen's code where he did manual Vector<uint8_t> serialization.

>>>> Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h:79
>>>> +    BufferSource challenge; // challenge becomes challengeVector once it is passed to UIProcess.
>>> 
>>> I don't understand this. Do we meed to keep it as a Vector<uint8_t> in the UIProcess? Or do we only need that format when passing it into an API? Is this BufferSource just something given to us in an argument? Perhaps we should. convert directly to Vector when given this value, and not retain two copies (a BufferSource version, and a Vector<uint8_t> version).
>> 
>> Yeah, the buffer source is from JS, directly from the IDL. Here, I'm copying what PublicKeyCredentialCreationOptions.h:55 does with id -> idVector. I don't know that we can directly create this as an vector as I'm not too familiar with the way it gets deserialized from the idl definition.
> 
> I really feel like we should have a clean way to serialize BufferSource across IPC. Let me check with Chris.

Per Chris: We should be using an IPC::DataReference here, instead of BufferSource during serialization.
Comment 8 Brent Fulgham 2021-11-08 16:00:55 PST
Comment on attachment 443592 [details]
Patch

On second thought, let's handle all the weird BufferSource encode/decode in a separate patch.
Comment 9 EWS 2021-11-08 17:38:07 PST
Committed r285475 (244000@main): <https://commits.webkit.org/244000@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 443592 [details].
Comment 10 Per Arne Vollan 2021-11-09 16:17:38 PST
Reopening to attach new patch.
Comment 11 Per Arne Vollan 2021-11-09 16:17:39 PST
Created attachment 443749 [details]
Patch
Comment 12 Per Arne Vollan 2021-11-09 16:38:27 PST
Sorry, uploaded patch to incorrect bug.