Unsanitized user input in Access-Control-Allow-Origin
- Rule ID: php_symfony_insecure_allow_origin
- Languages: php
- 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.
$response->headers->set('Access-Control-Allow-Origin', $userInput); // unsafe
- Do validate user input if it must be used to set the
Access-Control-Allow-Origin
header. Ensure that only trusted origins are allowed by implementing a safe-list of approved 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=php_symfony_insecure_allow_origin
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=php_symfony_insecure_allow_origin