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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
kubo ayumu
March 25, 2025
Technology
2.9k
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.2k
やさしいActiveRecordのDB接続のしくみ
boro1234
14
9.3k
テーブル定義変更の ガイドラインを作った話
boro1234
2
2.1k
正規化理論ことはじめ -数学的背景から理解する正規化の初手-
boro1234
1
1.2k
RDBおける候補キーを求めるためのアルゴリズム
boro1234
0
1.3k
CakePHPの内部実装 から理解するPSR-7
boro1234
0
1.7k
Other Decks in Technology
See All in Technology
Let's Change Our World—Again
snoozer05
PRO
6
600
20261017福岡devIO 「AIは"良いダッシュボード"を作れるか?
jtakeda
0
260
QAエンジニアがSoutherを使ってみたの〜10分でわかるSouther〜
mhlyc
0
110
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
400
S3 Filesで挑む! 八戸せんべい汁の食べ頃問題
usanchuu
0
160
ガチで放置できるClaude Code実行環境の作り方.pdf
lamaglama39
5
9.3k
macOS Golden Gate 時代のMac管理
tategami
0
140
From Developer Experience to Agentic Experience: The Next Evolution of APIs
benjagm
0
120
AI コーディングと人間の認知スループット / CTO Night & Day 2026 Morning Session / AI Coding and Human Cognitive Throughput
prog893
5
1.5k
AWSセキュリティで活用するAI機能
cmusudakeisuke
1
280
2026-10-24 JAWS JAWS-UG 茨城 #18 IAM Policy Autopilotってなにさ。terraform planからIAM Policyつくれるの? / What's IAM Policy Autopilot
masasuzu
0
130
AI駆動開発における開発環境のセキュリティの考え方
yamahiro
2
510
Featured
See All Featured
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
500
The Cost Of JavaScript in 2023
addyosmani
55
10k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Product Roadmaps are Hard
iamctodd
55
13k
Large-scale JavaScript Application Architecture
addyosmani
516
110k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
950
Six Lessons from altMBA
skipperchong
29
4.5k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Ethics towards AI in product and experience design
skipperchong
2
440
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
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