Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95242 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10712 invoked from network); 16 Aug 2016 20:57:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Aug 2016 20:57:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:33741] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/4A-36656-22E73B75 for ; Tue, 16 Aug 2016 16:57:09 -0400 Received: (qmail 131032 invoked by uid 89); 16 Aug 2016 20:57:03 -0000 Received: from unknown (HELO mail-qk0-f181.google.com) (yohgaki@ohgaki.net@209.85.220.181) by 0 with ESMTPA; 16 Aug 2016 20:57:03 -0000 Received: by mail-qk0-f181.google.com with SMTP id v123so83501770qkh.2 for ; Tue, 16 Aug 2016 13:57:02 -0700 (PDT) X-Gm-Message-State: AEkoousOIoboLYcJzv1rSavSUDhoRj8JDVbo2cacvUc+mI3ACVCUiZW7Fl1z2heBWTu14WpIKlxSLiiCWkAerQ== X-Received: by 10.55.130.130 with SMTP id e124mr19871943qkd.51.1471381016991; Tue, 16 Aug 2016 13:56:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.85.242 with HTTP; Tue, 16 Aug 2016 13:56:16 -0700 (PDT) In-Reply-To: References: <592333a7-2c73-38a4-b400-f3f2c7bf2f72@lsces.co.uk> Date: Wed, 17 Aug 2016 05:56:16 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Tom Worster Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC][VOTE] Add session_create_id() function From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi Tom, On Tue, Aug 16, 2016 at 9:08 PM, Tom Worster wrote: >>> I strongly disagree with this kind of attitude. >>> >>> If there are users who really do not want collision detection at all, >>> they should do it by their own responsibility and risk. >> >>Above discussion is added to the RFC. >> >>The default 128 bits Session ID is large enough to ignore collisions >>https://wiki.php.net/rfc/session-create-id#discussions >> >>It describes for an application, but PHP is a platform. >>There are millions PHP apps or more and there could be billions of >>active sessions. There could be tens of thousands new session IDs or >>more are created. Apply the calculation for expected time of possible >>collision. >> >>Do you still sure "There will be no collisions at all"? > > The calculation underestimates the difficulty of finding collisions by 38 > decimal orders of magnitude. The number of different SIDs in default PHP > config is 2^192, not 2^64. So yes, I am still sure. In theory, there wouldn't be collisions if CSPRNG is truly random that will never has collided values at any given chunks. 128 bits session ID would be far good enough. Problem is we can measure CSPRNG is producing acceptable random for apps requires randomness, but it is difficult making sure the random stream will _never_ has collision. (I'm not saying CSPRNG is not generating secure random. For most usages of random stream do not require uniqueness. Session module is special and requires collision free results for all CSPRNG.) Solution is simple for session database. All we have to do is validating newly generated session ID would not collide existing one. This is done by session module currently. Why not for new API that is supposed to generate 120% secure session ID? If users do not want 120% secure session ID, but almost 100% secure session ID is enough and would like to skip the validation. They may do if (session_ status() == PHP_SESSION_ACTIVE) session_commit(); session_id(session_create_id()); // Session is inactive, no collision check session_start(); by their own decision and risk. IMHO, other way around should not be the default. NOTE: Users will need to call session_create_id() for regenerating session ID. Therefore, there should be active session already. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net