Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration ...
Search
mackee
February 10, 2024
7.2k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration of full-scratch WebAuthn/Passkey Authentication written in Perl
YAPC::Hiroshima 2024
mackee
February 10, 2024
More Decks by mackee
See All by mackee
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
760
perlをWebAssembly上で動かすと何が嬉しいの??? / Where does Perl-on-Wasm actually make sense?
mackee
0
1.2k
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
6
6.2k
今!ソフトウェアエンジニアがハードウェアに手を出すには
mackee
14
7.3k
ワンバイナリWebサービスのススメ
mackee
10
9.1k
tanukistack ライブコーディング / tanukistack live-coding
mackee
0
790
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
1.2k
perl for shell, awk and sed programmers
mackee
3
2.9k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
1.1k
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
41
2.7k
Exploring anti-patterns in Rails
aemeredith
3
470
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
280
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
900
4 Signs Your Business is Dying
shpigford
187
23k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
260
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
73
41k
Deep Space Network (abreviated)
tonyrice
0
270
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The SEO identity crisis: Don't let AI make you average
varn
0
530
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Transcript
PerlͰͭ͘ΔϑϧεΫϥον WebAuthn/ύεΩʔೝূ YAPC::Hiroshima 2024 ݫౡ 15:00ʙ @mackee_w a.k.a macopy
͜ΜʹͪϚίϐʔͰ͢ʂ
εϐʔΧʔհ • X: @macopy • GitHub: @mackee • ໘ന๏ਓΧϠοΫ •
Tonamel αʔόʔαΠυ ΤϯδχΞ • ౡۀେֶग़
ຊͷ”օ༷”ͷඪ WebAuthnͷΈ͕Θ͔ͬͨؾʹͳΔ
ͱΓ͋͑ͣͬͯΈΔʹ օ͞Μͷ͓੮ͷޙΖʹ͋Δ`Perlbatross`ͰWebAuthn͕ΘΕ͍ͯ·͢
Θ͔ͬͨؾʹͳΔͨΊʹࢲ͕Δ͜ͱ • WebAuthnͷ࣮ࡍͷΈʹ͍ͭͯαʔόʔ࣮Λॻ͖ͳ͕Βઆ໌ • ͜ͷτʔΫϥΠϒίʔσΟϯάओମͰ͢ • ϋϓχϯά͕͋ͬͨΒԠԉ͍ͯͩ͘͠͞ • ͜ͷτʔΫͰॻ࣮͘৭ʑলུ͍ͯ͠·͢ •
(Option)ؼͬͨΒ͋ͳͨॻ͍ͯΈ·͠ΐ͏ • (ͲΜͳʹ͍͍ͯ͘ͷͰ)ϒϩάͰײ͕͋Εࢲ͔ͳΓتͼ·͢
ຊͷνϟʔτ • ࣗݾհͳͲ 15:00 ʙ 15:05 <= ΠϚίί • WebAuthnͱPasskeyͷ֓ཁ
15:05 ʙ 15:10 • Registration࣮ 15:10ʙ15:25 • Login࣮ 15:25ʙ15:35 • ·ͱΊ(όοϑΝ) 15:35ʙ15:40
ຊͷνϟʔτ • ࣗݾհͳͲ 15:00 ʙ 15:05 • WebAuthnͱPasskeyͷ֓ཁ 15:05 ʙ
15:10 • Registration࣮ 15:10ʙ15:25 • Login࣮ 15:25ʙ15:35 • ·ͱΊ(όοϑΝ) 15:35ʙ15:40
WebAuthnͱ • ύεϫʔυϨεೝূΛ࣮ݱ͢ΔͨΊͷඪ४Web API • ެ։伴҉߸Λͬͯిࢠॺ໊Ͱߦ͏ೝূํࣜ ύεϫʔυ
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 ΩʔϖΞ
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 ϩάΠϯ͍ͨ͠
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 challengeʹ ॺ໊ͯ͠
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 challengeʹ ॺ໊ͯ͠
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 ॺ໊ͨ͠Α
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 ॺ໊ͨ͠Α
WebAuthnͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث ൿີ伴 αʔόʔ ެ։伴 ͋ͬͯͦ͏ʂOK ݕূ
WebAuthnͷσϝϦοτ • ൿີ伴͕σόΠεʹด͍ͯ͡Δ • σόΠεΛ·͍ͨͩೝূΛͲ͏͢Δ͔ • CTAP2ͱ͍͏ൿີ伴͕ೖͬͨσόΠεͱBLEͳͲͰܨ͍Ͱೝূ͢ Δํࣜఆٛ͞Ε͍ͯΔ • ฆࣦͨ͠ΒͲ͏͢Δ͔
• => ༻్ͱͯ͠2FAͷ1͔ͭͭɺ͜Ε͚ͩͩͱ৺ڐͳ͍
Passkeyͱ • ݫີͳఆٛ: Discoverable CredentialΛ༻͍ΔWebAuthn • 伴ʹϢʔβʔ໊ͳͲΛηοτͰอଘ͢Δ • RP(αΠτ)ʹରͯ͠༻ՄೳͳIDͱެ։伴ͷϖΞΛྻڍͰ͖Δ •
ΫϥυಉظPasskey Auto fi llɺੜମೝূΛհͨ͠MFAͳͲɺ WebAuthnΛศརʹ͢ΔUXɺϢʔβʔʹWebAuthn͕͑ΔϩάΠ ϯํࣜͰ͋Δ͜ͱΛ͢͞ݴ༿ͱͯ͠ΘΕΔ
ຊͷνϟʔτ • ࣗݾհͳͲ 15:00 ʙ 15:05 • WebAuthnͱPasskeyͷ֓ཁ 15:05 ʙ
15:10 • Registration࣮ 15:10ʙ15:25 • Login࣮ 15:25ʙ15:35 • ·ͱΊ(όοϑΝ) 15:35ʙ15:40
Registrationͷϑϩʔ Ϣʔβʔ ϒϥβ ೝূث αʔόʔ ᶅొʹඞཁͳ ύϥϝʔλͩΑ ηογϣϯ challenge ᶃొ͍ͨ͠
ᶄ ᶆ͜ͷαΠτ༻ͷ 伴࡞ͬͯ ൿີ伴 ᶇ ᶈ࡞ͬͨ ެ։伴 ᶉ伴ͱchallengeͰ͢ ެ։伴 ᶊchallengeݕূ ᶋެ։伴Λอଘ
Registrationͷϑϩʔ https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API
AttestationObject • ೝূث͕ൃߦ͢Δূ໌ॻͳͲؚ͕·ΕΔใ • CBORܗࣜͰΤϯίʔυ͞Ε͍ͯΔ • ·ͨɺূ໌ॻ `authData` keyͷதʹόΠφϦͰؚ·Ε͍ͯΔ
AttestationObject ެ։伴ؚ͕·Ε͍ͯΔͷ͜͜ https://www.w3.org/TR/webauthn-3/# fi g-attStructs
AttestationObjectΛόΠφϦΤσΟλͰ͘
Attestation Objectͷunpack • a32: 32όΠτ όΠφϦจࣈྻ • N: ϏοάΤϯσΟΞϯ 32bit
unsigned int • n/a: 16bit unsigned intΛऔ্ͬͨͰͦΕΛ͞ͱΈͳͦ͠ͷόΠτΛͱΔ • a*: Γશ෦ όΠφϦจࣈྻ
COSEͷத https://zenn.dev/macopy/scraps/8f50c18 fb 0b164
ొ࣌ʹαʔόʔ͕Δݕূ https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API ҙ: ͜ͷϥΠϒίʔσΟϯάͰiiiͷҰ෦Λলུ͍ͯ͠·͢
ίϥϜ `attStmt` • attStmtެ։伴ͷॺ໊ݕূͳͲʹ༻͍ΒΕΔใ • YubikeyͳͲͷηΩϡϦςΟΩʔfmtʹ` fi do-u2f`͕ઃఆ͞Ε͍ͯΔ • `attStmt`ʹॻ͔Εͨূ໌ॻͱॺ໊Ͱਖ਼نͷηΩϡϦςΟΩʔ͔Βൃߦ͞Εͨൿ
ີ伴ɾެ։伴Ͱ͋Δ͜ͱ͕ݕূͰ͖Δ • ύεΩʔͰnone͕ઃఆ͞ΕΔ͜ͱ͕͋Δ • 1PasswordͰnone, iCloud KeychainͰ`packed`, Google Password ManagerͰ…, Windows HelloͰtpm
ຊͷνϟʔτ • ࣗݾհͳͲ 15:00 ʙ 15:05 • WebAuthnͱPasskeyͷ֓ཁ 15:05 ʙ
15:10 • Registration࣮ 15:10ʙ15:25 • Login࣮ 15:25ʙ15:35 • ·ͱΊ(όοϑΝ) 15:35ʙ15:40
Loginͷϑϩʔ https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API
AuthenticatorData https://www.w3.org/TR/webauthn-3/# fi g-authData
Կʹॺ໊Λߦͳ͍ͬͯΔ͔ • authenticatorData + sha256(clientDataJSON) https://www.w3.org/TR/webauthn-3/# fi g-signature
ೝূ࣌ʹαʔόʔ͕Δݕূ https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API
ຊͷνϟʔτ • ࣗݾհͳͲ 15:00 ʙ 15:05 • WebAuthnͱPasskeyͷ֓ཁ 15:05 ʙ
15:10 • Registration࣮ 15:10ʙ15:25 • Login࣮ 15:25ʙ15:35 • ·ͱΊ(όοϑΝ) 15:35ʙ15:40
·ͱΊ • WebAuthnެ։伴҉߸ͷੑ࣭Λར༻ͯ͠ύεϫʔυೝূͷམͱ݀͠ Λ௵͍ͯ͠Δ • ެ։伴͕࿙Ӯͯ͠ॺ໊Λੜ͢Δ͜ͱ͕Ͱ͖ͳ͍ • ੬ऑͳύεϫʔυ(=͍֮͑͢ύεϫʔυ)༻Ͱ͖ͳ͍ • ͍ճ͕͠Ͱ͖ͳ͍
• SpecΛಡΊPerlͰ࣮Ͱ͖Δͧ
·ͱΊ2 • ৭ʑෳࡶͳͷͰɺ͓ࣄͰϥΠϒϥϦΛͬͨํ͕ྑ͍ • PerlbatrossSimpleWebAuthn + Authen::WebAuthn • ࠓճͷίʔυΛॻ͘ͱ͖طଘͷϥΠϒϥϦͷதΛͨ͘͞Μࢀর͠ ·ͨ͠
• Specͷ͏͔ͪͳΓͷݕূΛͬ͢ඈ͍ͯ͠·͢ • ͚ͩͲΈΛ͍ͬͯΔͱσόοά͕ḿΔͷͰɺҰॻ͍ͯΈΔͱཧղ ͕ਂ·Γ·͢
ࢀߟจݙ • W3C Web Authentication: An API for accessing Public
Key Credentials Level 2 https://www.w3.org/TR/webauthn-2/ • mdn ΣϒೝূAPI https://developer.mozilla.org/ja/docs/Web/API/Web_Authentication_API • mercari engineering: WebAuthn͜ͱ͡Ί https://engineering.mercari.com/blog/entry/ 2019-06-04-120000/ • WEB+DB Press Vol.136 ಛू2 ࣮ઓೖύεΩʔ • Digital Identityٕज़ษڧձ Advent Calendar 2023 https://qiita.com/advent-calendar/2023/ iddance
See also • ImHexͰWebAuthnͷAttestationObjectΛύʔε͢Δ https:// zenn.dev/macopy/scraps/8f50c18fb0b164 • PerlͷCBOR::PPͱunpackͰWebAuthnͷAttestation ObjectΛύʔε ͢Δ
https://zenn.dev/macopy/scraps/e042aa351a57a7 • ࠓճͷ࣮ https://github.com/mackee/yapchiroshima2024
ϒϩάͰײ͓͓ͪͯ͠Γ·͢ʂ 🙏