Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97811 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96959 invoked from network); 17 Jan 2017 14:49:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jan 2017 14:49:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=leight@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=leight@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.51 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 209.85.215.51 mail-lf0-f51.google.com Received: from [209.85.215.51] ([209.85.215.51:33883] helo=mail-lf0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3A/D4-00729-CDE2E785 for ; Tue, 17 Jan 2017 09:49:01 -0500 Received: by mail-lf0-f51.google.com with SMTP id v186so109751933lfa.1 for ; Tue, 17 Jan 2017 06:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=HVZhvvF6KD3nxzx7Em/86mN2vjI0cslWbKihHzEsHN8=; b=cmOchALGxiLuNh/LTwV3x2QMCzQll4X2wC3VCdsMoerid9CaGxDDr1T+9GBUm+s0d3 kBbmA0koZup1OHbui8MI0ZTZZ6/7xGZXF89L9njc5siJB3QO6SR0EgkFbAgB6eT/nJrP m9Zek9UDHS3X6EeHZk3h8nKnEFDiafB0JqueyAvpB/XNbNGplssp4euIlRLTQinAfI68 WhKpdD1Nh4Lx7OBXSxMjW1O+1hTAx16JjnlQ7mTj1X7MM5bHirshAoBgyRSLeZhf3wL4 0uihFmFTf/v7TXJB7LGgvtXc+kIn9fpT0vX42wZooopddTB42mjb1KCZV4H4PJTBCKxz 80Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=HVZhvvF6KD3nxzx7Em/86mN2vjI0cslWbKihHzEsHN8=; b=uLD5lUrB6uVSgi0Vs0QxKzulbqXCrUy1rjWmOMM1zZOvwgIzUOzn5oEVIwxZxIfM4j y8r91xmvuj8fj9OO8gLNggZXl5ZygC1WeNcuR1RnFj+dLVx5RPmQx+HdTpMbMGcVFkDT XLXK7v2/7CR/JBLID6/uqU9ID1EAHEIqocSTF7HlINu+YWXWiXcNRVMIDqV4wV17d/+R ahOouEStfGKVelE+hr/cl8GnCFAp5wrcalzspkr668L6ha6mkp8H6AXrfEXHYZ+ld89c sUrtVYLk60JnyWGHvvU2ERKJR0GVxtSuz7uLqkP4m7JAQJ2txxwrUG4KvQgUGPx4n1dL sL2g== X-Gm-Message-State: AIkVDXIEP4snCrr6FOkrP15BWBfXeJsfQowVgGHDg/+CVfMCAPiso3e5lnff5zgvK3vnPgLB85Rt1povBM84vA== X-Received: by 10.25.39.4 with SMTP id n4mr7291462lfn.0.1484664536557; Tue, 17 Jan 2017 06:48:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.193.83 with HTTP; Tue, 17 Jan 2017 06:48:55 -0800 (PST) In-Reply-To: References: Date: Tue, 17 Jan 2017 14:48:55 +0000 Message-ID: To: Yasuo Ohgaki Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Improving mt_rand() seed From: leight@gmail.com (Leigh) On 16 January 2017 at 07:04, Yasuo Ohgaki wrote: > Hi all, > > 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. i.e. Our session id is compromised > by this kind of code. mt_rand is not advertised as crypto-quality. Where do you think mt_rand is used in session id generation? > > Although it would be rare that raw mt_rand() value is exposed, but > guessable value is guessable. I'm going to replace the seeding code by > simple php_random_int() call. > > Any comments? > > Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net