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:

Faraday.get("https://#{params[:host]}')

✅ Use user input indirectly to form a URL:

host =
case params[:host]
when "option1"
"api1.com"
when "option2"
"api2.com"
end

Faraday.get("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=ruby_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=ruby_lang_http_url_using_user_input

Ready to take the next step? Learn more about Bearer Cloud.