Passwordless (passkey) with Ruby/WebAuthn
Implementation trends
Corporate Design Department
Security Group Keiko Itakura

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

1

Introduction

Born in Izumo City, Shimane Prefecture2005 Unisys General Technology Research Institute
System Engineer
2008 Microsoft Consulting Services
technical consultant
2015 IBM Security Division
Manager
2019 Rakuten Group Ecosystem Service Department
Principal Information Security Specialist／
FIDO AllianceJapan Leadership Group/Vice Chair
2023 Medley
Corporate Design Department
Company-wide information security promotion oﬃcer
Copyright© Medley, Inc. ALL RIGHTS RESERVED.

2

Table of contents

Introduce the latest trends related to passwordless authentication (passkey)
from a Ruby implementation perspective.

1

History and issues of authentication methods

2

The release of synced passkeys and related technologies

3

Passkey implementation with Ruby

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

3

1

History and issues of authentication methods

2

The release of synced passkeys and related technologies

3

Passkey implementation with Ruby

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

4

History andissues ofauthentication
methods

Challenges in password authentication●●●

Can't remember passwords○ Setting a simple password that iseasy to remember○ Reusing passwords
Many security incidents occur due toaccount takeover.
Responding to inquiries due toforgotten passwords and incurring
password reset operation costs

On the Internet, nobody knows you're a dog

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

5

History andissues ofauthentication
methods

Challenges with multi-factor authentication

There have also been reports of attacks that cannot be prevented even withmulti-factor authentication, such as hijacking accounts by abusing password
resets.

UserAttacker

Fake SiteReal Site

1. Build Fake Site
2. Guide to Fake Site

4. Request password reset with phone number
3. Input user info(such as phone number) for
account registration

5. Send OTP

6. Input OTP
7. Success authentication with OTP

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

6

History andissues ofauthentication
methods

Traditional passkeys (device-bound passkeys)

Utilizing public key cryptography, authentication is performed based on possession
using an authenticator.

ClientServer
RP Client AppWebAuthn

RP Server AppWeb Browser

CTAPPublic KeyAuthenticator

WHAT IS A PASSKEY?
Any passwordless FIDO credential is a passkey.
https://ﬁdoalliance.org/passkeys/

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

7

History andissues ofauthentication
methods

Phishing resistance in passkeys

As an example of phishing resistance, the authenticator send the identiﬁer of theRP server with own sign, and the RP server veriﬁes this signature.
= If there is an intermediary, it can be detected by signature veriﬁcation &Authentication cannot be performed on a server whose domain is diﬀerent fromthe RP server.

Signed for the RP server
identifier
User data(e.g. biometricsinfo)

UserResult of local
authentication

Authenticator
RP Server(Service Provider)
Trust relationship

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

8

1

History and issues of authentication methods

2

The release of synced passkeys and related technologies

3Passkey implementation with Ruby

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

9The release ofsynced passkeys
and relatedtechnologies

Issues of traditional passkeys

Since the authentication method relies on the authenticator, the problem was
how to recover the account if the authenticator itself was lost or damaged.

LostDevices
Anotherdevices

BrokenDevices

Passcord

OTP

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

10The release ofsynced passkeys
and relatedtechnologies

Synced passkeys

Passkeys to be saved in a passkey provider (cloud provider or password managerprovider) and settings related to FIDO authentication to be migrated as well.
*The need for device-bound credentials continues to be discussed.

AZXYA+

FIDO
credentialA +Device-bound passkeys

Synced passkeys（Store diﬀerent key in each devices）（Store same key in each devices）

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

11

The release ofsynced passkeys
and related
technologies

Autofill UI

Check if the current user has credentials and display them as a list. (Passkeys arealso included in this list)
Users no longer need to enter not only a password but also an user id.

Browser
Select your account

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

12The release ofsynced passkeys
and related
technologies

HybridA smartphone can be used as an authenticator. A technology based on Bluetooth that can also
be used to leverage Passkeys across platforms.

Sign in on yourdesktop PC

Read theauthentication
QR code withyoursmartphone

Verify youridentity with yoursmartphone andthe authentication
is successful.

5. Establish a tunnel(wss)

2. Read QR code
3. BLE Scan

1. Show
QR code4. BLE advertising

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

13

The release ofsynced passkeys
and related
technologies

Demonstration

Please see a demonstration

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

14The release ofsynced passkeys
and related
technologies

Demonstration

https://www.youtube.com/watch?v=_QwOXyoetD8

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

15

The release ofsynced passkeys
and related
technologies

Comparison with traditional authentication methods -1

Traditional authentication methods and passkeys have diﬀerent risk scenarios(location/target to protect, entity responsible, impact, etc.)

Password / One Time Password
Credentials
Conﬁdentiality

Passkeys

Password reuse

Generate challenge

Credential compromise(phishing)

Origin bound keys

Credential compromise at RP

Loss of public key is not impactful

Credential compromise (credentialmanager)

Credential compromise (passkeyprovider)

Refer authenticate2023
Dean H.Saxe [The New Passkey Threat Model]

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

16The release ofsynced passkeys
and related
technologies

Comparison with traditional authentication methods -2

Risk assessment of passkey providers is also important from an availability
perspective.
*Passkey provider information can be obtained from AAGUID
https://github.com/passkeydeveloper/passkey-authenticator-aaguids/blob/main/aaguid.json
Password / One Time Password
CredentialAvailability

Passkeys

Forgotten

N/A

Deleted from credential manager

Deleted from authenticator or passkey
providerCannot access email/SMS

N/A

Lost access to credential manager

Device bound passkeys-Lost or broken device
Synced passkeys-Lost access to passkey provider-forgot credentials / failed account recovery-deleted passkey provider account-cancellation of service

Refer authenticate2023
Dean H.Saxe [The New Passkey Threat Model]をもとに加工

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

17

The release ofsynced passkeys
and relatedtechnologies

Comparison with traditional authentication methods -3

Correct use of passkeys, such as sharing passkeys using AirDrop, and risk
assessment is also important.

Password / One Time Password
Credential
recoveryAccount recovery via RPPasskeys
Device bound passkeys-another device bound credentials-Account recovery via RP
Synced passkeys-Credential recovery via passkey provider-Account recovery via RP

Credential
sharing

Shared via analog mechanisms orvoice

N/A

Shared by value

Apple Airdrop

Refer authenticate2023
Dean H.Saxe [The New Passkey Threat Model]をもとに加工

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

18

The release ofsynced passkeys
and relatedtechnologies

Support status

https://passkeys.dev/device-support/（2023/10/20）
Copyright© Medley, Inc. ALL RIGHTS RESERVED.

19

１ History and issues of authentication methods
２

The release of synced passkeys and related technologies

3

Passkey implementation with Ruby

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

20

Passkey
implementationwith Ruby

Sample code and spec info

Passkeys can be implemented using WebAuthn API (Web Authentication API).
The WebAuthn speciﬁcations are published as Level 3 (working draft).

https://www.w3.org/TR/webauthn-3/

Multiple Ruby libraries have been released*Recommend using products that have passed the FIDO Alliance test and are certiﬁed.

●●●webauthn-ruby (Cedarcode)devise-passkeys (Ruby Passkeys, wrapper around webauthn-ruby)warden-webauthn (Ruby Passkeys, wrapper around webauthn-ruby)

Sample code using above libraries
webauthn-rails-demo-app※Other language based libraries also have been released.
awesome-webauthn
Copyright© Medley, Inc. ALL RIGHTS RESERVED.

21

Passkey
implementationwith Ruby

Passkey implementation function

Web Authentication API has two basic functions: registration and login.

Registration

MethodUse case

Functionnavigator.credentials.create()●

Passkey registration whenregistering a user (account) tothe service
Passkey registration by existinguser (account) of the service

Send signature andpublic key information

Passkey authentication whenlogging in to existing services
Passkey authentication required
for logged in users (accounts)

Send signature●

Authenti navigator.credentials
cation.get()●●Copyright© Medley, Inc. ALL RIGHTS RESERVED.

22Passkeyimplementationwith Ruby

●Implementation overview (registration)

The registration step requires two APIs to be prepared.
（API1) API that issues a challenge response linked to a user ID（API2）API to verify the public key issued by the authenticator and save itin the database●Registration step overview
0. Passkey registration request by user
1.
2.
3.
4.
5.
6.

PublicKeyCredentialCreationOptions object creation by RP (server)（API1）
Execute navigator.credentials.create() by RP(JS APP)
Creation of key pair and attestation signature by authenticator
Return PublicKeyCredential by authenticator
Return AuthenticatorAttestationResponse by RP (JS APP)
Authentication information veriﬁed by RP (server), registration
completed(API2)

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

23

Passkey
implementation
with Ruby

ライブラリの利用

Add library name tto the gemﬁleExecute $ bundle

Or execute installation

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

24

Passkey
implementation
with Ruby

Conﬁguration ﬁleSet domain name and RP name etc as conﬁg info

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

25

Passkey
implementation
with Ruby

0．Passkey registration request by user

The browser display a button such as ``Register Passkey'' and user sends theinformation necessary for account registration to the server through events suchas pressing the button. The information required for registration diﬀers
depending on the service. (name, address, etc.)

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

26

Passkey
implementation
with Ruby

1．PublicKeyCredentialCreationOptions object creation
by RP (server)

When RP received request from a user, RP generates a challenge (random number)and creates a PublicKeyCredentialCreationOptions object along with informationnecessary for the next step such as RP information.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

27

Passkey
implementation
with Ruby

1．PublicKeyCredentialCreationOptions object creation
by RP (server)

Excerpt from contents of PublicKeyCredentialCreationOptions Object
Parameter

Must

Description

rp✓

Relying Party info
id:identiﬁcation（domain name）
name: RP nameuser✓

User info
id: identiﬁcation in RP
name: user namedisplayName:display namechallenge✓

Random number generated by server

pubKeyCredParams✓Key info
type: Credential typealg: encryption algorithmAuthenticatorSelection

Available function on authenticator
AuthenticatorAttachement :control syncronization toplatform requireResidentkey : Discoverable Credential usage
userVeriﬁcation : requirement level for local authentication

timeout

Waiting time for API callingexcludeCredentials

Existing passkey info (to avoid register samepasskey)
Copyright© Medley, Inc. ALL RIGHTS RESERVED.

28

Passkey
implementation
with Ruby

1．PublicKeyCredentialCreationOptions object creation
by RP (server)

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

29

Passkey
implementation
with Ruby

2. Execute navigator.credentials.create() by RP(JS APP)

Call the navigator.credentials.create() method with the
PublicKeyCredentialCreationOptions object and PublicKey as arguments

There are several JavaScript library例）webauthn-json

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

30

Passkey
implementation
with Ruby

3. Creation of key pair and attestation signature byauthenticator

When local authentication (identity veriﬁcation) with the authenticator is
successful, create a key pair and sign it with the private key for attestation.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

31

Passkey
implementation
with Ruby

4. Return PublicKeyCredential by authenticator

The authenticator returns the created public key and authentication informationsuch as Attestation to the browser as an attestationObject.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

32

Passkey
implementation
with Ruby

4. Return PublicKeyCredential by authenticator

Excerpt from contents of PublicKeyCredential

Parameter

Description

rawId

Binary data of generated public key identiﬁer (ArrayBuﬀer)

id

The generated public key identiﬁer is actually the Base64url
encoded data of the rawId above

response

Authenticator response to credential generation request(AuthenticatorAttestationResponse)
attestationObject
As a result of user veriﬁcation by the authenticator,authenticator data and attestation information in COSE format
clientDataJSON
JSON format information of the information (ClientData) sentfrom the web browser to the authenticator when requesting
credential generation

type

PublicKeyCredential type。generally, public-key

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

33

Passkey
implementation
with Ruby

5.Return AuthenticatorAttestationResponse by RP (JSAPP)

Send authentication info to AttesstationResponse endpoint at RPCopyright© Medley, Inc. ALL RIGHTS RESERVED.

34

Passkey
implementation
with Ruby

6.Authentication information veriﬁed by RP (server),registration completed

RP verify received authentication info. After successfully veriﬁed, return
appropriate success response and store public key to DB for using authentication
Registration has been completed.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

35

Passkey
implementation
with Ruby

6.Authentication information veriﬁed by RP (server),registration completed

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

36

Passkey
implementation
with Ruby●実装内容概要（認証）The authentication step requires two APIs to be prepared.
（API1) API that issues a challenge response linked to a user ID（API2）API that issues a session by verifying the signature issued by thebrowser's authenticator using a public key stored on the server.

●Authentication step overview
0. Passkey authentication request by user
1.
2.
3.
4.
5.
6.

Create PublicKeyCredentialRequestOptions Object by RP（Server）（API1）
Execute navigator.credentials.get() by RP（JS APP）
User conﬁrmation and assertion creation by authenticator
Return authentication info by authenticator
Return AuthenticationAssertionResponse by RP（JS APP）
Signature veriﬁcation and authentication completed by RP(server)(API2)

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

37

Passkey
implementation
with Ruby

0 Passkey authentication request by user

Similar to registration, request speciﬁcations for authentication endpoints arealso outside the scope of WebAuthn speciﬁcations. Usually uses a unique
identiﬁer such as a user ID that can identify the user.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

38

Passkey
implementationwith Ruby

0 Passkey authentication request by user

If you want to use Autoﬁll, specify the autocomplete attribute in the input ﬁeldof the login page.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

39

Passkey
implementation
with Ruby

1．Create PublicKeyCredentialRequestOptions Objectby RP（Server）

Upon receiving a request from a user, the server generates a challenge (randomnumber). Also, store the public key information created by the authenticatorstored in the DB in allowCredentials and create a
PublicKeyCredentialRequestOptions object.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

40

Passkey
implementation
with Ruby

1．Create PublicKeyCredentialRequestOptions Objectby RP（Server）

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

41

Passkey
implementation
with Ruby

1．Create PublicKeyCredentialRequestOptions Object
by RP（Server）

Excerpt from contents of PublicKeyCredentialRequestOptions Object
Parameter

Must

Descriotion

challenge✓

Random number generated by server

allowCredentials

type: PublicKeyCredential type
id: CredentialID by executing create()transports: Communication method to authenticator

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

42

Passkey
implementation
with Ruby

2. Execute navigator.credentials.get() by RP（JS APP）

Based on the RP response, execute navigator.credentials.get() to perform
authentication processing.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

43

Passkey
implementation
with Ruby

2. Execute navigator.credentials.get() by RP（JS APP）

Pass the PublicKeyCredentialRequestOptions object with publickKey as anargument.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

44

Passkey
implementation
with Ruby

3. User conﬁrmation and assertion creation byauthenticator

The authenticator veriﬁes the user based on the Challenge and RelyingParty
information and creates an assertion.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

45

Passkey
implementation
with Ruby

4. Return PublicKeyCredential by authenticator

Returns the PublicKeyCredential (assertion signature, clientDataHash,
AuthenticatorData, etc.) generated by the authenticator to the browser.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

46

Passkey
implementation
with Ruby

4. Return PublicKeyCredential by authenticator

Excerpt from contents of PublicKeyCredential
Parameter

Description

rawId

Binary data of public key identiﬁer（ArrayBuﬀer）

id

The public key identiﬁer is actually the Base64url encoded dataof the rawId above.

response

Authenticator response to credential authentication request(AuthenticatorAssertionResponse)
AuthenticatorData
Metadata about the authenticator
clientDataJSON
JSON format information of the information (ClientData) sentfrom the web browser to the authenticator when requesting
credential authentication
signature
Signature data for PublicKeyCredential generated by theauthenticator. It is generated using the registered user's private
key for data that is a concatenation of the hash values(ClienthDataHash) of the above authenticatorData andClientData.

type

PublicKeyCredential type. Generally, public-key
Copyright© Medley, Inc. ALL RIGHTS RESERVED.

47

Passkey
implementation
with Ruby

5.Return AuthenticationAssertionResponse by RP（JSAPP）

As with registration, in addition to the parameters received from theauthenticator, include parameters such as rawId, id, type, clienetDataJSON, etc.,
and send to the AssertionResponse endpoint.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

48

Passkey
implementation
with Ruby

6.Signature veriﬁcation and authentication

completed by RP (server)

The RP veriﬁes the Assertion, and if the veriﬁcation is successful, theauthentication to be successful. Continue processing in the same way as ageneral authentication server, such as issuing a session and setting the session
ID in a cookie.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

49

Passkey
implementation
with Ruby

6.Signature veriﬁcation and authentication

completed by RP (server)

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

50

Summary●Passkeys that are secure and improve usability are now even easier
to adapt products (Ruby libraries and sample code are also available)●Implementation with attention to precautions unique to Synced
Passkey and ongoing issues such as;○ Security level of Passkey providers○ Conﬁrming device bound credentials●Pay attention to smooth transition from existing authentication UX○ UX guidelines have also been published.

Copyright© Medley, Inc. ALL RIGHTS RESERVED.

51