Leakage of sensitive data in exception message
- Rule ID: java_lang_exception
- Languages: java
- Source: exception.yml
Leaking sensitive data to an exception is a common cause of data leaks and can lead to data breaches. This rule looks for instances of sensitive data sent to exceptions.
❌ Avoid using sensitive data in logger messages:
throw new Exception("error for " + user.email);
✅ If you need to identify a user, ensure to use their unique identifier instead of their personal identifiable information:
throw new Exception("error for " + + user.id);
To skip this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --skip-rule=java_lang_exception
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=java_lang_exception
Ready to take the next step? Learn more about Bearer Cloud.