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

[webauthn-lib] App broken after composer update #88

Closed
it-spiderman opened this issue Sep 2, 2019 · 9 comments
Closed

[webauthn-lib] App broken after composer update #88

it-spiderman opened this issue Sep 2, 2019 · 9 comments
Assignees
Labels
bug Something isn't working ongoing investigation Trying to find what's wrong

Comments

@it-spiderman
Copy link

Our implementation of WebAuthn using webauthn-lib got broken after running composer update.
We pinpointed the issue to the update of https://github.com/web-auth/cose-lib from 2.0.3 to 2.1.

Problem occurs here https://github.com/web-auth/cose-lib, seems that our key retrurns signature of length 71, while expected is 64. (Using FIDO2 usb key)

Since the signature handling is done compeltely by the library, we are not sure how to deal with this issue.
Temporarely we worked around the issue by manually requiring 2.0.3 in main composer.json.

What are the recommendations for resolving this?

Thank you

@Spomky
Copy link
Contributor

Spomky commented Sep 2, 2019

Hello @it-spiderman,

I am sorry to read that you have an issue with the new minor version.
Can you tell me when this exception is thrown: registration of the device or authentication of the user?

Is it possible to have additional information such as the credential options, response or pk source?
At least the complete trace of the exception?

Thanks

@Spomky Spomky self-assigned this Sep 2, 2019
@Spomky Spomky added bug Something isn't working ongoing investigation Trying to find what's wrong labels Sep 2, 2019
@it-spiderman
Copy link
Author

Hello @Spomky,

This only occurs on authentication step - key registration works fine.
We are basically using the code as it is on:
https://github.com/web-auth/webauthn-framework/blob/master/doc/webauthn/PublicKeyCredentialRequest.md#example-1

`[1d4ed64ca2b16c9cd768826a] /wmf-2fa/index.php?title=Special:UserLogin&returnto=Main+Page InvalidArgumentException from line 37 of /var/www/html/wmf-2fa/extensions/WebAuthn/vendor/web-auth/cose-lib/src/Algorithm/Signature/ECDSA/ECSignature.php: Invalid signature length.

Backtrace:

#0 /var/www/html/wmf-2fa/extensions/WebAuthn/vendor/web-auth/cose-lib/src/Algorithm/Signature/ECDSA/ES256.php(37): Cose\Algorithm\Signature\ECDSA\ECSignature::toAsn1(string, integer)
#1 /var/www/html/wmf-2fa/extensions/WebAuthn/vendor/web-auth/webauthn-lib/src/AuthenticatorAssertionResponseValidator.php(156): Cose\Algorithm\Signature\ECDSA\ES256->verify(string, Cose\Key\Key, string)
#2 /var/www/html/wmf-2fa/extensions/WebAuthn/src/Key/WebAuthnKey.php(489): Webauthn\AuthenticatorAssertionResponseValidator->check(string, Webauthn\AuthenticatorAssertionResponse, Webauthn\PublicKeyCredentialRequestOptions, MediaWiki\Extension\WebAuthn\Request, string)
#3 /var/www/html/wmf-2fa/extensions/WebAuthn/src/Key/WebAuthnKey.php(285): MediaWiki\Extension\WebAuthn\Key\WebAuthnKey->authenticationCeremony(string, Webauthn\PublicKeyCredentialRequestOptions)
#4 /var/www/html/wmf-2fa/extensions/WebAuthn/src/Module/WebAuthn.php(114): MediaWiki\Extension\WebAuthn\Key\WebAuthnKey->verify(array, MediaWiki\Extension\OATHAuth\OATHUser)
#5 /var/www/html/wmf-2fa/extensions/WebAuthn/src/Authenticator.php(239): MediaWiki\Extension\WebAuthn\Module\WebAuthn->verify(MediaWiki\Extension\OATHAuth\OATHUser, array)
#6 /var/www/html/wmf-2fa/extensions/WebAuthn/src/Auth/WebAuthnSecondaryAuthenticationProvider.php(88): MediaWiki\Extension\WebAuthn\Authenticator->continueAuthentication(array)
#7 /var/www/html/wmf-2fa/extensions/OATHAuth/src/Auth/SecondaryAuthenticationProvider.php(65): MediaWiki\Extension\WebAuthn\Auth\WebAuthnSecondaryAuthenticationProvider->continueSecondaryAuthentication(User, array)
#8 /var/www/html/wmf-2fa/includes/auth/AuthManager.php(650): MediaWiki\Extension\OATHAuth\Auth\SecondaryAuthenticationProvider->continueSecondaryAuthentication(User, array)
#9 /var/www/html/wmf-2fa/includes/specialpage/AuthManagerSpecialPage.php(355): MediaWiki\Auth\AuthManager->continueAuthentication(array)
#10 /var/www/html/wmf-2fa/includes/specialpage/AuthManagerSpecialPage.php(482): AuthManagerSpecialPage->performAuthenticationStep(string, array)`

Thank you for your support

@Spomky
Copy link
Contributor

Spomky commented Sep 2, 2019

Thaks for the details.
It looks like you have web-auth/cose-lib v2.1 and web-auth/webauthn-lib v2.0. Is it correct?
If yes, I see from where the issue comes from and I will fix that in few hours.

@it-spiderman
Copy link
Author

Correct, "web-auth/webauthn-lib": "v2.0.3", which requires "web-auth/cose-lib": "^2.0" (resolves to 2.1.4)

Thank you!

@Spomky
Copy link
Contributor

Spomky commented Sep 2, 2019

That's great. Let me a few moment to fix it.
You will be able to use web-auth/webauthn-lib v2.0 with web-auth/cose-lib v2.1.
If everything is fine you will be able to update web-auth/webauthn-lib to v2.1 as well.

Please note that there is also a bug in the JS script in the example (see #87): the challenge and IDs in allowedCredentials are base64url safe and not base64 encoded.

If you use the example for your JS code, you will have an issue. If you use another JS library that is fully compliant with the specification you should not have any trouble.

You will find scripts that work in demo.zip.

I let this issue opened until you correctly upgraded your application.

@Spomky
Copy link
Contributor

Spomky commented Sep 2, 2019

Should be fixed in v2.1.5 now.
Can you confirm it is now fine wor you?

I also updated the JS script in the example. Don’t forget to update it too if you are using it.

@it-spiderman
Copy link
Author

Everything is working, thank you very much

@Spomky
Copy link
Contributor

Spomky commented Sep 3, 2019

That's a good news. Sorry for the inconvenient.

@github-actions
Copy link
Contributor

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working ongoing investigation Trying to find what's wrong
Projects
None yet
Development

No branches or pull requests

2 participants