【发布时间】:2014-06-17 11:20:09
【问题描述】:
在文章https://www.owasp.org/index.php/Insufficient_Session-ID_Length 您可以阅读有关会话猜测攻击的信息。
攻击者需要多长时间才能找到有效/活动会话?
B is the number of bits of entropy in the session identifier
A is the number of guesses an attacker can try each second
S is the number of valid session identifiers
that are valid and available to be guessed at any given time
大多数 PHP 默认设置使用 md5 散列(128 位)。
当我对 B 使用 128,对 A 使用 1000,对 S 使用 500 时,我得到的结果是 3,4028236692093846346337460743177e+32 秒,或者大约是 10790283070806014188970529,15499 年。
看起来还不错。我从未在任何小于 128 位的网站上看到任何会话,(问题:)还是我的假设有问题?
默认值是否安全?
现在使用这个(偏执模式)
ini_set('session.hash_function', 'sha512');
ini_set('session.hash_bits_per_character', 6);
ini_set('session.entropy_file', '/dev/urandom');
ini_set('session.entropy_length', 128);
生成会话 ID,例如:
K7ZvnlbRth5JbbJIRIDWdljiKHnP2fRrOVpCMxSbp9rO4OWzynraCon3O-Gfu9beuy2YGHEBpE14uvMzOfVvj3
【问题讨论】: