logo

Database

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.

Weakness:

372 - Use of an insecure channel - HTTP

Category: Information Collection

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() {...