Skip to content

Commit 9ca7fca

Browse files
committed
Bug 1463170 - Set AuthenticatorAssertionResponse.userHandle to null r=ttaubert r=smaug
Summary: The WebAuthn spec says to set `AuthenticatorAssertionResponse.userHandle` to null when the authenticator returns no user handle (e.g., when allowList is set), but we return an empty ArrayBuffer. This is because of the defaults in AuthenticatorAssertionResponse.h, as the field is itself unset. We missed this change to the spec that happened in December [2], so this also has a corresponding WebIDL update. I don't see any other instances of WebIDL differences. [1] https://w3c.github.io/webauthn/#ref-for-dom-authenticatorassertionresponse-userhandle%E2%91%A0 [2] w3c/webauthn@3b2a1d1 Test Plan: https://treeherder.mozilla.org/#/jobs?repo=try&revision=59a2ab255ef14e935c1aa9f457276f8e61e5d779 Reviewers: smaug, ttaubert Bug #: 1463170 Differential Revision: https://phabricator.services.mozilla.com/D1337 --HG-- extra : amend_source : 966dcd24050585e745078648e1d7995b3beaf9ca extra : transplant_source : h%3E%B7COQ%F3%05%A9%95%1C%5D%CD%E1XZ%06Z%8D%83
1 parent d4f19ce commit 9ca7fca

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

dom/webauthn/AuthenticatorAssertionResponse.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,16 @@ void
9999
AuthenticatorAssertionResponse::GetUserHandle(JSContext* aCx,
100100
JS::MutableHandle<JSObject*> aRetVal)
101101
{
102-
if (!mUserHandleCachedObj) {
103-
mUserHandleCachedObj = mUserHandle.ToArrayBuffer(aCx);
102+
// Per https://w3c.github.io/webauthn/#ref-for-dom-authenticatorassertionresponse-userhandle%E2%91%A0
103+
// this should return null if the handle is unset.
104+
if (mUserHandle.IsEmpty()) {
105+
aRetVal.set(nullptr);
106+
} else {
107+
if (!mUserHandleCachedObj) {
108+
mUserHandleCachedObj = mUserHandle.ToArrayBuffer(aCx);
109+
}
110+
aRetVal.set(mUserHandleCachedObj);
104111
}
105-
aRetVal.set(mUserHandleCachedObj);
106112
}
107113

108114
nsresult

dom/webauthn/tests/test_webauthn_loopback.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ <h1>Full-run test for MakeCredential/GetAssertion for W3C Web Authentication</h1
116116
ok(aAssertion.response.authenticatorData instanceof ArrayBuffer, "AuthenticatorAssertionResponse.AuthenticatorData is an ArrayBuffer");
117117
ok(aAssertion.response.signature === aAssertion.response.signature, "AuthenticatorAssertionResponse.Signature is SameObject");
118118
ok(aAssertion.response.signature instanceof ArrayBuffer, "AuthenticatorAssertionResponse.Signature is an ArrayBuffer");
119-
ok(aAssertion.response.userHandle === aAssertion.response.userHandle, "AuthenticatorAssertionResponse.UserHandle is SameObject");
120-
ok(aAssertion.response.userHandle instanceof ArrayBuffer, "AuthenticatorAssertionResponse.UserHandle is an ArrayBuffer");
121-
is(aAssertion.response.userHandle.byteLength, 0, "AuthenticatorAssertionResponse.UserHandle is emtpy");
119+
ok(aAssertion.response.userHandle === null, "AuthenticatorAssertionResponse.UserHandle is null for u2f authenticators");
122120

123121
ok(aAssertion.response.authenticatorData.byteLength > 0, "Authenticator data exists");
124122
let clientData = JSON.parse(buffer2string(aAssertion.response.clientDataJSON));

dom/webidl/WebAuthentication.webidl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface AuthenticatorAttestationResponse : AuthenticatorResponse {
3535
interface AuthenticatorAssertionResponse : AuthenticatorResponse {
3636
[SameObject] readonly attribute ArrayBuffer authenticatorData;
3737
[SameObject] readonly attribute ArrayBuffer signature;
38-
[SameObject] readonly attribute ArrayBuffer userHandle;
38+
[SameObject] readonly attribute ArrayBuffer? userHandle;
3939
};
4040

4141
dictionary PublicKeyCredentialParameters {

0 commit comments

Comments
 (0)