Usage of hard-coded database password

Description

Hard-coded database passwords pose a significant security risk. Embedding passwords directly in your code can lead to unauthorized database access if the codebase is compromised.

Remediations

  • Do not embed database passwords directly in your code. This approach is insecure and makes your database vulnerable to unauthorized access.
    Connection conn = DriverManager.getConnection(url, "admin", "secret");
  • Do use environment variables to store sensitive information such as database passwords. This method keeps credentials out of your codebase and makes them easier to manage securely.
  • Do consider implementing a key-management system to securely handle passwords 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=java_lang_hardcoded_database_password

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

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