Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
caching_sha2_passwordのはなし
Search
kubo ayumu
March 25, 2025
Technology
2.8k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
caching_sha2_passwordのはなし
https://mysql.connpass.com/event/345603/
kubo ayumu
March 25, 2025
More Decks by kubo ayumu
See All by kubo ayumu
MariaDB Connector/C のcaching_sha2_passwordプラグインの仕様について
boro1234
0
1.3k
大テーブルと小テーブルのJOINのコスト計算の話
boro1234
5
2.1k
やさしいActiveRecordのDB接続のしくみ
boro1234
14
9.2k
テーブル定義変更の ガイドラインを作った話
boro1234
2
2k
正規化理論ことはじめ -数学的背景から理解する正規化の初手-
boro1234
1
1.2k
RDBおける候補キーを求めるためのアルゴリズム
boro1234
0
1.3k
CakePHPの内部実装 から理解するPSR-7
boro1234
0
1.6k
Other Decks in Technology
See All in Technology
AIエージェントを最高のパートナーに育てる方法|評価と判断軸を育てる5つのステップ
koichiaoki
1
150
越境するなら専門用語を使うな高校校歌 / If you wanna cross border, you shouldn't use jargon
vtryo
0
140
データ界隈LT祭 第1回LT登壇
taromatsui_cccmkhd
2
1.4k
すぐできる衛星通信対応 あとは山奥に行くだけ
tatetate55
0
130
あけおめLINE 傾向とその対策
nasa9084
0
130
バイブコーディング時代のWebアプリ開発入門~Cloud Runで学ぶセキュアなビルドとデプロイ
waiwai2111
1
140
データ_AIの事業の勝敗をわけるもの
nek0128
1
450
エージェントはローカル、検証はMicroVM — Lambda MicroVMsでつくるServerless CI
fujioka6789
3
300
Cloudflare Workers 向けアプリを C# で構築する ~WASM Native AOT への道~
nenonaninu
1
260
AI 時代のスタートアップエコシステ厶から考究する技術的負債との向き合い方
m3m0r7
PRO
3
2.2k
銀行勘定系システムにおける開発プロセス刷新×AIによる環境モダナイゼーション / Development Process Transformation and AI-Driven Environment Modernization
muit
1
2.3k
Claude Codeを「使うほど育つ」AI秘書にするノウハウ
minorun365
PRO
31
27k
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
850
First, design no harm
axbom
PRO
2
1.3k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.1k
Being A Developer After 40
akosma
91
590k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
For a Future-Friendly Web
brad_frost
183
10k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Transcript
caching_sha2_passwordの はなし MySQL30周年&ユーザ会25周年記念イベント @amamanamam
くぼ • DBREやってます • MySQL 8.0から仲良くなり始めました • ビールをよく飲みます • Xはこちら
◦ https://twitter.com/amamanamam
皆さん caching_sha2_password 移行の準備は できていますか?
ということで caching_sha2_password について簡単に まとめてきました
アジェンダ ・前提 ・mysql_native_passwordの仕様の話 ・sha256_passwordの仕様の話 ・caching_sha2_passwordの仕様の話
アジェンダ ・前提 ・mysql_native_passwordの仕様の話 ・sha256_passwordの仕様の話 ・caching_sha2_passwordの仕様の話
前提 • MySQL 8.0と8.4LTSでは caching_sha2_passwordがデフォルト • MySQL8.4LTSでは mysql_native_passwordが無効 • MySQL9.0
Innovation Releaseでは mysql_native_passwordが廃止
前提 • AuroraMySQL V3では mysql_native_passwordがデフォルト • AuroraMySQL V4(?)でやっと caching_sha2_passwordがデフォルトに なったりするかな...?
前提 https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_lifecycle.html
前提 • ServerGreeting ◦ Initial Handshake packetの送信 ◦ default_authentication_pluginで設定されている認証プ ラグインを送信
• LoginRequest ◦ Initial Handshake packetの応答 ◦ クライアント側で使用する認証プラグインを送信 ◦ その後サーバー側でmysql.userのpluginを確認
前提 • AuthSwitchRequest/Response ◦ ユーザの認証プラグインが期待されている認証プラグイ ンと異なった時に、使用すべき認証プラグインを送信
アジェンダ ・前提 ・mysql_native_passwordの仕様の話 ・sha256_passwordの仕様の話 ・caching_sha2_passwordの仕様の話
mysql_native_passwordの仕様の話 • パスワードハッシュ(SHA-1)を用いたチャレンジ&レスポンス認 証 • ユーザ作成を行うと、mysql.userのauthentication_stringカラ ムにSHA1(SHA1(passwors))の結果が格納される mysql> create user
kubo identified with 'mysql_native_password' by 'password'; Query OK, 0 rows affected (0.27 sec) mysql> select Host,User,plugin,authentication_string from mysql.user where User='kubo'; +------+------+-----------------------+-------------------------------------------+ | Host | User | plugin | authentication_string | +------+------+-----------------------+-------------------------------------------+ | % | kubo | mysql_native_password | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | +------+------+-----------------------+-------------------------------------------+ 1 row in set (0.03 sec)
mysql_native_passwordの仕様の話 • サーバ側からクライアント側に20バイトのランダムデータが 送信され、クライアント側で以下の計算をしてサーバーに送 信 SHA1( password ) XOR SHA1(
"20-bytes random data from server" <concat> SHA1( SHA1( password ) ) ) • サーバーはSHA1(SHA1( password ))とランダムデータの値 を知っているので、それらとクライアントから送られてきた計 算結果にXORとSHA1を作用させることで、パスワードハッ シュを照合
アジェンダ ・前提 ・mysql_native_passwordの仕様の話 ・sha256_passwordの仕様の話 ・caching_sha2_passwordの仕様の話
sha256_passwordの仕様の話 • パスワードハッシュ方式(SHA-256)に基づいた認証 • salt付きでハッシュ化されるため、同じパスワードのユーザ作 成でも異なるauthentication_stringの値となる mysql> create user kubo1
identified with 'sha256_password' by 'password'; Query OK, 0 rows affected (0.03 sec) mysql> create user kubo2 identified with 'sha256_password' by 'password'; Query OK, 0 rows affected (0.03 sec) mysql> select Host,User,plugin,SUBSTR(HEX(authentication_string), -10) from mysql.user where User in ('kubo1','kubo2'); +------+-------+-----------------+-----------------------------------------+ | Host | User | plugin | SUBSTR(HEX(authentication_string), -10) | +------+-------+-----------------+-----------------------------------------+ | % | kubo1 | sha256_password | 736D4A6132 | | % | kubo2 | sha256_password | 7631786841 | +------+-------+-----------------+-----------------------------------------+
sha256_passwordの仕様の話 • パスワードをプレーンテキストで送る必要があるため、 SSL/TLSやRSA暗号鍵でのセキュアな接続を必要とす る
アジェンダ ・前提 ・mysql_native_passwordの仕様の話 ・sha256_passwordの仕様の話 ・caching_sha2_passwordの仕様の話
caching_sha2_passwordの仕様の話 • パスワードハッシュ方式(SHA-256)に基づいた認証 • クライアント・サーバー間のやり取りには以下の2つのフェー ズがある ◦ Fast authentication ◦
Complete authentication
caching_sha2_passwordの仕様の話 • Fast authenticationではmysql_native_passwordのように まずサーバーからクライアントへランダムデータを送る • クライアントでは以下の計算結果をサーバーに送る XOR(SHA256(password), SHA256(SHA256(SHA256(password)), Nonce))
• サーバー側では該当ユーザのパスワードハッシュの値が キャッシュ内にあるか確認 • そこでもし見つかれば、クライアントから送られてきた計算結 果にその値とランダムデータの値をXORとSHAを作用させる ことで、パスワードハッシュの照合
caching_sha2_passwordの仕様の話 • キャッシュ内に何も見つからなければComplete authenticationのフェーズに入る • Complete authenticationでは、sha256_passwordのように SSL/TLS接続もしくはRSA暗号化通信がなされた状況下で パスワードをそのまま受け取って照合を行う
caching_sha2_passwordの仕様の話 • キャッシュ内に何も見つからなければComplete authenticationのフェーズに入る • Complete authenticationでは、sha256_passwordのように SSL/TLS接続もしくはRSA暗号化通信がなされた状況下で パスワードをそのまま受け取って照合を行う
まとめ • caching_sha2_passwordはmysql_native_passwordと sha256_passwordを組み合わせたような認証プラグイン • 1回目の認証はsha256_passwordのようにセキュアな経路 を必要とする • 2回目以降はキャッシュ内のパスワードハッシュに基づいて mysql_native_passwordのような認証を行う
参考 • Protecting MySQL Passwords With the sha256_password Plugin •
MySQL 8.0.4 : New Default Authentication Plugin : caching_sha2_password • Caching_sha2_password information