Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112365 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 76295 invoked from network); 2 Dec 2020 08:51:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Dec 2020 08:51:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C390D1804C3 for ; Wed, 2 Dec 2020 00:18:44 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,SPF_HELO_NONE, SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from darkcity.gna.ch (darkcity.gna.ch [195.49.47.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 2 Dec 2020 00:18:43 -0800 (PST) Received: from macbook-air-1.home (unknown [IPv6:2a02:1205:5053:a220:e536:571e:4b37:a4ea]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id 898246C0C64; Wed, 2 Dec 2020 09:18:41 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) In-Reply-To: Date: Wed, 2 Dec 2020 09:18:40 +0100 Cc: PHP Internals List Content-Transfer-Encoding: quoted-printable Message-ID: <23E6CF0B-77EF-4358-9576-BCB7919154A5@cschneid.com> References: <3dd3c22d-0959-5425-46b1-dade4ac75b00@rhsoft.net> To: "Reindl Harald (privat)" X-Mailer: Apple Mail (2.3608.120.23.2.4) Subject: Re: [PHP-DEV] PHP 8 is_file/is_dir input handling From: cschneid@cschneid.com (Christian Schneider) Am 01.12.2020 um 21:13 schrieb Reindl Harald (privat) = : > Am 01.12.20 um 21:09 schrieb Stanislav Malyshev: >>> we are running error_reporting E_ALL for 17 years now and don't >>> distinct between notice / warning / error, it has to be fixed - >>> period >> Surely you do. Your code continues to run after warning/notice but = stops >> after the error. It's impossible to ignore that. Unless you have an >> error handler that does exit() after a notice (which I have hard time >> believing, honestly, but who knows), there is a very major = distinction. >=20 > my server would trigger a mail every 15 minutes wioth all warnings and = notices to enforce fixing the issue Out of curiosity: What is your fix? Because we are running into this issue with fuzzers bombarding our = website with all types of illegal parameters, string containing 0-bytes = amongst them. Our solution was to basically throw away all user input containing = 0-bytes (except $_FILES) which feels awkward but was the only way to = avoid these messages (and in some cases exceptions) consistently. Concerning the original question: My personal preference in this specific case is Stas=E2=80=99 way: = is_file() is a low-level function and should simply return false for = *anything* which is not a valid, existing filename. Having *everything* = involving paths warn/throw an exception when 0-bytes are involved is an = overly broad generalization. I challenge everybody to show me how changing is_file() to simply return = false (while keeping more high-level functions like, say, popen throwing = an exception) leads to a security hole. In my preferred world the following code would be both safe and = guaranteed to report =E2=80=9EFile not found=E2=80=9C on any invalid = input: If (is_file($filename)) do_something($filename); else message("File not found=E2=80=9C); I=E2=80=99ll try to put a PR together for FileFunction() because I think = those functions should all handle 0-bytes like non-existing files. - Chris