CVE-2022-0272 (published 2022-04-21T17:15Z)

Improper Restriction of XML External Entity Reference in GitHub repository detekt/detekt prior to 1.20.0.

Severity: HIGH
CVSS v2 base score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P)
CVSS v3 base score: 9.8, CRITICAL (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

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/detekt/detekt
commit_details: repo_url: https://github.com/detekt/detekt
author: Brais Gabín
author_date: 2022-01-18 18:21:06+01:00
msg: Parse Baseline in a secure way (#4499)
repository: repo_url: https://github.com/detekt/detekt
repo_name: detekt/detekt
description: Static code analysis for Kotlin
repo_language: Kotlin
owner: detekt
file_changes: filename: BaselineFormat.kt
change_type: ModificationType.MODIFY
diff: @@ -3,6 +3,7 @@ package io.gitlab.arturbosch.detekt.core.baseline
 import org.xml.sax.SAXParseException
 import java.nio.file.Files
 import java.nio.file.Path
+import javax.xml.XMLConstants
 import javax.xml.parsers.SAXParserFactory
 import javax.xml.stream.XMLStreamException
 import javax.xml.stream.XMLStreamWriter
@@ -17,7 +18,11 @@ internal class BaselineFormat {
     fun read(path: Path): Baseline {
         try {
             Files.newInputStream(path).use {
-                val reader = SAXParserFactory.newInstance().newSAXParser()
+                val reader = SAXParserFactory.newInstance()
+                    .apply {
+                        setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true)
+                    }
+                    .newSAXParser()
                 val handler = BaselineHandler()
                 reader.parse(it, handler)
                 return handler.createBaseline()

programming_language: Scala