Skip to content

Commit

Permalink
Use phpseclib's Crypt::Random to generate CSRF token
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Jan 19, 2016
1 parent dbb2673 commit f20970d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libraries/session.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
exit;
}

require PHPSECLIB_INC_DIR . '/Crypt/Random.php';

// verify if PHP supports session, die if it does not

if (!@function_exists('session_name')) {
Expand Down Expand Up @@ -111,7 +113,7 @@
* (we use "space PMA_token space" to prevent overwriting)
*/
if (! isset($_SESSION[' PMA_token '])) {
$_SESSION[' PMA_token '] = md5(uniqid(rand(), true));
$_SESSION[' PMA_token '] = bin2hex(phpseclib\Crypt\Random::string(16));
}

/**
Expand All @@ -130,5 +132,5 @@ function PMA_secureSession()
) {
session_regenerate_id(true);
}
$_SESSION[' PMA_token '] = md5(uniqid(rand(), true));
$_SESSION[' PMA_token '] = bin2hex(phpseclib\Crypt\Random::string(16));
}

0 comments on commit f20970d

Please sign in to comment.