Skip to content

Add #[\SensitiveParameter] to $secret in ClientRaw::setAuth()#34

Draft
semgrep-code-badoo[bot] wants to merge 1 commit into
masterfrom
semgrep-autofix/1774442108
Draft

Add #[\SensitiveParameter] to $secret in ClientRaw::setAuth()#34
semgrep-code-badoo[bot] wants to merge 1 commit into
masterfrom
semgrep-autofix/1774442108

Conversation

@semgrep-code-badoo
Copy link
Copy Markdown

Mark the $secret parameter as sensitive to prevent credential exposure in stack traces.

Changes

  • Added #[\SensitiveParameter] attribute to the $secret parameter in ClientRaw::setAuth()

Why

When an exception is thrown, PHP includes function arguments in stack traces. Without the #[\SensitiveParameter] attribute, the authentication secret could be logged or displayed in error output, potentially exposing credentials. This PHP 8.2+ attribute redacts the parameter value in stack traces, preventing unintended secret disclosure.

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.


⚠️ Review carefully before merging. This PR was generated by AI and may cause breaking changes or introduce new vulnerabilities.

Mark the `$secret` parameter as sensitive to prevent credential exposure in stack traces.

## Changes
- Added `#[\SensitiveParameter]` attribute to the `$secret` parameter in `ClientRaw::setAuth()`

## Why
When an exception is thrown, PHP includes function arguments in stack traces. Without the `#[\SensitiveParameter]` attribute, the authentication secret could be logged or displayed in error output, potentially exposing credentials. This PHP 8.2+ attribute redacts the parameter value in stack traces, preventing unintended secret disclosure.

## 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/695640481).
Comment thread src/REST/ClientRaw.php
* @return ClientRaw
*/
public function setAuth(string $login, string $secret) : ClientRaw
public function setAuth(string $login, #[\SensitiveParameter] string $secret) : ClientRaw
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
  1. Add the attribute #[\SensitiveParameter] before the $secret parameter in the function definition so the first line reads: public function setAuth(string $login, #[\SensitiveParameter] string $secret) : ClientRaw.
  2. Make sure there are no syntax errors resulting from this change.

This marks the $secret parameter as sensitive and helps prevent its value from being exposed in error logs or stack traces.

💬 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants