CodeQL documentation

Failure to use HTTPS or SFTP URL in 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 query in the CodeQL repository

Using an insecure protocol like HTTP or FTP to download your dependencies leaves your Maven build vulnerable to a Man in the Middle (MITM). This can allow attackers to inject malicious code into the artifacts that you are resolving and infect build artifacts that are being produced. This can be used by attackers to perform a Supply chain attack against your project’s users.

This vulnerability has a CVSS v3.1 base score of 8.1/10 .

Recommendation

Always use HTTPS or SFTP to download artifacts from artifact servers.

Example

These examples show examples of locations in Maven POM files where artifact repository upload/download is configured. The first shows the use of HTTP, the second shows the use of HTTPS.


 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">

    4.0.0

    com.semmle
    parent
    1.0
    pom

    Security Testing
    An example of insecure download and upload of dependencies

    
        
            insecure-releases
            Insecure Repository Releases
            
            http://insecure-repository.example
        
        
            insecure-snapshots
            Insecure Repository Snapshots
            
            http://insecure-repository.example
        
    
    
        
            insecure
            Insecure Repository
            
            http://insecure-repository.example
        
    
    
        
            insecure-plugins
            Insecure Repository Releases
            
            http://insecure-repository.example
        
    


 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">

    4.0.0

    com.semmle
    parent
    1.0
    pom

    Security Testing
    An example of secure download and upload of dependencies

    
        
            insecure-releases
            Secure Repository Releases
            
            https://insecure-repository.example
        
        
            insecure-snapshots
            Secure Repository Snapshots
            
            https://insecure-repository.example
        
    
    
        
            insecure
            Secure Repository
            
            https://insecure-repository.example
        
    
    
        
            insecure-plugins
            Secure Repository Releases
            
            https://insecure-repository.example
        
    

References

  • © GitHub, Inc.
  • Terms
  • Privacy