Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116963 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50533 invoked from network); 1 Feb 2022 09:09:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Feb 2022 09:09:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AACBD1804A7 for ; Tue, 1 Feb 2022 02:23:54 -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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS199118 195.10.208.0/24 X-Spam-Virus: No X-Envelope-From: Received: from mout-b-105.mailbox.org (mout-b-105.mailbox.org [195.10.208.50]) (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 ; Tue, 1 Feb 2022 02:23:54 -0800 (PST) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-105.mailbox.org (Postfix) with ESMTPS id 4Jp1HX1YBkz9ssP; Tue, 1 Feb 2022 11:23:52 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=woltlab.com; s=MBO0001; t=1643711030; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dGy6TSDy9hQZFJsxq/DfHIrqpyFNqYU7lSw7f7vQDDA=; b=dZ22WT6Z+aiGphLb7XJ++SEKT6uX7l7V10K11QgCzuXvJ0E8hvSMjmZi2vwz8zpoQ6Hkwt 0fA+fJXeWj4qMv7htW/fxfs7PcLy9ZsMczPw35XNA9PlBSIPptseas7mjUxEUZa2MkB85s 9L+PYl1AyQ/bwUt17S8ybtw9RG/j2XVJwMYO2SrzEityhaVoQ5s3atzvdeJzb//KREedTD i9sEDqgISNxh5seLZUQnawY3pG9sgy3GcpeXLWhdwe6Hyw7asDnUbrvursFmWCZmQheiYB TZfHtt66mOqpEEe3OVRAjbFly81YCqYeSV81wAc7H1r7vsb/2HzKbDuvWdWrfQ== Message-ID: Date: Tue, 1 Feb 2022 11:23:46 +0100 MIME-Version: 1.0 Content-Language: en-US To: =?UTF-8?Q?Alexandru_P=c4=83tr=c4=83nescu?= Cc: PHP internals References: <1d272d70-1d78-5bd1-2e11-9f903c755073@woltlab.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] RFC [Discussion]: Redacting parameters in back traces From: duesterhus@woltlab.com (=?UTF-8?Q?Tim_D=c3=bcsterhus=2c_WoltLab_GmbH?=) Hi Alex On 2/1/22 07:38, Alexandru Pătrănescu wrote: > I think storing the original value within the replacement value should be > considered and voted in this RFC as well, even if implemented in a separate > PR. > I did write some code where I process programmatically the backtraces and > while I might not have used it with sensitive parameters, it would be good > to have the code generic, if this passes. That's fair. I guess you are thinking of including this in the primary vote, instead of a secondary vote, right? It doesn't make sense to leave this out if you already have a use case that would break otherwise. > I'm guessing that mostly means accepting the value as a constructor > parameter exposing a getValue() method > And, of course, making sure var_dump/print_r/string-casting does not print > it. I mean, it looks like the implementation is doable. I believe the following (userland) implementation should do the right thing: final class SensitiveParameterValue { public function __construct(private readonly mixed $value) {} public function getValue(): mixed { return $value; } public function __debugInfo(): array { return []; } public function __serialize(): array { return []; } } It allows you to explicitly retrieve the original value, but makes it hard to accidentally expose it, by hiding it from 'var_dump()' and 'serialize()'. > Thinking about this will bring a small issue into plain sight, the > attribute is the same class as the replacing placeholder, > \SensitiveParameter. > I believe they should be separate classes, \SensitiveParameter marked as an > Attribute that can be applied to parameters and something like > \SensitiveParameterValue that replaces the original value in stack traces. You are right. If we also want to store the original value, we should use a separate class. In any case re-using the attribute class will limit future extensions. I've already adjusted the RFC (and the PoC implementation) to update the replacement value to SensitiveParameterValue: https://wiki.php.net/rfc/redact_parameters_in_back_traces. Regarding storing the original value I'll wait for your reply. Best regards Tim Düsterhus Developer WoltLab GmbH -- WoltLab GmbH Nedlitzer Str. 27B 14469 Potsdam Tel.: +49 331 96784338 duesterhus@woltlab.com www.woltlab.com Managing director: Marcel Werk AG Potsdam HRB 26795 P