Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Malformed UTF-8 characters, possibly incorrectly encoded #17

Closed
saiht opened this issue Jul 29, 2020 · 19 comments
Closed

Malformed UTF-8 characters, possibly incorrectly encoded #17

saiht opened this issue Jul 29, 2020 · 19 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@saiht
Copy link

saiht commented Jul 29, 2020

On following environment:

PHP 7.4.8
Laravel v7.21
Default configuration for larapass.php

On registration process, I got the error:

Response for /webauthn/register/options:

{"rp":{"name":"Laravel"},"pubKeyCredParams":[{"type":"public-key","alg":-7},{"type":"public-key","alg":-8},{"type":"public-key","alg":-35},{"type":"public-key","alg":-36},{"type":"public-key","alg":-257}],"challenge":"nB15sPSpNaZNc_qo3RexMg","attestation":"none","user":{"name":"admin@admin.com","id":"MzQ5MDE3ZTEtYjU2Zi00YWM0LTlkYjEtZmNmZGMyOGE2ZTg3","displayName":"admin"},"authenticatorSelection":{"requireResidentKey":false,"userVerification":"preferred"},"timeout":60000}

On /webauthn/register:

Expand { "message": "Malformed UTF-8 characters, possibly incorrectly encoded", "exception": "InvalidArgumentException", "file": "/var/www/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php", "line": 75, "trace": [ { "file": "/var/www/vendor/symfony/http-foundation/JsonResponse.php", "line": 50, "function": "setData", "class": "Illuminate\\Http\\JsonResponse", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php", "line": 31, "function": "__construct", "class": "Symfony\\Component\\HttpFoundation\\JsonResponse", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php", "line": 474, "function": "__construct", "class": "Illuminate\\Http\\JsonResponse", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php", "line": 209, "function": "prepareJsonResponse", "class": "Illuminate\\Foundation\\Exceptions\\Handler", "type": "->" }, { "file": "/var/www/app/Exceptions/Handler.php", "line": 53, "function": "render", "class": "Illuminate\\Foundation\\Exceptions\\Handler", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 51, "function": "render", "class": "App\\Exceptions\\Handler", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 130, "function": "handleException", "class": "Illuminate\\Routing\\Pipeline", "type": "->" }, { "file": "/var/www/app/Http/Middleware/SetLocale.php", "line": 24, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "App\\Http\\Middleware\\SetLocale", "type": "->" }, { "file": "/var/www/app/Http/Middleware/AuthGates.php", "line": 32, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "App\\Http\\Middleware\\AuthGates", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php", "line": 41, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\\Routing\\Middleware\\SubstituteBindings", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php", "line": 44, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\\Auth\\Middleware\\Authenticate", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php", "line": 76, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php", "line": 49, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\\View\\Middleware\\ShareErrorsFromSession", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php", "line": 116, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php", "line": 62, "function": "handleStatefulRequest", "class": "Illuminate\\Session\\Middleware\\StartSession", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\\Session\\Middleware\\StartSession", "type": "->" }, { "file": "/var/www/vendor/stancl/tenancy/src/Middleware/PreventAccessFromCentralDomains.php", "line": 29, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Stancl\\Tenancy\\Middleware\\PreventAccessFromCentralDomains", "type": "->" }, { "file": "/var/www/vendor/stancl/tenancy/src/Middleware/IdentificationMiddleware.php", "line": 36, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/stancl/tenancy/src/Middleware/InitializeTenancyByDomain.php", "line": 38, "function": "initializeTenancy", "class": "Stancl\\Tenancy\\Middleware\\IdentificationMiddleware", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Stancl\\Tenancy\\Middleware\\InitializeTenancyByDomain", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php", "line": 37, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php", "line": 66, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\\Cookie\\Middleware\\EncryptCookies", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 103, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 687, "function": "then", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 662, "function": "runRouteWithinStack", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 628, "function": "runRoute", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 617, "function": "dispatchToRoute", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 165, "function": "dispatch", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 128, "function": "Illuminate\\Foundation\\Http\\{closure}", "class": "Illuminate\\Foundation\\Http\\Kernel", "type": "->" }, { "file": "/var/www/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php", "line": 65, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Barryvdh\\Debugbar\\Middleware\\InjectDebugbar", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php", "line": 27, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize", "type": "->" }, { "file": "/var/www/vendor/fruitcake/laravel-cors/src/HandleCors.php", "line": 37, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Fruitcake\\Cors\\HandleCors", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php", "line": 63, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode", "type": "->" }, { "file": "/var/www/vendor/fideloper/proxy/src/TrustProxies.php", "line": 57, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 167, "function": "handle", "class": "Fideloper\\Proxy\\TrustProxies", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 103, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 140, "function": "then", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 109, "function": "sendRequestThroughRouter", "class": "Illuminate\\Foundation\\Http\\Kernel", "type": "->" }, { "file": "/var/www/public/index.php", "line": 55, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Kernel", "type": "->" } ] }

I think that the reason may be the encoded id/rawId values, because the exception is thrown while attaching the credentials to the user.

As I saw, in

public function addCredential(CredentialSource $source) : void
{
$this->webAuthnCredentials()->save(
WebAuthnCredential::fromCredentialSource($source)
);
}
and deeper in the code,
$credentials = $this->loader->loadArray($data)->getResponse();
while decoding $json['id'] and $json['rawId'] , we got a non UTF-8 string.

This provokes the following mysql error:

SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xFD\x81\x06[@z...' for column 'id' at row 1 (SQL: insert into `web_authn_credentials` (`id`, `user_handle`, `type`, `transports`, `attestation_type`, `trust_path`, `aaguid`, `public_key`, `counter`, `user_id`, `updated_at`, `created_at`) values (\t²ü\x06[@z!6\x18Bâ¥c\x192P´─╩6ÆÒÝÅ ╩WsE;É, 624905a3-f0ba-4ad1-8186-cc7b5da7cb37, public-key, [], none, {"type":"Webauthn\\TrustPath\\EmptyTrustPath"}, 00000000-0000-0000-0000-000000000000, Ñ\x01\x02\x03& \x01!X \x14­bÿâ^a? TÂפ¨Æ\x18Y·┌©j¾\fr\x16ó░┌í├Ad"X èÄð|áı%Tàóês\x08Æø·F┌+\x04TG¶CK╬┬U┐\x19F=, 1, 1, 2020-07-29 07:01:07, 2020-07-29 07:01:07)) ◀SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xFD\x81\x06[@z...' for column 'id' at row 1 (SQL: insert into `web_authn_credentials` (`id`, `use...
@saiht
Copy link
Author

saiht commented Aug 3, 2020

No one ? @DarkGhostHunter

@DarkGhostHunter
Copy link
Owner

I'll take a look, it's very difficult to reproduce for me.

@exodusanto
Copy link
Contributor

I have the same error.

I fixed it wrapping $source->getPublicKeyCredentialId() with utf8_encode function in WebAuthnCredential@fromCredentialSource

public static function fromCredentialSource(CredentialSource $source)
    {
        return ($model = new static)->fill([
            $model->getKeyName()    => utf8_encode($source->getPublicKeyCredentialId()),
            'user_handle'           => $source->getUserHandle(),
            'type'                  => $source->getType(),
            'transports'            => $source->getTransports(),
            'attestation_type'      => $source->getAttestationType(),
            'trust_path'            => $source->getTrustPath()->jsonSerialize(),
            'aaguid'                => $source->getAaguid()->toString(),
            'public_key'            => utf8_encode($source->getCredentialPublicKey()),
            'counter'               => $source->getCounter(),
        ]);
    }

@efureev
Copy link

efureev commented Sep 29, 2020

I have the same problem. But crashed on find by id before creating CredentialSource.

php 7.4.10
Lara 7.28
Postgres 12

@DarkGhostHunter DarkGhostHunter self-assigned this Oct 19, 2020
@DarkGhostHunter DarkGhostHunter added bug Something isn't working help wanted Extra attention is needed labels Oct 19, 2020
@DarkGhostHunter
Copy link
Owner

Okay, I've put an alpha for v3.0.

Check it out for any problems. I'll make a full project with it to test it thoroughly.

MartinCamen added a commit to MartinCamen/Larapass that referenced this issue Mar 30, 2021
@DarkGhostHunter
Copy link
Owner

Figured out that you can just use the rawId of the payload, since it's already encoded in Base64 URL, as the ID in the database.

@DarkGhostHunter
Copy link
Owner

Fixed. Now it needs some tests.

@DarkGhostHunter
Copy link
Owner

@ReArmedHalo
Copy link

ReArmedHalo commented May 1, 2021

@DarkGhostHunter I'm getting this error on v3.0.1. Using a fresh Laravel 8 project with Breeze and this package. (First adventure into Webauthn, thanks for this package!)

Tried in Chrome v90 and Safari on macOS Big Sur on MBP M1 using Touch ID and Yubikey 5C NFC

{
    "message": "Malformed UTF-8 characters, possibly incorrectly encoded",
    "exception": "InvalidArgumentException",
    "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php",
    "line": 84,
    "trace": [
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/symfony/http-foundation/JsonResponse.php",
            "line": 54,
            "function": "setData",
            "class": "Illuminate\\Http\\JsonResponse",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php",
            "line": 32,
            "function": "__construct",
            "class": "Symfony\\Component\\HttpFoundation\\JsonResponse",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
            "line": 631,
            "function": "__construct",
            "class": "Illuminate\\Http\\JsonResponse",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
            "line": 351,
            "function": "prepareJsonResponse",
            "class": "Illuminate\\Foundation\\Exceptions\\Handler",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line": 51,
            "function": "render",
            "class": "Illuminate\\Foundation\\Exceptions\\Handler",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 130,
            "function": "handleException",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php",
            "line": 50,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Routing\\Middleware\\SubstituteBindings",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php",
            "line": 44,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Auth\\Middleware\\Authenticate",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php",
            "line": 78,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php",
            "line": 49,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\View\\Middleware\\ShareErrorsFromSession",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php",
            "line": 121,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php",
            "line": 64,
            "function": "handleStatefulRequest",
            "class": "Illuminate\\Session\\Middleware\\StartSession",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Session\\Middleware\\StartSession",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php",
            "line": 37,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php",
            "line": 67,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Cookie\\Middleware\\EncryptCookies",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 103,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 697,
            "function": "then",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 672,
            "function": "runRouteWithinStack",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 636,
            "function": "runRoute",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 625,
            "function": "dispatchToRoute",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 166,
            "function": "dispatch",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 128,
            "function": "Illuminate\\Foundation\\Http\\{closure}",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
            "line": 21,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php",
            "line": 31,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
            "line": 21,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php",
            "line": 40,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\TrimStrings",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
            "line": 27,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php",
            "line": 86,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/fruitcake/laravel-cors/src/HandleCors.php",
            "line": 38,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Fruitcake\\Cors\\HandleCors",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/fideloper/proxy/src/TrustProxies.php",
            "line": 57,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Fideloper\\Proxy\\TrustProxies",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 103,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 141,
            "function": "then",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 110,
            "function": "sendRequestThroughRouter",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/code/valet/larapass/public/index.php",
            "line": 52,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "/Users/dustinschreiber/.composer/vendor/laravel/valet/server.php",
            "line": 214,
            "function": "require"
        }
    ]
}

@renedekat
Copy link

It seems that the JSON type doesn't like none as a value for attestation_type

SQLSTATE[22032]: <>: 3140 Invalid JSON text: "Invalid value." at position 1 in value for column 'web_authn_credentials.attestation_type'. (SQL: insert into web_authn_credentials (id, user_handle, type, transports, attestation_type, trust_path, aaguid, public_key, counter, user_id, updated_at, created_at) values (q5Nd7GrQztOkUeWUXA-X_2XiJUc, 076f0803-2531-436d-ae4f-0e4f45a9f6e7, public-key, [], none, {"type":"Webauthn\TrustPath\EmptyTrustPath"}, 00000000-0000-0000-0000-000000000000, ����& �!X �d����"�������@�{0���p����`�x~��"X j��6���2�������6v��'"���:^b.:A�Y, 0, 1, 2021-06-12 13:11:26, 2021-06-12 13:11:26))

@ReArmedHalo
Copy link

@renedekat did you have the same error I have and ever figure it out? I just tried building a new app and I'm still running into this issue with a Yubikey or Touch ID.

@ReArmedHalo
Copy link

I just managed to resolve the issue by changing the database column for "attestation_type" from JSON to string. I'm not entirely sure what values can be in attestation_type but it seems both Touch ID and my Yubikey report none.

Alternatively, changing ManagesCredentialRepository on line 71 to 'type' => json_encode($source->getType()), also appears to solve the problem but again, I don't know the implications of this. @DarkGhostHunter do you have any thoughts as I am not very familiar with the Webauthn spec or your implementation here.

@asivaneswaran
Copy link

@DarkGhostHunter Any news on this?

@DarkGhostHunter
Copy link
Owner

@DarkGhostHunter Any news on this?

Too busy much work

@DarkGhostHunter
Copy link
Owner

I just managed to resolve the issue by changing the database column for "attestation_type" from JSON to string. I'm not entirely sure what values can be in attestation_type but it seems both Touch ID and my Yubikey report none.

Alternatively, changing ManagesCredentialRepository on line 71 to 'type' => json_encode($source->getType()), also appears to solve the problem but again, I don't know the implications of this. @DarkGhostHunter do you have any thoughts as I am not very familiar with the Webauthn spec or your implementation here.

Thanks for the support. I'll look into it this weekend.

@DarkGhostHunter
Copy link
Owner

By the way, is non-labour day here. Today counts as part of the weekend.

@DarkGhostHunter
Copy link
Owner

I just managed to resolve the issue by changing the database column for "attestation_type" from JSON to string. I'm not entirely sure what values can be in attestation_type but it seems both Touch ID and my Yubikey report none.

Alternatively, changing ManagesCredentialRepository on line 71 to 'type' => json_encode($source->getType()), also appears to solve the problem but again, I don't know the implications of this. @DarkGhostHunter do you have any thoughts as I am not very familiar with the Webauthn spec or your implementation here.

After checking it out, none is accepted. The most straightforward way to save the attestation type from the authenticator is to change the column to string because. I haven't found any example or reason to presume it would exceed 255 characters. Indeed, it seems that is just a small string.

Using json_encode($source->getType()) may be enough as none would encode to none, but since I haven't found any example on what a attestation_type is apart from just a string, it may be better to keep it as a string and not touch it.

Patch incoming now.

DarkGhostHunter added a commit that referenced this issue Nov 1, 2021
@DarkGhostHunter
Copy link
Owner

Should be fixed. Hopefully.

Otherwise, I'm open to new ways to appease the WebAuthn gods.

@ReArmedHalo
Copy link

Thanks @DarkGhostHunter ! I'll update my test project this week and give things a go!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants