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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mackee
February 10, 2024
7k
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
350
perlをWebAssembly上で動かすと何が嬉しいの??? / Where does Perl-on-Wasm actually make sense?
mackee
0
1.1k
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
6
6k
今!ソフトウェアエンジニアがハードウェアに手を出すには
mackee
14
7.2k
ワンバイナリWebサービスのススメ
mackee
10
8.9k
tanukistack ライブコーディング / tanukistack live-coding
mackee
0
730
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
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Scaling GitHub
holman
464
140k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
220
Raft: Consensus for Rubyists
vanstee
141
7.6k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
190
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.6k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Ethics towards AI in product and experience design
skipperchong
2
330
How to train your dragon (web standard)
notwaldorf
97
6.7k
ラッコキーワード サービス紹介資料
rakko
1
4M
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
ϒϩάͰײ͓͓ͪͯ͠Γ·͢ʂ 🙏