Usage of hard-coded secret

Description

Storing secret values directly in the source code exposes them to unauthorized access and compromises security. This practice makes your application vulnerable to attacks.

Remediations

  • Do not hard-code secrets in your application code. Hard-coding makes sensitive information easily accessible to anyone who can view the code.
  • Do use environment variables to manage secrets securely. This method keeps sensitive information out of your codebase and makes it more difficult for unauthorized users to access.
  • Do retrieve secrets from a secure location at runtime. This approach minimizes the risk of exposing sensitive information and enhances the security of your application.
    $secret = getenv('SECRET_KEY');
  • Do consider implementing a key-management system to securely handle secrets and other sensitive information. This approach provides enhanced security measures for managing and accessing credentials.

References

Associated CWE

OWASP Top 10

Configuration

To skip this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --skip-rule=php_lang_hardcoded_secret

To run only this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --only-rule=php_lang_hardcoded_secret