Unsanitized user input in Access-Control-Allow-Origin
- Rule ID: javascript_express_insecure_allow_origin
- Languages: javascript
- Source: insecure_allow_origin.yml
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 define the Access-Control-Allow-Origin header with user input. This practice can compromise the security of your application by allowing data access to unintended users.
- Do verify user input if it is absolutely necessary to use it for defining origins. Ensure that the verification process is robust to prevent security breaches.
- Do use a safelist approach when specifying origins. This uses a predefined list of trusted origins and only allows requests from those origins.
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_express_insecure_allow_origin
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=javascript_express_insecure_allow_origin