Unsanitized user input in HTTP request (SSRF)

Description

Applications should not connect to locations formed from user input. This is bad security practice because it can lead to Server-Side-Request-Forgery (SSRF) attacks. This rule checks for URLs containing user-supplied data.

Remediations

❌ Avoid using user input in HTTP URLs:

new URL(request.getParameter("someRandomUrl")).getContent();

✅ Use user input indirectly to form a URL:

String url;
if (request.getParameter("selectedUrl") == "option1") {
url = "api1.com";
} else {
url = "api2.com";
}

new URL(url).getContent();

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_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=java_lang_http_url_using_user_input

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