Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124610 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 403D31A00B7 for ; Fri, 26 Jul 2024 12:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721998379; bh=wyhHYHjarsoak8TygB6qFgLTZDhce0hBnDKnHe9W0Ns=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=Lu80gUczM55/BCjuFKwT/rMMrUcsOMbdEPy+73JwhmVkwKVX/CwW6RM5BcPoNHBDb 8p2BIY74repk4Jy35ZtBR621CnQ4MgLv6ZYnjHv93obR3hx4xwfTSh9PV/eBxV2y1E g6Sa0cW8PLOsNYzwfaUXoRvxacmeeiiwhs/1/l+ZyfmRV4e4AvGtwhhKPvOH2qSwW3 9MtMVEwxcgtDtAHfa+Dna4PFUViCMWZEK/6R7uVCYLmttZ+ggCjdBJKmWBsauU2Kdh sTNAlZuvQ87WpjeKMQwfeYyEnDvhLhnkXh+FT226XTDECCEE4hT58A9oC1LPBQWVH6 S4V00OUyjIXHA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 46E3918005B for ; Fri, 26 Jul 2024 12:52:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh1-smtp.messagingengine.com (fhigh1-smtp.messagingengine.com [103.168.172.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 26 Jul 2024 12:52:57 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfhigh.nyi.internal (Postfix) with ESMTP id B7F66114019A; Fri, 26 Jul 2024 08:51:21 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute3.internal (MEProxy); Fri, 26 Jul 2024 08:51:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1721998281; x= 1722084681; bh=0hn8RuMGc3pNn+LhZ/WeNkpYBMGY6fCpyjVXz3b/QmI=; b=k suBvvk0fuk3mhpYQM8TO1rvBu1JldQFs8sn7pfLxu9nIukCGFNgXWpJPlJXWg++U JCGEdEFej9ZbjtEC2oT6daj2b+q5LSdiagoqpe1oy9y1q48B9MIgx9pA80uMtDyY YZ1bncQyv9c71HdayOg4P43Y2DWrFwte9Z+FkO1dWyMdEHfvKSnw+vXmGJwbXdug L4Bqaro+G23uMJT/2bYXOCrqkQ8fRG3sbo4ozLtNWNAieKaxi3o0fHRaIc7+BsZc 3/+AczRLFffyTD84Bw1Ia8vw7vtJo8dJ+0hDu2UZyJYMYowtIBuctwXkNZmtS6mt 2yeZeozNqmtzvN2wVL9FA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1721998281; x=1722084681; bh=0hn8RuMGc3pNn+LhZ/WeNkpYBMGY 6fCpyjVXz3b/QmI=; b=hvbXo1IpnnWf/G/27ZtU1iCd5CMOd9ALMR252EaRz81N V113yS+/lVWfQbm8jrmMp3kC2kVIz8j7sxXjfffy7MNWzYWzSwwqmqUhFgXvzDpo 9u/2OM6ndI+i2yM3TSsrxmR3NWkXkD1rVYLjZODgFkGR54AHqQZrxQzFz43YhSQZ lShwTa8dRdZyT7TpGgCxmJZG6mH+sIm07oBE72WUzvLRpdivLjqQazhcaht8ML2R VFjPwB2Z1U4xMcvxC3z3cTjXcl6vkdq5OEap1L0phJ696zWxJ4yJiXHv6xisk6iT dbibvwMfK6I6EsGlWq3a+ADo48VPgr+XRPG64JhXHg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrieehgdehkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesrgdtreerreerjeenucfhrhhomhepfdftohgs ucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrg htthgvrhhnpeeuvedukedvgeetfeehkeeuhfejjeekudeiveefuddugeelgfduueejfedt hfeiudenucffohhmrghinhepphhhphhtuhhtohhrihgrlhdrnhgvthenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggu rdgtohguvghspdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 24C5615A0092; Fri, 26 Jul 2024 08:51:21 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-582-g5a02f8850-fm-20240719.002-g5a02f885 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Message-ID: In-Reply-To: <6c0baa01-68e5-4d74-bc4e-d6830ab5076d@bastelstu.be> References: <1a88918e-e808-d778-45e1-53797660e093@php.net> <95147d9d-d6e8-4396-bf0b-409c33679f90@bastelstu.be> <6c0baa01-68e5-4d74-bc4e-d6830ab5076d@bastelstu.be> Date: Fri, 26 Jul 2024 14:50:58 +0200 To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , "Peter Stalman" Cc: "Derick Rethans" , "PHP internals" Subject: Re: [PHP-DEV] [RFC] [VOTE] Deprecations for PHP 8.4 Content-Type: multipart/alternative; boundary=96c1010f7e1e490494dac26c87562337 From: rob@bottled.codes ("Rob Landers") --96c1010f7e1e490494dac26c87562337 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Jul 26, 2024, at 13:58, Tim D=C3=BCsterhus wrote: > Hi >=20 > On 7/26/24 08:35, Peter Stalman wrote: > > How prevalent is this exactly? PHP 4 ended support in 2008. I think > > putting warning labels on these things in the docs is enough, but we= can't > > go around locking up every kitchen knife just because there are some= idiots > > out there who read a book from the 50s about the war. >=20 > I just Googled "PHP tutorial" and found https://www.phptutorial.net/ a= s=20 > the second search result, which considers itself to be "the modern PHP=20 > tutorial". >=20 > I've clicked at the CSRF section=20 > (https://www.phptutorial.net/php-tutorial/php-csrf/) and what do I fin= d: >=20 > > $_SESSION['token'] =3D md5(uniqid(mt_rand(), true)); >=20 > *Exactly* the md5-uniqid construction that is called out as unsafe in=20 > the RFC and used in a security context. In regards to hashing, this is likely fine; for now. There still isn't a= n arbitrary pre-image attack on md5 (that I'm aware of). Can you create = a random file with a matching hash? Yes, in a few seconds, on modern har= dware. But you cannot yet make it have arbitrary contents in our lifetim= e. The NSA probably has something like this though, but if so, this isn'= t widely known. That being said, this is just randomly creating a random id without leak= ing it's internal construction, no different than putting an md5 in a UU= ID-v8. The real issue here is the use of uniqid() and rand(), making it = quite likely (at scale, at least) that a session id will overlap with an= other session id. =E2=80=94 Rob --96c1010f7e1e490494dac26c87562337 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Fri, Jul 26,= 2024, at 13:58, Tim D=C3=BCsterhus wrote:
Hi

On 7/26/= 24 08:35, Peter Stalman wrote:
> How prevalent is this = exactly? PHP 4 ended support in 2008.  I think
> p= utting warning labels on these things in the docs is enough, but we can'= t
> go around locking up every kitchen knife just becau= se there are some idiots
> out there who read a book fr= om the 50s about the war.

I just Googled "P= HP tutorial" and found htt= ps://www.phptutorial.net/ as 
the second search r= esult, which considers itself to be "the modern PHP 
= tutorial".

I've clicked at the CSRF section=  

> $_SESSION['token'] =3D= md5(uniqid(mt_rand(), true));

*Exactly* th= e md5-uniqid construction that is called out as unsafe in 
the RFC and used in a security context.

In regards to hashing, this is likely fine; for now. The= re still isn't an arbitrary pre-image attack on md5 (that I'm aware of).= Can you create a random file with a matching hash? Yes, in a few second= s, on modern hardware. But you cannot yet make it have arbitrary content= s in our lifetime. The NSA probably has something like this though, but = if so, this isn't widely known.

That being = said, this is just randomly creating a random id without leaking it's in= ternal construction, no different than putting an md5 in a UUID-v8. The = real issue here is the use of uniqid() and rand(), making it quite likel= y (at scale, at least) that a session id will overlap with another sessi= on id.

=E2=80=94 Rob
--96c1010f7e1e490494dac26c87562337--