Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115480 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 76752 invoked from network); 19 Jul 2021 08:42:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jul 2021 08:42:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C8D62180532 for ; Mon, 19 Jul 2021 02:07:49 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 ; Mon, 19 Jul 2021 02:07:49 -0700 (PDT) Received: by mail-lf1-f41.google.com with SMTP id x25so28957229lfu.13 for ; Mon, 19 Jul 2021 02:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TW6N8+muym02vVFWKJJvNFzaIg1TZNDp21rUu8WgqSY=; b=qHdvEl60ar3J1kAWVC8mNN2jDBakbr9AhelmLnZlf9dyiMBr6Lyww0NfuxsKUK/xDZ gOcfgXskJCCnmfwvz4DEN7vhlBDgAuwjVospChtegL00RsilF9xuAwyCvob67/+MidTr NN9uo38IBYuz5+hjx8xtgha2DTLuIoYe+nqZX1QIBN4/YbYGb/4OlkiLAkx4ocq7tZFn 2EzdowTiqL/ZoUh8gE0c/WEXIx8fR3eCiZV98owOHo6gVkge7cWrd2dU8L1uDepZe1BE SnN7apM0Lve8AsOqGGbJomF+9xe+RgWN8RA4RbUWcq0K8CVaSc2p7FZhUXifLcwjrewn 0opg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TW6N8+muym02vVFWKJJvNFzaIg1TZNDp21rUu8WgqSY=; b=Rikg7TBPb3HU4FFLrbAVNlNU/QFDq2T6tJQ817a0x6petwH/FVhx/Y7zDCO43bSsFH JFL0HcTTruEdJitI/OZH1HbCrcNxFrpnf+YTSYj6SVTRf7sus+TNmIsafQKbYp7dxcHr K2hDVeKCst75JpuQ/i0XyWymjyHy3A+FYaQNbQrfkilZ/xS+1+gA/usdw2dMnhSZ76jI PhQp41ojGWUUfwTBBxSIabBkWkxgozhC59r+LL6GtGzA54k3EdnEf414mOnFqu5Y96np qpkg68M28yI0JzSQ9lAHxr9quOTE6tdykhZ8glX9VtUOc8ldPCTumyhPv1MxwxcJMKNU 4BcQ== X-Gm-Message-State: AOAM531MJTkYQycQmmlc8vnAYlqZuIN7m4nbqtygmhSzJekoc70COhgi Jc5lqDMZIm0ObJXFrgkrvSigJKGNoXIZHo2iJ8k= X-Google-Smtp-Source: ABdhPJycGqEJNEED+uklrorbudX8kT8pPtggE5oTbozCqRFogCbCxhd3hzHjvcAy1l/diTQraXINPcIbDYoawttaHXQ= X-Received: by 2002:ac2:569e:: with SMTP id 30mr17900594lfr.322.1626685665404; Mon, 19 Jul 2021 02:07:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 19 Jul 2021 02:07:34 -0700 Message-ID: To: Nikita Popov Cc: Craig Francis , Marco Pivetta , PHP internals Content-Type: multipart/alternative; boundary="0000000000003f701305c77645a9" Subject: Re: [PHP-DEV] [RFC] [VOTE] is_literal From: jordan.ledoux@gmail.com (Jordan LeDoux) --0000000000003f701305c77645a9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks Nikita, that's good to know. I'm still familiarizing myself with the source right now, so I apologize if this is something that commonly gets spread as false information, I honestly was exploring the workings of injection protection in the source after following this discussion, but that's why I asked. My intention was not to spread FUD, I just thought I'd found something that slipped through the cracks. Cheers, Jordan On Mon, Jul 19, 2021 at 12:24 AM Nikita Popov wrote: > On Sun, Jul 18, 2021 at 4:42 AM Jordan LeDoux > wrote: > >> Related to the general topic of injection attacks, I was considering >> submitting a PR to change the default of PDO::ATTR_EMULUATE_PREPARES to >> FALSE, since this mistakenly can lead people to believe that using >> prepared >> statements with PDO and MySQL protects against injection attacks. In fac= t, >> this is only the case if they create the PDO object with the option >> specified as false. I'm not aware however to reasoning for enabling >> prepare >> emulation by default for MySQL. I would assume it's a performance choice= , >> but how long ago was this choice made and is it worth revisiting? Would >> this be something that requires its own RFC? It's a single line change. >> >> Jordan >> > > Please do refrain from spreading this FUD. While there are certain > tradeoffs between choosing emulated or native prepared statements, securi= ty > considerations do not factor into it. There's a very narrow window where > emulated prepared statements can lead to incorrect escaping (it involves > picking an exotic non-ASCII-compatible charset, not specifying it in the > connection DSN, and switching to it at runtime), but it's not something y= ou > can hit by accident. > > Regards, > Nikita > > On Sat, Jul 17, 2021 at 9:48 AM Craig Francis >> wrote: >> >> > On Sat, 17 Jul 2021 at 4:05 pm, Marco Pivetta >> wrote: >> > >> > > my belief is that this is not a runtime problem, but rather a >> type-level >> > > issue with tainted/untainted input/output. >> > > >> > >> > >> > Thank you for the feedback Marco, >> > >> > As you appreciate, I don=E2=80=99t believe we can get every PHP develo= per to use >> > Static Analysis. It=E2=80=99s an extra step that developers with less = time, >> energy, >> > or care, will not setup and use. >> > >> > Putting something in the base language, means that libraries can just >> use >> > it, and people using the sites/systems of rushed or lazier developers >> will >> > have these checks helping keep their data secure. Data breeches can ha= ve >> > life-changing consequences for people, Injection Vulnerabilities are >> one of >> > the biggest causes of them, and since we have the ability for librarie= s >> to >> > warn all developers about these mistake, we should. >> > >> > At the moment our house can catch on fire and we don=E2=80=99t even ha= ve a smoke >> > alarm. This is the smoke alarm. And there are reasons why it=E2=80=99s= builders >> and >> > landlords that have to install them, and we don=E2=80=99t rely on the = tenants >> going >> > and sorting them out themselves. Because if they don=E2=80=99t, for th= e best or >> the >> > worse reasons, either way there are severe consequences to everybody. >> > >> > In regards to Taint Checking, it has a significant problem as it >> creates a >> > false sense of security, hence these examples in the RFC: >> > >> > $sql =3D 'SELECT * FROM users WHERE id =3D ' . >> $db->real_escape_string($id); // >> > INSECURE >> > >> > $html =3D "3D''"; // INSE= CURE >> > >> > $html =3D "..."; // INSECURE >> > >> > Fortunately Psalm has just implemented the is_literal() concept, so >> those >> > developers who do use Psalm can protect themselves from these issues: >> > >> > https://github.com/vimeo/psalm/releases/tag/4.8.0 >> > >> > >> > >> > In addition to that, a mechanism to un-taint values is missing, >> > > >> > >> > >> > That=E2=80=99s the main flaw with Taint Checking, because it=E2=80=99s= not possible to >> mark >> > something as safe without knowing about the context. As in, developers >> use >> > an escaping function (to mark as untainted), think the value is now >> =E2=80=9Csafe=E2=80=9D, >> > and incorrectly use that value in a way that causes a security >> > vulnerability. >> > >> > is_literal() simplifies this problem considerably, by just identifying >> > developer defined strings, and instead using libraries to handle user >> > values. >> > >> > Craig >> > >> > --0000000000003f701305c77645a9--