Unsanitized user input in Access-Control-Allow-Origin

Description

Using unverified user-defined input to set the Access-Control-Allow-Origin header can result in unauthorized access to sensitive data. This vulnerability exposes your application to potential security risks by allowing attackers to specify origins that can access resources.

Remediations

  • Do not use user input to define the Access-Control-Allow-Origin header without validation. This practice can inadvertently grant access to sensitive information.
  • Do verify user input if it is absolutely necessary to use it for defining origins. Implement a mechanism to ensure the input is from a trusted source.
  • Do use a safelist approach when specifying origins. Only allow known, trusted domains to interact with your resources.

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_insecure_allow_origin

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

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