SlideShare a Scribd company logo
1 of 21
Download to read offline
SQLアンチパターン
19章 リーダブルパスワード
(読み取り可能パスワード)
Name : Naoya ISHII
Twitter :@naopi
TAG:
SIer(), JAVA,
Father,
Frontale supporter
アジェンダ
目的
 パスワードのリカバリーとリセットを行う
アンチパターン
 パスワードを平文(復号可能な形)で格納する
解決策
 ソルトをつけてパスワードハッシュを格納する
パスワードのリカバリとリセットを行う
とある認証付きシステムを利用しているユーザが
パスワードを忘れてしまった。
利用ユーザ自身でパスワードの再通知やリセットを行えるよう
にしたい
アンチパターン
パスワードを平文で格納する
パスワードの格納で想定されるリスク
● ネットワークパケット上のSQL文を傍受することが容易に行わ
れる。
● データベースサーバやアプリケーションログのSQLクエリログ
を探しだされてしまう。
● データベースのバックアップファイルやバックアップメディアか
らデータを読み込まれてしまう。
ID、パスワードが正しければ1以上!!
〃 が無い(誤り)なら0
IDが存在しなくても0!!!
SELECT COUNT(*) as password_mathes
FROM Account
WHERE account_id = '1234'
AND password = 'opensesame' ;
パスワードの認証時の問題
認証の失敗した原因が
パスワードの誤りなのか?
ID自体が存在しないのか?
(´・ω・`)ワカラン
ログインを複数失敗したらロックをかけたい
パスワードの誤りならロックかける
けど?
(´・ω・`)ドッチヤネン
パスワードの認証時の問題
SELECT CASE WHEN password = 'opensesame'
  THEN 1 ELSE 0 END as password_mathes
FROM Account
WHERE account_id = '1234';
指定したpasswordがあれば1を、無い(誤り)であれば0
を、アカウントが存在しなければNotFoundを返すSQL
ログインエラーのメッセージについて
「ユーザが存在しません」
「パスワードに誤りがあります」
参考:9-3. エラーメッセージからの情報暴露 : https://www.ipa.go.
jp/security/awareness/vendor/programmingv1/b09_03.html
「ユーザまたはパスワードに誤りが
あります」
パスワードを電子メールで送信する
From: deamon
To: bill@example.com
Subject: パスワードのリクエスト
いつもお世話に〜〜〜〜
アカウント「bill」の再通知リクエストに回答します。
新しいパスワードは「 xhsyd0ak」です。
 
よろしく
論外!!
メールは傍受される危険性
が非常に高い。
アンチパターンを用いてもいい場合
(平文パスワード格納してもいい場合)
● アプリケーションが外部のサービスにアク
セスする
(パスワードを内部に持つ)
● イントラネット内で少人数で使う
「そのシステム、ウチ(外部)でも使えるようにしてよ」案件
解決策
ソルトを付けてパスワードハッシュを格納す
る
ハッシュ関数
 入力内容を識別不可能なハッシュと呼ばれる文字列に
変換する
SHA2('xyzzy', 256) = ‘1184828a00……….’
vsレインボークラック
速いCPUを使うことによって総当たりでハッシュ値の
検索をかけるよりもさらに高速にパスワードの解読を
行う方法がある。
レインボーテーブルの参照
レインボーテーブル
ハッシュ値の逆引き辞書
そこから高速にパスワードを求める
解決策
暗号化前のパスワードにソルトを付ける
ソルトあり
SHA2(‘password’ || ‘G0y6cf3’, 256)
= ‘0c4dd4eea2d53306a0d11e31e1a28cf339ec6113’
ソルト(赤字)の文字列はパスワードごとに用意し攻撃者の用意
するレインボーテーブルを複雑化させる。
解決策
SQLからパスワードを隠す
ログファイルの漏洩
SQL上では平文として利用せずに
アプリケーションでハッシュ計算
ネットワークパケットの傍受
セキュアHTTP(HTTPS)の利用
リカバリーではなくリセットする
一時パスワードを電子メールで送付
 記載しているパスワードは短時間で無効化する
 初回ログイン時に強制的に更新させる
一意のトークンを生成し送付する
 そのトークンをキー(識別子)としてパスワード管理テーブルのアカウ
ントと紐付ける
さいごに
教諭になりすまし成績など入手 クラス編成をLINEで流す
滋賀の高校
県教委と学校によると、男子生徒は当時2年だった2月、卒業式の準備でほかの生徒が教諭の
パソコンを使用した際に メモされたパスワードと画面表示されたIDを暗記 。3月中旬にコンピュー
ター教室のパソコンから校務用サーバーにアクセスし、入手した情報をUSBメモリーに保存し
た。
つい最近こんな事件も・・・・
「あなたが読み取れるものは、
攻撃者にも読み取れます」
おしまい

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

[Sqlap]リーダブルパスワード