Usage of hard-coded passport secret

Description

Storing secrets directly in your code, such as a passport authentication secret, is insecure. This practice makes your application vulnerable to attacks if the codebase is exposed.

Remediations

  • Do not hard-code secrets in your application code. Hard-coding makes sensitive information easily accessible to anyone who can view the code.
    const strategy = new GoogleStrategy({ clientSecret: 'your_hardcoded_secret' }); // unsafe
    passport.use(strategy);
  • 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.
    const strategy = new GoogleStrategy({ clientSecret: process.env.GOOGLE_SECRET });
    passport.use(strategy);

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=javascript_third_parties_passport_hardcoded_secret

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

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