Java Insecure Http Url
Description
The detector identifies Java code that creates insecure HTTP connections instead of HTTPS. Using plain HTTP for network communications exposes the application to man-in-the-middle attacks where attackers can intercept and modify the transmitted data. This represents a significant security risk as sensitive information could be exposed or tampered with during transmission.
Detection Strategy
• Identifies calls to URL/URI builder methods that use HTTP URLs
• Detects usage of 'newBuilder()' method when the argument contains an HTTP URL
• Checks for 'uri()' method calls where the URI parameter uses an insecure HTTP scheme
• Analyzes string arguments and variables passed to these methods to confirm they contain 'http://' URLs
Vulnerable code example
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse.BodyHandlers;
import java.net.URI;
public class VulnerableHttpExample {
public void sendRequest() {
HttpClient client = HttpClient.newHttpClient();...✅ Secure code example
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse.BodyHandlers;
import java.net.URI;
import java.time.Duration;
public class SecureHttpExample {
public void sendRequest() {...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.