CVE-2022-0219 (published 2022-01-20T17:15Z)

Improper Restriction of XML External Entity Reference in GitHub repository skylot/jadx prior to 1.3.2.

Severity: MEDIUM
CVSS v2 base score: 4.3 (AV:N/AC:M/Au:N/C:P/I:N/A:N)
CVSS v3 base score: 5.5, MEDIUM (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N)

Weakness information:
cwe_id: CWE-611
cwe_name: Improper Restriction of XML External Entity Reference
description: The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
extended_description: 
            XML documents optionally contain a Document Type Definition (DTD), which, among other features, enables the definition of XML entities. It is possible to define an entity by providing a substitution string in the form of a URI. The XML parser can access the contents of this URI and embed these contents back into the XML document for further processing.
            By submitting an XML file that defines an external entity with a file:// URI, an attacker can cause the processing application to read the contents of a local file. For example, a URI such as "file:///c:/winnt/win.ini" designates (in Windows) the file C:\Winnt\win.ini, or file:///etc/passwd designates the password file in Unix-based systems. Using URIs with other schemes such as http://, the attacker can force the application to make outgoing requests to servers that the attacker cannot reach directly, which can be used to bypass firewall restrictions or hide the source of attacks such as port scanning.
            Once the content of the URI is read, it is fed back into the application that is processing the XML. This application may echo back the data (e.g. in an error message), thereby exposing the file contents.
         
         

Fix information:
repo_url: https://github.com/skylot/jadx
commit_details: repo_url: https://github.com/skylot/jadx
author: Skylot
author_date: 2022-01-20 11:17:12+00:00
msg: fix: use secure xml parser for process manifest
repository: repo_url: https://github.com/skylot/jadx
repo_name: skylot/jadx
description: Dex to Java decompiler
repo_language: Java
owner: skylot
file_changes: filename: ExportGradleProject.java
change_type: ModificationType.MODIFY
diff: @@ -8,7 +8,6 @@
 import java.util.Set;
 
 import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -24,6 +23,7 @@
 import jadx.core.utils.exceptions.JadxRuntimeException;
 import jadx.core.utils.files.FileUtils;
 import jadx.core.xmlgen.ResContainer;
+import jadx.core.xmlgen.XmlSecurity;
 
 public class ExportGradleProject {
 
@@ -139,7 +139,7 @@ private ApplicationParams getApplicationParams(Document androidManifest, Documen
 
 	private Document parseXml(String xmlContent) {
 		try {
-			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			DocumentBuilder builder = XmlSecurity.getSecureDbf().newDocumentBuilder();
 			Document document = builder.parse(new InputSource(new StringReader(xmlContent)));
 
 			document.getDocumentElement().normalize();

programming_language: Java