Mark parameters containing user credentials as sensitive#878
Open
Mark parameters containing user credentials as sensitive#878
Conversation
ee3e53a to
a3761c0
Compare
PHP 8.2 introduced the `SensitiveParameter` attribute. The effect of the attribute is that the value of the parameter is no longer directly shown in stack traces; instead, starting with PHP 8.2, the parameter will be presented as a `SensitiveParameterValue` object. As the attribute only applies to parameters, it (unfortunately) has no effect on serialization of the object. See: https://3v4l.org/StoQO Might be an idea to start a discussion about an `SensitiveProperty` attribute on the PHP Internals mailing list, but that's outside the scope of this PR. For now, this PR marks the `$args` parameter for the `Auth\Basic` class constructor and the `Proxy\Http` constructor as sensitive as both of these are supposed to contain user credentials (user name, password) for accessing a protected URL. Includes updating the example code for custom authentication to also use the attribute. **Open question**: the `$options` array passed to a large range of Requests methods can [also contain credentials](https://github.com/WordPress/Requests/blob/ebb9f65855c860bc33005b3d8bccf6444e598fba/src/Requests.php#L395-L399). Should this parameter also be marked as sensitive in all appropriate places ? Refs: * https://www.php.net/manual/en/class.sensitiveparameter.php * https://wiki.php.net/rfc/redact_parameters_in_back_traces
a3761c0 to
ef400a8
Compare
Member
Wrapping the entire How about creating a polyfill for See https://www.php.net/manual/en/class.sensitiveparametervalue.php |
Member
Author
|
Let's think this over some more. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PHP 8.2 introduced the
SensitiveParameterattribute.The effect of the attribute is that the value of the parameter is no longer directly shown in stack traces; instead, starting with PHP 8.2, the parameter will be presented as a
SensitiveParameterValueobject.As the attribute only applies to parameters, it (unfortunately) has no effect on serialization of the object. See: https://3v4l.org/StoQO Might be an idea to start a discussion about an
SensitivePropertyattribute on the PHP Internals mailing list, but that's outside the scope of this PR.For now, this PR marks the
$argsparameter for theAuth\Basicclass constructor and theProxy\Httpconstructor as sensitive as both of these are supposed to contain user credentials (user name, password) for accessing a protected URL.Includes updating the example code for custom authentication to also use the attribute.
Open question
The
$optionsarray passed to a large range of Requests methods can also contain credentials. Should this parameter also be marked as sensitive in all appropriate places ?Refs: