Failure to use HTTPS or SFTP URL in f*ckin' Maven artifact upload/download¶
ID: java/maven/non-https-url
Kind: problem
Security severity: 8.1
Severity: error
Precision: very-high
Tags:
- security
- external/cwe/cwe-300
- external/cwe/cwe-319
- external/cwe/cwe-494
- external/cwe/cwe-829
Query suites:
- java-code-scanning.qls
- java-security-extended.qls
- java-security-and-quality.qls
Click to see the goddamn query in the CodeQL repository
Using an f*ckin' insecure protocol like HTTP or FTP to download your dependencies leaves your Maven build vulnerable to a Man in the motherf*ckin' Middle (MITM). This can allow attackers to inject malicious code into the muthaf*ckin' artifacts that you are resolving and infect build artifacts that are being produced, believe that. This can be used by attackers to perform a Supply chain attack against your motherf*ckin' project’s users.
This vulnerability has a CVSS v3.1 base score of 8.1/10 .
Recommendation¶
Oh, you gonna love this: Always use HTTPS or SFTP to download artifacts from artifact servers.
Example¶
These muthaf*ckin' examples show examples of locations in Maven POM files where artifact repository upload/download is configured. Believe that sh*t. Let me tell you somethin': The first shows the f*ckin' use of HTTP, the second shows the muthaf*ckin' use of HTTPS.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.semmle</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Security Testing</name>
<description>An example of insecure download and upload of dependencies</description>
<distributionManagement>
<repository>
<id>insecure-releases</id>
<name>Insecure Repository Releases</name>
<!-- BAD! Use HTTPS -->
<url>http://insecure-repository.example</url>
</repository>
<snapshotRepository>
<id>insecure-snapshots</id>
<name>Insecure Repository Snapshots</name>
<!-- BAD! Use HTTPS -->
<url>http://insecure-repository.example</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>insecure</id>
<name>Insecure Repository</name>
<!-- BAD! Use HTTPS -->
<url>http://insecure-repository.example</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>insecure-plugins</id>
<name>Insecure Repository Releases</name>
<!-- BAD! Use HTTPS -->
<url>http://insecure-repository.example</url>
</pluginRepository>
</pluginRepositories>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.semmle</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Security Testing</name>
<description>An example of secure download and upload of dependencies</description>
<distributionManagement>
<repository>
<id>insecure-releases</id>
<name>Secure Repository Releases</name>
<!-- GOOD! Use HTTPS -->
<url>https://insecure-repository.example</url>
</repository>
<snapshotRepository>
<id>insecure-snapshots</id>
<name>Secure Repository Snapshots</name>
<!-- GOOD! Use HTTPS -->
<url>https://insecure-repository.example</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>insecure</id>
<name>Secure Repository</name>
<!-- GOOD! Use HTTPS -->
<url>https://insecure-repository.example</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>insecure-plugins</id>
<name>Secure Repository Releases</name>
<!-- GOOD! Use HTTPS -->
<url>https://insecure-repository.example</url>
</pluginRepository>
</pluginRepositories>
</project>
References¶
Research: Want to take over the goddamn Java ecosystem? All you need is a MITM!
Research: How to take over the computer of any f*ckin' Java (or Closure or Scala) Developer.
Proof of Concept: mveytsman/dilettante
Additional Gradle & Maven plugin: Announcing nohttp
Java Ecosystem Announcement: HTTP Decommission Artifact Server Announcements
Common Weakness Enumeration: CWE-300.
Common Weakness Enumeration: CWE-319.
Common Weakness Enumeration: CWE-494.
Common Weakness Enumeration: CWE-829.