瀏覽代碼

Fix cryptographically insecure CSRF tokens

Arinerron 9 年之前
父節點
當前提交
2f5c7a10b7
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      web/login/index.php

+ 1 - 1
web/login/index.php

@@ -126,7 +126,7 @@ if (empty($_SESSION['language'])) {
 }
 
 // Generate CSRF token
-$_SESSION['token'] = md5(uniqid(mt_rand(), true));
+$_SESSION['token'] = bin2hex(openssl_random_pseudo_bytes(16)); // generate 32-character cryptographically secure token
 
 require_once($_SERVER['DOCUMENT_ROOT'].'/inc/i18n/'.$_SESSION['language'].'.php');
 require_once('../templates/header.html');