From a067868b732984b0f958b62f7360dc2eca06f783 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 20 Nov 2014 16:06:14 +0000 Subject: [PATCH] Prevent high resource usage when hashing large passwords. props mdawaffe, pento Merges [30466] to the 3.9 branch. Built from https://develop.svn.wordpress.org/branches/3.9@30468 git-svn-id: http://core.svn.wordpress.org/branches/3.9@30459 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-phpass.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wp-includes/class-phpass.php b/wp-includes/class-phpass.php index 1970ae9da4..f2dadae3ff 100644 --- a/wp-includes/class-phpass.php +++ b/wp-includes/class-phpass.php @@ -214,6 +214,10 @@ class PasswordHash { function HashPassword($password) { + if ( strlen( $password ) > 4096 ) { + return '*'; + } + $random = ''; if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) { @@ -249,6 +253,10 @@ class PasswordHash { function CheckPassword($password, $stored_hash) { + if ( strlen( $password ) > 4096 ) { + return false; + } + $hash = $this->crypt_private($password, $stored_hash); if ($hash[0] == '*') $hash = crypt($password, $stored_hash);