compare confidential data, such as cryptographic secrets, because the CPU time required for the comparison depends on the contents of the addresses compared, this function is subject to timing-based side-channel attacks. (機密データ(暗号シークレットなど)の比較にmemcmp()を使用しないでくだ さい。比較にかかるCPU時間は比較されるアドレスの内容に依存するため、こ の関数はタイミングベースのサイドチャネル攻撃を受けやすいです。)
length leaks. So it's OK to leak the length. The important part is that it doesn't leak information about the difference of the two strings. CSRFトークンやHMACの出力長は 公開情報(固定長) 攻撃者が知りたいのは 内容 であり、長さだけでは内容を推測できない hash_equals も長さが異なると即座に false を返すが、問題ないか? — ircmaxell's Blog "It's All About Time"
about timing attacks until I was confident that the other potential vectors are secured. ⚫ Rate Limiting: 攻撃に必要な数万〜数十万の試行を制限 ⚫ トークンのローテーション: 有効期限を短くして試行回数を制限 ⚫ 他の対策も重要: SQLi、XSS対策が優先 — ircmaxell's Blog "It's All About Time" 「実用的には、他の脆弱性対策ができてからタイミング攻撃を心配すべき」
to make it simpler for PHP developers to protect their applications. ⚫ 難しい定数時間比較の実装を開発者に任せない ⚫ hash_equals() を呼ぶだけで対策が完了する ⚫ 本発表のまとめでも紹介した「簡単に防げるなら防いでおく」はこの設計思想と同じ — RFC 本文(2013年12月)
で可決(賛成22 / 反対1) 実装時に hash_equals にリネーム RFC「Differences between this RFC and the implementation」に記載 hash_ プレフィックスの理由 RFCに「as part of ext/hash」と明記されている通り、hashモジュールの一部として実装 同モジュールの関数は慣例として hash_ プレフィックスを持つ hash_hmac, hash_file, hash_pbkdf2 等 →内部でハッシュ化しているわけではなく、所属モジュールに由来する命名