Closed AntonyChiossi closed 1 year ago
@AntonyChiossi Can you confirm that you're testing this with a security key? I see -8
for an algorithm ID in the Chrome response. And which version of Firefox and which OS again?
Bizarre that the same implementation of SimpleWebAuthn succeeds with responses in Chrome but not in Firefox...
Other users are also running into a similar issue on another software that uses this module for webauthn where it works fine on chrome/chromium stable but not firefox and chrome dev but what is different is in this case it spits out a certificate error on chrome dev.
See the open issue on the other software: https://github.com/misskey-dev/misskey/issues/12115
Snippet of the error
Error: Certificate not good after "Sun Oct 22 2023 00:43:10 GMT+0000 (Coordinated Universal Time)" (Packed|Full)
at verifyAttestationPacked (file:///node_modules/.pnpm/@simplewebauthn+server@8.3.2/node_modules/@simplewebauthn/server/esm/registration/verifications/verifyAttestationPacked.js:55:19)
at verifyRegistrationResponse (file:///node_modules/.pnpm/@simplewebauthn+server@8.3.2/node_modules/@simplewebauthn/server/esm/registration/verifyRegistrationResponse.js:164:26)
@AntonyChiossi After some experimentation tonight it just dawned on me that the "fix" I added to address #440 is going to break security key responses in those versions of Firefox suffering the malformed CBOR issue because I'm flipping a bit in authData. This breaks signature verification for these bad responses because authData
is part of the bytes that get signed over:
Unfortunately, even when I experimented with flipping the bit back so that authData
isn't changed at all, signature verification of that Firefox response is still broken. Part of me wonders if there's not more fallout related to the malformed authData structure in Firefox. For one, the CBOR-encoded credential public key decodes to { kty: "OKP", crv: "Ed25519" }
instead of { kty: 1, crv: 6 }
like it does in Chrome. Without diving into Firefox 117 and 118 to see how they constructed authData I can only speculate that there's something else going on in these versions of Firefox that's continuing to break signature verification.
Based on all of this I'm inclined to say that this isn't something I can really address in this library. A "fix" for this issue is likely to be to specify only [-7, -257]
for supportedAlgorithmIDs
when generating registration options, and remove this option (to go back to the default of [-8, -7, -257]
) after Firefox 119 comes out with a proper fix.
I'm leaving this issue open for now as I'm going to add in a small change that'll prevent bad CBOR handling from permanently changing authData
for the rest of the response verification.
I've released @simplewebauthn/server@8.3.3 that restores authData
after handling bad CBOR. That should remove anything SimpleWebAuthn might be doing that would cause the failing signature verification with security key responses only in Firefox...
I'll leave this issue open for a bit in case someone (😉) with a bit more expertise around signature verification and CBOR sees something else I'm missing here. Otherwise I'll have to close this out as an issue with Firefox that can't be solved at the library level.
The 0xa4 to 0xa3 thing is definitely a no-no, you're actually losing all the key material when you do that.
"Good": A401634F4B50032720674564323535313921982018D818FB18E5183B187E18D618FA18971856187418CB18C4189E18C2189618B918EB185F18BE1874181D189218470E1837184E187B071839184F18D018E8
{1: "OKP", 3: -8, -1: "Ed25519", -2: [216, 251, 229, 59, 126, 214, 250, 151, 86, 116, 203, 196, 158, 194, 150, 185, 235, 95, 190, 116, 29, 146, 71, 14, 55, 78, 123, 7, 57, 79, 208, 232]}
Bad:
A301634F4B50032720674564323535313921982018D818FB18E5183B187E18D618FA18971856187418CB18C4189E18C2189618B918EB185F18BE1874181D189218470E1837184E187B071839184F18D018E8
{1: "OKP", 3: -8, -1: "Ed25519"}
That "Good" actually looks pretty hosed to me, when did we decide we could use strings instead of int values? It should look like:
A401010327200621583E18D818FB18E5183B187E18D618FA18971856187418CB18C4189E18C2189618B918EB185F18BE1874181D189218470E1837184E187B071839184F18D018E8
{1: 1, 3: -8, -1: 6, -2: h'18D818FB18E5183B187E18D618FA18971856187418CB18C4189E18C2189618B918EB185F18BE1874181D189218470E1837184E187B071839184F18D018E8'}
I feel like data is getting messed with along the way, which would invalidate the signature of course.
The key used is one of the new FIDO only Yubico Security Keys, the ones that used to be blue but are now black.
The 0xa4 to 0xa3 thing is definitely a no-no, you're actually losing all the key material when you do that.
Now I'm resetting the 0xa4
back to the 0xa3
it was before, I had to flip 0xa3
to 0xa4
because the bad CBOR encoding from Firefox 117 and Firefox 118 prevented the credential public key from being parsed. See #440 for more context if you want, so far I've been working to support these bad -8
security key responses.
I added the flip back just now because I realized I was invalidating signatures by permanently changing authData
, so SimpleWebAuthn should no longer be responsible for the failing signature validation that's still gone unsolved in this issue.
That "Good" actually looks pretty hosed to me, when did we decide we could use strings instead of int values? It should look like:
We didn't, Mozilla goofed and fixed the problem in Firefox 119 https://github.com/mozilla/authenticator-rs/pull/292
But 0xa3
would be 3 pairs, 0xa4
would be 4 pairs which is what we should see for this...
That "Good" actually looks pretty hosed to me, when did we decide we could use strings instead of int values? It should look like:
We didn't, Mozilla goofed and fixed the problem in Firefox 119 mozilla/authenticator-rs#292
This does not surprise me at all, this reminded me of https://bugzilla.mozilla.org/show_bug.cgi?id=1759098.
Hi @MasterKale, thanks for investigating on this issue. Is it still open in the lastest version right? if so, is there any workaround I can try? Is this a good one?
Sorry to leave you hanging @AntonyChiossi, I'd say "yes" to your question about limiting public key credential algorithms to ES256 (-7
) and RS256 (-257
) in the meantime when calling generateRegistrationOptions()
(i.e. setting supportedAlgorithmIDs: [-7, -257]
.) That should "solve" this problem by sidestepping the use of Ed25519 entirely.
Closing this out as there's not much more to do at the library level.
As requested here: https://github.com/MasterKale/SimpleWebAuthn/issues/440#issuecomment-1756923797
After updating both packages to their latest version, registration fails but with a different error this time. Chrome keeps working.
Here some debugging info:
Working with Chrome:
Failing with Firefox
The verification key is the result of the method verifyRegistrationResponse