mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge branch 'develop-olympus' into develop
* develop-olympus: [prep-release-3.0.12] Update changelog for 3.0.12 release. [ticket/11873] Add unit test for large password input. [ticket/11873] Do not hash very large passwords in order to safe resources.
This commit is contained in:
commit
787784e083
3 changed files with 16 additions and 0 deletions
|
@ -211,6 +211,7 @@
|
||||||
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-11368">PHPBB3-11368</a>] - Latest pm reports row count</li>
|
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-11368">PHPBB3-11368</a>] - Latest pm reports row count</li>
|
||||||
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-11583">PHPBB3-11583</a>] - InnoDB supports FULLTEXT index since MySQL 5.6.4.</li>
|
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-11583">PHPBB3-11583</a>] - InnoDB supports FULLTEXT index since MySQL 5.6.4.</li>
|
||||||
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-11740">PHPBB3-11740</a>] - Update link in FAQ to Ideas Centre</li>
|
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-11740">PHPBB3-11740</a>] - Update link in FAQ to Ideas Centre</li>
|
||||||
|
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-11873">PHPBB3-11873</a>] - Prevent expensive hash computation in phpbb_check_hash() by rejecting very long passwords</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h4>Sub-task</h4>
|
<h4>Sub-task</h4>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -442,6 +442,13 @@ function phpbb_hash($password)
|
||||||
*/
|
*/
|
||||||
function phpbb_check_hash($password, $hash)
|
function phpbb_check_hash($password, $hash)
|
||||||
{
|
{
|
||||||
|
if (strlen($password) > 4096)
|
||||||
|
{
|
||||||
|
// If the password is too huge, we will simply reject it
|
||||||
|
// and not let the server try to hash it.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||||
if (strlen($hash) == 34)
|
if (strlen($hash) == 34)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,5 +17,13 @@ class phpbb_security_hash_test extends phpbb_test_case
|
||||||
$this->assertTrue(phpbb_check_hash('test', '$P$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
|
$this->assertTrue(phpbb_check_hash('test', '$P$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
|
||||||
$this->assertFalse(phpbb_check_hash('foo', '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
|
$this->assertFalse(phpbb_check_hash('foo', '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_check_hash_with_large_input()
|
||||||
|
{
|
||||||
|
// 16 MB password, should be rejected quite fast
|
||||||
|
$start_time = time();
|
||||||
|
$this->assertFalse(phpbb_check_hash(str_repeat('a', 1024 * 1024 * 16), '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
|
||||||
|
$this->assertLessThanOrEqual(5, time() - $start_time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue