note 118672 added to function.session-regenerate-id
| From: | tedivm at tedivm dot com | Date: | Sun, 17 Jan 2016 20:37:55 +0000 |
| Subject: | note 118672 added to function.session-regenerate-id | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204705@lists.php.net to get a copy of this message | ||
I wrote the current top voted comment on this and wanted to add something. The existing code from my
previous comment generates it's nonces in an insecure way-
<?php
$_SESSION['nonce'] = md5(microtime(true));
?>
Since "microtime" is predictable it makes brute forcing the nonce much easier. A better
option would be something that utilizes randomness, such as-
<?php
bin2hex(openssl_random_pseudo_bytes(32))
?>
----
Server IP: 72.52.91.14
Probable Submitter: 73.252.198.12
----
Manual Page -- http://php.net/manual/en/function.session-regenerate-id.php
Edit -- https://master.php.net/note/edit/118672
Del: integrated -- https://master.php.net/note/delete/118672/integrated
Del: useless -- https://master.php.net/note/delete/118672/useless
Del: bad code -- https://master.php.net/note/delete/118672/bad+code
Del: spam -- https://master.php.net/note/delete/118672/spam
Del: non-english -- https://master.php.net/note/delete/118672/non-english
Del: in docs -- https://master.php.net/note/delete/118672/in+docs
Del: other reasons-- https://master.php.net/note/delete/118672
Reject -- https://master.php.net/note/reject/118672
Search -- https://master.php.net/manage/user-notes.php