Add #[\SensitiveParameter] to secret parameter in setAuth()#32
Add #[\SensitiveParameter] to secret parameter in setAuth()#32semgrep-code-badoo[bot] wants to merge 1 commit intomasterfrom
Conversation
Mark the `$secret` parameter in `Client::setAuth()` with the `#[\SensitiveParameter]` attribute to prevent credential exposure in stack traces. ## Changes - Added `#[\SensitiveParameter]` attribute to the `$secret` parameter in `src/REST/Client.php` ## Why The `#[\SensitiveParameter]` attribute (introduced in PHP 8.2) instructs PHP to redact the parameter value from stack traces and exception messages. Without this attribute, if an exception is thrown during authentication, the secret (password or API token) could be logged or displayed in error output, potentially exposing credentials to unauthorized parties. ## Semgrep Finding Details Function parameter like $secret, $secretKey, or $secret_key contains sensitive data but is not marked with #[\SensitiveParameter]. If the application crashes or throws an exception, this value may be included in stack traces or error logs, leading to unintended secret disclosure. Add the #[\SensitiveParameter] attribute to prevent exposure. @9071412 requested Semgrep Assistant generate this pull request to fix [a finding](https://semgrep.dev/orgs/bmbl/findings/695640482).
| * @return static | ||
| */ | ||
| public function setAuth(string $login, string $secret) : Client | ||
| public function setAuth(string $login, #[\SensitiveParameter] string $secret) : Client |
There was a problem hiding this comment.
Semgrep identified an issue in your code:
Function parameter like $secret, $secretKey, or $secret_key contains sensitive data but is not marked with #[\SensitiveParameter]. If the application crashes or throws an exception, this value may be included in stack traces or error logs, leading to unintended secret disclosure. Add the #[\SensitiveParameter] attribute to prevent exposure.
To resolve this comment:
✨ Commit Assistant Fix Suggestion
- Add the
#[\SensitiveParameter]attribute before the$secretfunction parameter in thesetAuthmethod. The function should look like:
public function setAuth(string $login, #[\SensitiveParameter] string $secret) : Client. - Ensure there are no other function parameters in your codebase named
$secret,$secretKey, or$secret_keywithout the#[\SensitiveParameter]attribute and apply the same fix if you find any.
Adding the #[\SensitiveParameter] attribute will help prevent accidental disclosure of secret values in stack traces and logs.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by php-missing-sensitive-parameter-secret.
You can view more details about this finding in the Semgrep AppSec Platform.
Mark the
$secretparameter inClient::setAuth()with the#[\SensitiveParameter]attribute to prevent credential exposure in stack traces.Changes
#[\SensitiveParameter]attribute to the$secretparameter insrc/REST/Client.phpWhy
The
#[\SensitiveParameter]attribute (introduced in PHP 8.2) instructs PHP to redact the parameter value from stack traces and exception messages. Without this attribute, if an exception is thrown during authentication, the secret (password or API token) could be logged or displayed in error output, potentially exposing credentials to unauthorized parties.Semgrep Finding Details
Function parameter like $secret, $secretKey, or $secret_key contains sensitive data but is not marked with #[\SensitiveParameter]. If the application crashes or throws an exception, this value may be included in stack traces or error logs, leading to unintended secret disclosure. Add the #[\SensitiveParameter] attribute to prevent exposure.
@9071412 requested Semgrep Assistant generate this pull request to fix a finding.