日向夏特殊応援部隊

俺様向けメモ

"OpenID: Single Sign-On for the Internet" を読んだ (2)

Negotiating crypto keys

associate の時に DH 鍵交換を行う際に潜む問題点です。

何が問題なのか
In the original description, the Diffie-Hellman exchange by itself does not provide authentication of the communicating parties and is thus vulnerable to a man-in-the-middle attack. A person in the middle may establish two distinct Diffie-Hellman key exchanges, one with Alice and the other with Bob, effectively masquerading as Alice to Bob, and vice versa, allowing the attacker to decrypt (and read or store) then re-encrypt the messages passed between them. A method to authenticate the communicating parties to each other is generally needed to prevent this type of attack.
に書いてあるんですけど man-in-the-middle attack (中間者攻撃) に弱いって事が DH 鍵交換の欠点みたいです。どういう事かと言うと、二者間で互いに相手が本当に期待する相手であるならば問題は無いんですが、それが保証されていない場合に問題になってしまいます。 最近話題になってた ARP Spoofing だとか、DNS Spoofing と言った手法で、中間者が存在する場合、中間者が二者それぞれと DH して橋渡ししてあげれば、見た目上は期待通りの挙動をしつつ、中身はすっぱ抜かれるよねって事ですね。

まとめ

SSL/TLS などの https を使えと。 その場合はメッセージ自体が安全になるから DH 鍵交換は使わないでも良い。 spec には、DH 鍵交換 + http を止めて https のが RECOMMENDED だよとは書いてない気がする。

追記 (2008-06-13T18:22:03+09:00)

https を使う場合の association の補足
id:machu さんにブクマコメントで突っ込まれてた件ですが、
SSL/TLS などの https を使えと。 その場合はメッセージ自体が安全になるから DH 鍵交換は使わないでも良い。」←鍵交換しないとレスポンスのメッセージ検証ができないよね / 「DH」じゃなくて鍵をplainに送るという話かな?
鍵交換しないとメッセージの署名出来ないから当然するんだけど、知らない人の為に一応解説すると、association は、
  • association を行う
    • DH 鍵交換を行う
      • openid.session_type が "DH-SHA1" または "DH-SHA256"
    • DH 鍵交換を行わない
      • openid.session_type が "no-encryption"
      • この場合は OP からのレスポンスで mac_key が返って来るので、これを共通の鍵として使う
  • association を行わない
    • Stateless モードになって、後でcheck_authenticationを実行しなければならない
って感じになってる。 id:machu さんが言ってる鍵交換ってのは、DH 鍵交換しない時に OP が生成するmac_keyの値で、これは平文で送られて来るので https じゃないと使ってはいけない事になっている。 詳しくは、OpenID Authentication 2.0 - Final # 8. Establishing Associations を見て下さい。 association は今後ちゃんと書く予定。
結局 DH鍵交換 + http と plain text で渡される mac_key + https のどちらを使うべきか
https を用意出来るなら後者を選択すべき。と言うのは DH 鍵交換における中間者攻撃の危険性があるのでと言う事は前述の通りです。