-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement PHP 8.2 SensitiveParameter
to redact sensitive/password data in backtraces.
#38142
Comments
Hi @convenient. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Here's a rector rule for anyone wanting to add to their codebase https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#addsensitiveparameterattributerector |
Hi @engcom-Hotel. Thank you for working on this issue.
|
Hello @convenient, Thanks for the report and collabration! I agree with your point we should have Hence marking this issue as a feature request for now. Thanks |
@engcom-Hotel While PHP 8.1 does not support this functionality, I do not believe that prevents this moving along. It would simply not take effect until PHP 8.2. See this example file has // example.php
<?php
class Example
{
public function login($username, #[\SensitiveParameter] $password)
{
throw new \Exception('something unexpected happened');
}
}
(new Example)->login('SomeCoolUsername', 'SomeCoolerPassword12345'); PHP 8.1Runs as normal, still shows
PHP 8.2Runs as normal, shows
|
This is potentially blocked by laminas/laminas-code#145. Magento's code generation will not currently create attributes in |
Summary
Currently if an exception is thrown while handling a sensitive parameter, part of that parameter is exposed in a stack trace.
We could enable
zend.exception_ignore_args
to turn off all the arguments from the traces, but that would affect the ability to support the sites and debug issues as we'd have no data.As of PHP 8.2 there is support to provide annotations to function parameters to ensure they're excluded from back traces for this exact purpose.
It looks like
And would prevent the contents of
$bar
being exposed in any tracesExamples
For example it looks like this at a basic level
See the the log contains
SomeCoolerPassw
which is not my full example password, but it is a lot.The extensible nature of Magento means this kind of thing can happen in many core places
For example inside
performIdentityCheck
if someone had hooked into the observeradmin_user_authenticate_after
with some flaky logic that could trigger an exception, it could cause this function to fail like in the above demo.This would result in part of the password being exposed in the logs
magento2/app/code/Magento/User/Model/User.php
Lines 965 to 997 in 1819863
Proposed solution
When it becomes time to drop PHP 8.1 support add
#[\SensitiveParameter]
to all password / token fields in the codebase.Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: