On 16.01.2017 at 08:04, Yasuo Ohgaki wrote:

> Since I was about to improve uniqid()'s entropy by replacing
> php_combined_lcg() to php_random_int(), I spent time to check other places
> that could be a problem.
> 
> mt_rand()'s is seeded as follows by default.
> 
> ext/standard/php_rand.h
> #ifdef PHP_WIN32
> #define GENERATE_SEED() (((zend_long) (time(0) * GetCurrentProcessId())) ^
> ((zend_long) (1000000.0 * php_combined_lcg())))
> #else
> #define GENERATE_SEED() (((zend_long) (time(0) * getpid())) ^ ((zend_long)
> (1000000.0 * php_combined_lcg())))
> #endif
> 
> We know this kind of seed is guessable. 

But where's the problem?  mt_rand() is not suitable for cryptographic
purposes anyway.

> i.e. Our session id is compromised
> by this kind of code.

Does the session ID rely on mt_rand() or GENERATE_SEED()?  If so, that
would of course be an issue, but that should be fixed by not using
mt_rand()/GENERATE_SEED() for the session ID at all, IMHO.

-- 
Christoph M. Becker

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to