Usage of hard-coded secret

Description

Storing secret values directly in the source code exposes them to unauthorized access and compromises security.

Remediations

  • Do not embed secret values directly in your source code. This practice makes your application vulnerable to attacks if the source code is accessed.
    SECRET_KEY = "hardcoded_secret_key" # unsafe
  • 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 to ensure they are not exposed in the source code.
    SECRET_KEY = ENV['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=ruby_lang_hardcoded_secret

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

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