Unsanitized user input in HTTP request (SSRF)

Description

Applications should not connect to locations formed from user input. This rule checks for URLs containing user-supplied data.

Remediations

❌ Avoid using user input in HTTP URLs:

$curl = curl_init("https://{$_GET['host']}');

✅ Use user input indirectly to form a URL:

if ($_GET["host"] == "option1") {
$host = "api1.com";
} else {
$host = "api2.com";
}

$curl = curl_init("https://$host');

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_lang_http_url_using_user_input

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

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